Components / Signature Pad

Signature

Signature Pad

Draw a signature with a mouse, a pen or a finger. Gives you a PNG with a transparent background.

  • @signnative/ui
  • MIT
  • Client only · no backend

A signature image is a picture, not an identity check. What makes a signature mean something is how the signer was identified and what the evidence records.

Theme
The CSS variables this sets
:root {
  --signing-accent: #3157e8;
  --sig-accent: #3157e8;
  --sig-accent-soft: color-mix(in oklab, #3157e8 14%, white);
  --sig-radius: 8px;
  --radius-control: 8px;
  --radius-panel: 12px;
  --font-sans: var(--font-inter), ui-sans-serif, system-ui, sans-serif;
}

In the signer page kit, set the accent with accentProps(accent) on the element around the surface; it sets data-signing-accent and --signing-accent. The secure elements take the same values as a checked appearance object instead.

Default

Draw with a mouse, a pen or a finger. onChange gets a base64 PNG after each stroke, or null after Clear.

onChange: null (empty)

Controlled, with Undo and the image

Pass value to control it: null from outside empties the pad. signatureDataUrl turns the PNG into an image source.

The image shows here

Ink, line width and height

Any CSS colour. Keep the default ink for documents: the PDF uses the same.

Other wording

Every text the pad shows or announces can be replaced, for translation or your own tone.

Theming with CSS variables

The paper stays light, but its colours are variables. Set them on any element around the pad.

Phone width

The width follows the container. A touch draws and never scrolls the page.

Installation

npx shadcn@latest add <site>/r/signature-pad.json

Not published yet

Not published yet. The registry item exists in packages/ui/registry.json but is not served yet.

API

className and children are left out: every component that takes them passes them on.

SignaturePad

NameTypeDefaultDescription
onChange(png: string | null) => voidAfter each stroke, Undo and Clear. A base64 PNG without the data: prefix, or null when empty.
valuestring | nullControlled value. A new value the pad did not report is drawn; null empties the pad.
defaultValuestring | nullnullUncontrolled start value, read once on mount.
heightnumber180Height of the drawing area in CSS pixels. The width follows the container.
lineWidthnumber2.5Stroke width in CSS pixels.
inkstring"#0b1f4d"Stroke colour, any CSS colour.
undobooleanfalseShow an Undo button that removes the last stroke.
labelsPartial<SignaturePadLabels>EnglishEvery text the pad shows or announces, for translation.

Accessibility

  • The drawing area is an image whose name says whether it is empty. A status line announces “Signature drawn.” and “Signature cleared.”
  • A canvas cannot be drawn on with a keyboard. Clear and Undo can be reached and pressed, but that is not a way to sign: put a typed name next to the pad, or use Signature Capture.
  • Clear and Undo are buttons with text, at least 44 px tall, with a visible focus outline.
  • A touch on the pad draws and never scrolls the page (touch-action: none). A second finger is ignored while one draws.