How it works
Strokes are stored as points with a width rather than as pixels. Coalesced pointer events give dense samples; each segment is a quadratic curve from midpoint to midpoint, and the width follows speed through a low-pass filter so it never steps. Because the data is kept, undo is exact, the canvas redraws sharply at any pixel ratio, the signature rescales when the pad changes width, and the ink colour follows the theme.
Use it for
- Accepting a proposal, a delivery or a consent form where a drawn signature is expected.
- Collecting a quick sketch or initials on a tablet or phone.
Look elsewhere when
- A legally binding signature flow on its own: pair it with identity and audit steps on the server.
- As the only way to confirm: always offer a typed-name or checkbox alternative for people who cannot draw.
Usage
import { useRef, useState } from 'react'
import { SignaturePad } from './SignaturePad.jsx'
export function SignStep() {
const pad = useRef(null)
const [empty, setEmpty] = useState(true)
return (
<>
<SignaturePad ref={pad} height={180} onChange={(s) => setEmpty(s.isEmpty)} />
<button disabled={empty} onClick={() => upload(pad.current.toSVG())}>
Accept and sign
</button>
</>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
onChange | ({ isEmpty, strokes }) => void | — | Called after each stroke, undo or clear. |
defaultStrokes | [x, y][][] | — | Strokes to start with, as points normalised to the pad (0 to 1), such as a saved signature. |
height | number | 180 | Pad height in px; the width fills the container and the drawing rescales with it. |
minWidth | number | 0.9 | Thinnest line, at fast strokes. |
maxWidth | number | 3.2 | Thickest line, at slow strokes; pen pressure can add up to 30%. |
color | string | — | Ink colour. By default the ink follows --ds-sign-ink, then --ds-text, so it flips with the theme. |
baseline | boolean | true | Draws the dashed line and × mark. |
disabled | boolean | false | Locks the pad, for example after submitting. |
labels | object | — | Replaces built-in text: pad, hint, undo, clear, empty, signed, strokes(n). |
ref | { undo, clear, isEmpty, toDataURL, toSVG } | — | Imperative handle: toDataURL(type) returns an image, toSVG() a resolution-free path drawing. |
Accessibility
- The canvas is a focusable role="img" whose label states whether it is signed and how many strokes it has.
- Keyboard: Ctrl / Cmd+Z undoes the last stroke, Delete or Backspace clears. Drawing itself needs a pointer, so offer a typed alternative next to it.
- Undo and Clear are real buttons, 32px high, hidden only while the pad is empty.
- touch-action: none stops the page from scrolling while signing. Reduced motion removes the hint and tool fades.
Motion
Ink appears under the pen with no delay. The hint fades and rises 4px in 240ms when the first stroke starts; the tools fade in over 200ms once there is something to undo.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
SignaturePad.jsxsignature-pad.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.







