[ Forms ]
SignaturePad
A draw-to-sign canvas with natural, speed-sensitive strokes, Undo and Clear, and PNG output. Ink follows the text color, so it works in light and dark mode.
1 examplesDark modeAccessible
Import#
import { SignaturePad } from 'reusify-ui';When to use#
- Contracts, delivery confirmations, consent forms and approvals.
Examples#
Basic#
Draw with mouse, pen or finger.
const pad = useRef(null);
const [signature, setSignature] = useState(null);
<SignaturePad
ref={pad}
onChange={setSignature} // PNG data URL, or null when empty
actions={<Button variant="text" size="sm" onClick={save}>Save</Button>}
/>
// pad.current.clear() · undo() · isEmpty() · toDataURL('image/png')Used in designs#
SignaturePad in real layouts: this design uses it. Open one to try it and copy the code.
API reference#
<SignaturePad />
The ref exposes clear(), undo(), isEmpty() and toDataURL(type).
| Prop | Type | Default | Description |
|---|---|---|---|
onChange | (dataUrl: string | null) => void | - | Called after each stroke, undo or clear. |
strokeColor | string | - | Ink color. Defaults to the current text color. |
strokeWidth | number | 2.5 | Base line width; fast strokes get thinner. |
height | number | string | 180 | Canvas height. |
placeholder | ReactNode | 'Sign here' | Shown while empty. |
showControls | boolean | true | Show Undo and Clear. |
undoLabel / clearLabel | string | 'Undo' / 'Clear' | Button labels. |
actions | ReactNode | - | Right side of the toolbar. |
disabled | boolean | false | Stop drawing. |
onChange-(dataUrl: string | null) => voidCalled after each stroke, undo or clear.
strokeColor-stringInk color. Defaults to the current text color.
strokeWidth2.5numberBase line width; fast strokes get thinner.
height180number | stringCanvas height.
placeholder'Sign here'ReactNodeShown while empty.
showControlstruebooleanShow Undo and Clear.
undoLabel / clearLabel'Undo' / 'Clear'stringButton labels.
actions-ReactNodeRight side of the toolbar.
disabledfalsebooleanStop drawing.
Accessibility#
- The canvas is role="img" and its label says whether it is empty or signed.
- Drawing needs a pointer. For keyboard-only users, offer an alternative such as typing their name.