# Handwritten signature pad

> A paper box to sign with a finger or mouse, with a stroke that thins with speed and an option to type your name.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-in-signature
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

A signature field drawn on a canvas over dotted paper, with the classic cross and dashed line. Pointer events capture mouse, pen and touch, and each segment is smoothed with curves while its width thins with speed, so it looks like ink rather than a polyline. A keyboard mode swaps the canvas for a text input in a script typeface.

The main color is the ink and the second color the cross. Use it in delivery confirmations, rental agreements and consent forms, and export the drawing with canvas toDataURL when you need to store it.

## Code

### HTML

```html
<div class="uvq06-sg"><div class="pd"><canvas role="img" aria-label="Signature area"></canvas><span class="hn" aria-hidden="true">Sign here</span><span class="x" aria-hidden="true">×</span><span class="ln" aria-hidden="true"></span><label class="ty"><span class="sr">Type your name</span><input placeholder="Type your name" autocomplete="name"></label></div><div class="rw"><button type="button" class="md" aria-pressed="false">Use keyboard</button><button type="button" class="cl">Clear</button><span class="ok" aria-live="polite"></span></div></div>
```

### CSS

```css
.uvq06-sg {
  --c1: #1e3a8a;
  --c2: #b45309;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-sg {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 19em;
}

.uvq06-sg .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-sg .pd {
  position: relative;
  height: 8em;
  border-radius: .9em;
  overflow: hidden;
  background: #fbfaf6;
  background-image: radial-gradient(rgba(0,0,0,.04) 1px,transparent 1px);
  background-size: .5em .5em;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1em 1.8em -1em rgba(0,0,0,.45);
  cursor: crosshair;
}

.uvq06-sg .pd:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg canvas.fade {
  opacity: 0;
}

.uvq06-sg .hn {
  position: absolute;
  left: 0;
  right: 0;
  top: 1.1em;
  font-size: .72em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(0,0,0,.32);
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg.has .hn {
  opacity: 0;
}

.uvq06-sg .x {
  position: absolute;
  left: .75em;
  bottom: 1.45em;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1;
  color: var(--c2);
  pointer-events: none;
}

.uvq06-sg .ln {
  position: absolute;
  left: 2.2em;
  right: 1em;
  bottom: 1.85em;
  height: 1.5px;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 .4em,transparent .4em .6em);
  pointer-events: none;
}

.uvq06-sg .ty {
  position: absolute;
  left: 2.3em;
  right: 1em;
  bottom: 1.95em;
  display: none;
}

.uvq06-sg .ty input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: 400 2em/1.2 "Snell Roundhand","Segoe Script","Brush Script MT","Lucida Handwriting",cursive;
  color: var(--c1);
  caret-color: var(--c1);
}

.uvq06-sg .ty input::placeholder {
  color: rgba(0,0,0,.25);
}

.uvq06-sg.kb .ty {
  display: block;
}

.uvq06-sg.kb canvas,.uvq06-sg.kb .hn {
  display: none;
}

.uvq06-sg.kb .pd {
  cursor: text;
}

.uvq06-sg .rw {
  display: flex;
  align-items: center;
  gap: .4em;
  margin-top: .7em;
}

.uvq06-sg .rw button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .5em .85em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-sg .rw button:hover {
  background: color-mix(in srgb,var(--fg) 11%,transparent);
}

.uvq06-sg .rw button:active {
  transform: scale(.94);
}

.uvq06-sg .rw button:focus-visible {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg .md[aria-pressed="true"] {
  color: #fff;
  background: var(--c1);
}

.uvq06-sg .ok {
  margin-left: auto;
  font-size: .78em;
  font-weight: 700;
  color: #16a34a;
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-sg,.uvq06-sg *,.uvq06-sg *::before,.uvq06-sg *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq06-sg").forEach(el => {
  const cv=el.querySelector("canvas"),cx=cv.getContext("2d"),md=el.querySelector(".md"),cl=el.querySelector(".cl"),ok=el.querySelector(".ok"),ty=el.querySelector(".ty input");let dr=false,pts=[],lw=2,k=2,t=0;
const r0=window.devicePixelRatio||1;cv.width=Math.max(1,cv.offsetWidth*r0*2);cv.height=Math.max(1,cv.offsetHeight*r0*2);k=cv.width/Math.max(1,cv.offsetWidth);
const ink=()=>getComputedStyle(el).getPropertyValue("--c1").trim()||"#1e3a8a";
const done=v=>{el.classList.toggle("has",v);ok.textContent=v?"✓ Signed":""};
const seg=p=>{const a=pts[pts.length-1],z=pts[pts.length-2]||a;const d=Math.hypot(p.x-a.x,p.y-a.y),v=d/Math.max(1,p.t-a.t)/k;lw=lw*.6+Math.max(.9,Math.min(3.2,3.4-v*1.2))*k*.4;cx.lineWidth=lw;cx.beginPath();cx.moveTo((a.x+z.x)/2,(a.y+z.y)/2);cx.quadraticCurveTo(a.x,a.y,(a.x+p.x)/2,(a.y+p.y)/2);cx.stroke();pts.push(p)};
const start=p=>{pts=[p];cx.strokeStyle=cx.fillStyle=ink();cx.lineCap=cx.lineJoin="round";lw=2.2*k;cx.beginPath();cx.arc(p.x,p.y,lw/2,0,7);cx.fill()};
const pt=e=>{const r=cv.getBoundingClientRect();return{x:(e.clientX-r.left)*cv.width/r.width,y:(e.clientY-r.top)*cv.height/r.height,t:e.timeStamp}};
cv.addEventListener("pointerdown",e=>{dr=true;cv.setPointerCapture(e.pointerId);start(pt(e));e.preventDefault()});
cv.addEventListener("pointermove",e=>{if(dr){seg(pt(e));done(true)}});
const up=()=>{dr=false};cv.addEventListener("pointerup",up);cv.addEventListener("pointercancel",up);
cl.addEventListener("click",()=>{cv.classList.add("fade");clearTimeout(t);t=setTimeout(()=>{cx.clearRect(0,0,cv.width,cv.height);cv.classList.remove("fade")},300);ty.value="";done(false)});
md.addEventListener("click",()=>{const on=md.getAttribute("aria-pressed")!=="true";md.setAttribute("aria-pressed",String(on));el.classList.toggle("kb",on);if(on)ty.focus()});
ty.addEventListener("input",()=>done(!!ty.value.trim()));
const W=cv.width,Hh=cv.height;start({x:W*.16,y:Hh*.55,t:0});for(let s=1;s<=160;s++){const q=s/160;seg({x:W*(.16+.6*q+.035*Math.sin(q*30)),y:Hh*(.56-.17*Math.sin(q*15)*Math.exp(-q*1.3)-.06*Math.cos(q*30)),t:s*9})}done(true);
return()=>clearTimeout(t)
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-sg {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 19em;
}

.uvq06-sg .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-sg .pd {
  position: relative;
  height: 8em;
  border-radius: .9em;
  overflow: hidden;
  background: #fbfaf6;
  background-image: radial-gradient(rgba(0,0,0,.04) 1px,transparent 1px);
  background-size: .5em .5em;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1em 1.8em -1em rgba(0,0,0,.45);
  cursor: crosshair;
}

.uvq06-sg .pd:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg canvas.fade {
  opacity: 0;
}

.uvq06-sg .hn {
  position: absolute;
  left: 0;
  right: 0;
  top: 1.1em;
  font-size: .72em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(0,0,0,.32);
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg.has .hn {
  opacity: 0;
}

.uvq06-sg .x {
  position: absolute;
  left: .75em;
  bottom: 1.45em;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1;
  color: var(--c2);
  pointer-events: none;
}

.uvq06-sg .ln {
  position: absolute;
  left: 2.2em;
  right: 1em;
  bottom: 1.85em;
  height: 1.5px;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 .4em,transparent .4em .6em);
  pointer-events: none;
}

.uvq06-sg .ty {
  position: absolute;
  left: 2.3em;
  right: 1em;
  bottom: 1.95em;
  display: none;
}

.uvq06-sg .ty input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: 400 2em/1.2 "Snell Roundhand","Segoe Script","Brush Script MT","Lucida Handwriting",cursive;
  color: var(--c1);
  caret-color: var(--c1);
}

.uvq06-sg .ty input::placeholder {
  color: rgba(0,0,0,.25);
}

.uvq06-sg.kb .ty {
  display: block;
}

.uvq06-sg.kb canvas,.uvq06-sg.kb .hn {
  display: none;
}

.uvq06-sg.kb .pd {
  cursor: text;
}

.uvq06-sg .rw {
  display: flex;
  align-items: center;
  gap: .4em;
  margin-top: .7em;
}

.uvq06-sg .rw button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .5em .85em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-sg .rw button:hover {
  background: color-mix(in srgb,var(--fg) 11%,transparent);
}

.uvq06-sg .rw button:active {
  transform: scale(.94);
}

.uvq06-sg .rw button:focus-visible {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg .md[aria-pressed="true"] {
  color: #fff;
  background: var(--c1);
}

.uvq06-sg .ok {
  margin-left: auto;
  font-size: .78em;
  font-weight: 700;
  color: #16a34a;
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-sg,.uvq06-sg *,.uvq06-sg *::before,.uvq06-sg *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const cv=el.querySelector("canvas"),cx=cv.getContext("2d"),md=el.querySelector(".md"),cl=el.querySelector(".cl"),ok=el.querySelector(".ok"),ty=el.querySelector(".ty input");let dr=false,pts=[],lw=2,k=2,t=0;
const r0=window.devicePixelRatio||1;cv.width=Math.max(1,cv.offsetWidth*r0*2);cv.height=Math.max(1,cv.offsetHeight*r0*2);k=cv.width/Math.max(1,cv.offsetWidth);
const ink=()=>getComputedStyle(el).getPropertyValue("--c1").trim()||"#1e3a8a";
const done=v=>{el.classList.toggle("has",v);ok.textContent=v?"✓ Signed":""};
const seg=p=>{const a=pts[pts.length-1],z=pts[pts.length-2]||a;const d=Math.hypot(p.x-a.x,p.y-a.y),v=d/Math.max(1,p.t-a.t)/k;lw=lw*.6+Math.max(.9,Math.min(3.2,3.4-v*1.2))*k*.4;cx.lineWidth=lw;cx.beginPath();cx.moveTo((a.x+z.x)/2,(a.y+z.y)/2);cx.quadraticCurveTo(a.x,a.y,(a.x+p.x)/2,(a.y+p.y)/2);cx.stroke();pts.push(p)};
const start=p=>{pts=[p];cx.strokeStyle=cx.fillStyle=ink();cx.lineCap=cx.lineJoin="round";lw=2.2*k;cx.beginPath();cx.arc(p.x,p.y,lw/2,0,7);cx.fill()};
const pt=e=>{const r=cv.getBoundingClientRect();return{x:(e.clientX-r.left)*cv.width/r.width,y:(e.clientY-r.top)*cv.height/r.height,t:e.timeStamp}};
cv.addEventListener("pointerdown",e=>{dr=true;cv.setPointerCapture(e.pointerId);start(pt(e));e.preventDefault()});
cv.addEventListener("pointermove",e=>{if(dr){seg(pt(e));done(true)}});
const up=()=>{dr=false};cv.addEventListener("pointerup",up);cv.addEventListener("pointercancel",up);
cl.addEventListener("click",()=>{cv.classList.add("fade");clearTimeout(t);t=setTimeout(()=>{cx.clearRect(0,0,cv.width,cv.height);cv.classList.remove("fade")},300);ty.value="";done(false)});
md.addEventListener("click",()=>{const on=md.getAttribute("aria-pressed")!=="true";md.setAttribute("aria-pressed",String(on));el.classList.toggle("kb",on);if(on)ty.focus()});
ty.addEventListener("input",()=>done(!!ty.value.trim()));
const W=cv.width,Hh=cv.height;start({x:W*.16,y:Hh*.55,t:0});for(let s=1;s<=160;s++){const q=s/160;seg({x:W*(.16+.6*q+.035*Math.sin(q*30)),y:Hh*(.56-.17*Math.sin(q*15)*Math.exp(-q*1.3)-.06*Math.cos(q*30)),t:s*9})}done(true);
return()=>clearTimeout(t)
}

export default function InSignature() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#1e3a8a",
          "--c2": "#b45309",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-sg"><div className="pd"><canvas role="img" aria-label="Signature area"></canvas><span className="hn" aria-hidden="true">Sign here</span><span className="x" aria-hidden="true">×</span><span className="ln" aria-hidden="true"></span><label className="ty"><span className="sr">Type your name</span><input placeholder="Type your name" autoComplete="name" /></label></div><div className="rw"><button type="button" className="md" aria-pressed="false">Use keyboard</button><button type="button" className="cl">Clear</button><span className="ok" aria-live="polite"></span></div></div>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Handwritten signature pad” block (Inputs) from AIMRAN Library to my project.

## What it is
A paper box to sign with a finger or mouse, with a stroke that thins with speed and an option to type your name.

## Chosen settings
- Main color: #1e3a8a
- Secondary color: #b45309
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Firma aquí"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uvq06-sg {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  width: 19em;
}

.uvq06-sg .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-sg .pd {
  position: relative;
  height: 8em;
  border-radius: .9em;
  overflow: hidden;
  background: #fbfaf6;
  background-image: radial-gradient(rgba(0,0,0,.04) 1px,transparent 1px);
  background-size: .5em .5em;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08),0 1em 1.8em -1em rgba(0,0,0,.45);
  cursor: crosshair;
}

.uvq06-sg .pd:has(input:focus-visible) {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg canvas.fade {
  opacity: 0;
}

.uvq06-sg .hn {
  position: absolute;
  left: 0;
  right: 0;
  top: 1.1em;
  font-size: .72em;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-align: center;
  color: rgba(0,0,0,.32);
  pointer-events: none;
  transition: opacity calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-sg.has .hn {
  opacity: 0;
}

.uvq06-sg .x {
  position: absolute;
  left: .75em;
  bottom: 1.45em;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1;
  color: var(--c2);
  pointer-events: none;
}

.uvq06-sg .ln {
  position: absolute;
  left: 2.2em;
  right: 1em;
  bottom: 1.85em;
  height: 1.5px;
  background: repeating-linear-gradient(90deg,rgba(0,0,0,.35) 0 .4em,transparent .4em .6em);
  pointer-events: none;
}

.uvq06-sg .ty {
  position: absolute;
  left: 2.3em;
  right: 1em;
  bottom: 1.95em;
  display: none;
}

.uvq06-sg .ty input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: none;
  font: 400 2em/1.2 "Snell Roundhand","Segoe Script","Brush Script MT","Lucida Handwriting",cursive;
  color: var(--c1);
  caret-color: var(--c1);
}

.uvq06-sg .ty input::placeholder {
  color: rgba(0,0,0,.25);
}

.uvq06-sg.kb .ty {
  display: block;
}

.uvq06-sg.kb canvas,.uvq06-sg.kb .hn {
  display: none;
}

.uvq06-sg.kb .pd {
  cursor: text;
}

.uvq06-sg .rw {
  display: flex;
  align-items: center;
  gap: .4em;
  margin-top: .7em;
}

.uvq06-sg .rw button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: .5em .85em;
  border-radius: 2em;
  font-size: .78em;
  font-weight: 650;
  background: color-mix(in srgb,var(--fg) 6%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-sg .rw button:hover {
  background: color-mix(in srgb,var(--fg) 11%,transparent);
}

.uvq06-sg .rw button:active {
  transform: scale(.94);
}

.uvq06-sg .rw button:focus-visible {
  outline: 2px solid color-mix(in srgb,var(--c1) 60%,var(--fg));
  outline-offset: 3px;
}

.uvq06-sg .md[aria-pressed="true"] {
  color: #fff;
  background: var(--c1);
}

.uvq06-sg .ok {
  margin-left: auto;
  font-size: .78em;
  font-weight: 700;
  color: #16a34a;
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-sg,.uvq06-sg *,.uvq06-sg *::before,.uvq06-sg *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const cv=el.querySelector("canvas"),cx=cv.getContext("2d"),md=el.querySelector(".md"),cl=el.querySelector(".cl"),ok=el.querySelector(".ok"),ty=el.querySelector(".ty input");let dr=false,pts=[],lw=2,k=2,t=0;
const r0=window.devicePixelRatio||1;cv.width=Math.max(1,cv.offsetWidth*r0*2);cv.height=Math.max(1,cv.offsetHeight*r0*2);k=cv.width/Math.max(1,cv.offsetWidth);
const ink=()=>getComputedStyle(el).getPropertyValue("--c1").trim()||"#1e3a8a";
const done=v=>{el.classList.toggle("has",v);ok.textContent=v?"✓ Signed":""};
const seg=p=>{const a=pts[pts.length-1],z=pts[pts.length-2]||a;const d=Math.hypot(p.x-a.x,p.y-a.y),v=d/Math.max(1,p.t-a.t)/k;lw=lw*.6+Math.max(.9,Math.min(3.2,3.4-v*1.2))*k*.4;cx.lineWidth=lw;cx.beginPath();cx.moveTo((a.x+z.x)/2,(a.y+z.y)/2);cx.quadraticCurveTo(a.x,a.y,(a.x+p.x)/2,(a.y+p.y)/2);cx.stroke();pts.push(p)};
const start=p=>{pts=[p];cx.strokeStyle=cx.fillStyle=ink();cx.lineCap=cx.lineJoin="round";lw=2.2*k;cx.beginPath();cx.arc(p.x,p.y,lw/2,0,7);cx.fill()};
const pt=e=>{const r=cv.getBoundingClientRect();return{x:(e.clientX-r.left)*cv.width/r.width,y:(e.clientY-r.top)*cv.height/r.height,t:e.timeStamp}};
cv.addEventListener("pointerdown",e=>{dr=true;cv.setPointerCapture(e.pointerId);start(pt(e));e.preventDefault()});
cv.addEventListener("pointermove",e=>{if(dr){seg(pt(e));done(true)}});
const up=()=>{dr=false};cv.addEventListener("pointerup",up);cv.addEventListener("pointercancel",up);
cl.addEventListener("click",()=>{cv.classList.add("fade");clearTimeout(t);t=setTimeout(()=>{cx.clearRect(0,0,cv.width,cv.height);cv.classList.remove("fade")},300);ty.value="";done(false)});
md.addEventListener("click",()=>{const on=md.getAttribute("aria-pressed")!=="true";md.setAttribute("aria-pressed",String(on));el.classList.toggle("kb",on);if(on)ty.focus()});
ty.addEventListener("input",()=>done(!!ty.value.trim()));
const W=cv.width,Hh=cv.height;start({x:W*.16,y:Hh*.55,t:0});for(let s=1;s<=160;s++){const q=s/160;seg({x:W*(.16+.6*q+.035*Math.sin(q*30)),y:Hh*(.56-.17*Math.sin(q*15)*Math.exp(-q*1.3)-.06*Math.cos(q*30)),t:s*9})}done(true);
return()=>clearTimeout(t)
}

export default function InSignature() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#1e3a8a",
          "--c2": "#b45309",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-sg"><div className="pd"><canvas role="img" aria-label="Signature area"></canvas><span className="hn" aria-hidden="true">Sign here</span><span className="x" aria-hidden="true">×</span><span className="ln" aria-hidden="true"></span><label className="ty"><span className="sr">Type your name</span><input placeholder="Type your name" autoComplete="name" /></label></div><div className="rw"><button type="button" className="md" aria-pressed="false">Use keyboard</button><button type="button" className="cl">Clear</button><span className="ok" aria-live="polite"></span></div></div>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
