UIComponentsReact
A surface the user signs with a mouse, a finger or a pen, with buttons to undo, redo and clear.
Built on the headless Signature Pad.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/signature-pad.jsonIt also adds utils, button. The app needs its setup first: Installation.
Usage
Put a SignaturePadControl inside SignaturePad, and a SignaturePadGuide and a SignaturePadStrokes inside the Control; add a SignaturePadUndo, a SignaturePadRedo and a SignaturePadClear after the Control for the buttons. Name the pad with a Field label, or aria-label on the Control. A pointer press draws a stroke, Ctrl+Z or Cmd+Z undoes, Ctrl+Shift+Z, Cmd+Shift+Z or Ctrl+Y redoes, and Delete or Backspace clears; the value, the form value, the exports (toSVG, toDataURL, toBlob), the labels and the announcements come from the headless Signature Pad.
Drawing is path-based, so offer a way to sign without it where the signature is not itself the point, for example a Tabs with a typed name in an Input beside the pad.
import {
SignaturePad,
SignaturePadClear,
SignaturePadControl,
SignaturePadGuide,
SignaturePadRedo,
SignaturePadStrokes,
SignaturePadUndo,
} from '@/components/ui/signature-pad'Examples
Default
A pad in a Field with a label, a description, a dashed baseline and Undo, Redo and Clear.
The Control has the Input's box: a border, a ring on keyboard focus and the destructive colours while the Field is invalid (WCAG 1.4.11, 2.4.7). The ink fills currentColor, so a text colour class on SignaturePadStrokes sets it, and the exports read the same colour. The Guide is a dashed muted line near the bottom of the Control; text inside it, such as an "×", sits on the line. Undo, Redo and Clear are the Button's ghost icon-xs, 24 by 24 CSS pixels (WCAG 2.5.8), dimmed while there is nothing to undo, redo or clear, and stay focusable then. This item takes Base UI's component ID as its slug and one name per Base UI part.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Signature Pad's API reference.