[ 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).

onChange-
(dataUrl: string | null) => void

Called after each stroke, undo or clear.

strokeColor-
string

Ink color. Defaults to the current text color.

strokeWidth2.5
number

Base line width; fast strokes get thinner.

height180
number | string

Canvas height.

placeholder'Sign here'
ReactNode

Shown while empty.

showControlstrue
boolean

Show Undo and Clear.

undoLabel / clearLabel'Undo' / 'Clear'
string

Button labels.

actions-
ReactNode

Right side of the toolbar.

disabledfalse
boolean

Stop 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.