Signature Pad
Capture handwritten signatures with mouse or touch via signature_pad. Imperative clear, undo, and PNG export through a ref.
Gallery
Undo, clear, and preview a PNG. ref exposes clear / undo / toDataURL.
Loading…
Installation
CLI
Also needs
npm i signature_padUsage
signature-pad.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| penColor | string | "#0a0a0a" | Ink color. |
| strokeWidth | number | 2 | Base stroke width (maps to pressure min/max). |
| guide | string | - | Caption + dashed baseline under the pad. |
| disabled | boolean | false | Blocks drawing (read-only stored signatures). |
| invalid | boolean | false | Destructive border for empty-required states. |
| onEmptyChange | (empty: boolean) => void | - | Fires when the pad becomes empty or has ink. |
| onBegin / onEnd | () => void | - | Stroke lifecycle callbacks. |
| className | string | - | Merged onto the pad stage (default `h-48`). |
Handle (ref)
| Prop | Type | Default | Description |
|---|---|---|---|
| clear() | void | - | Erase the pad. |
| undo() | void | - | Remove the last stroke. |
| isEmpty() | boolean | - | Whether any ink is present. |
| toDataURL() | string | - | PNG (or other MIME) data URL. |
| toBlob() | Promise<Blob · null> | - | Blob for upload / download. |
| toData() / fromData() | PointGroup[] | - | Serialize / restore stroke data. |
Related
- Dialog, modal signature capture
- Field, label required signature rows
- Image Cropper, crop photos before upload