Components

Signature pad

Sign on the screen. One brush pen with real pressure, a pencil baseline with its x, a clear button, and a typed-name fallback that is set in hand lettering. It carries the image in a hidden field, so it works in a plain form and can be required.

Install

terminal
npx shadcn@latest add @wobko/signature-pad

First time here? Add the registry to components.json first. How to install

Examples

Default

Sign with the mouse, a finger or a pen. The brush swells where you lean on it.

Type instead

The typed fallback: the name is hand lettering with a brush swash under it. Anyone who cannot draw gets a signature that is still an image.

Agreement form

A real form: the signature is a required field that posts as a data URL. Submit it empty to see the red baseline; sign and it goes through.

API reference

SignaturePad

The root: a Sketchpad with one pen, plus the value. The value is a data URL (svg by default, png on request) that is empty until the person has signed; the detail argument carries the strokes, so a signature can be stored as JSON and drawn again later.

PropTypeDefaultDescription
namestring-Form field name. A hidden input carries the data URL, so FormData and native submit just work.
value / defaultValue / onValueChangestring / (value: string, detail: { mode, strokes, text }) => void-The signature image as a data URL, or "". Controlled, the value is the truth: a value the pad did not produce (a saved signature loaded from a server, or "" from a reset) replaces whatever was drawn or typed and is shown as an image until the person signs again. A brush signature is about 40 KB as an svg data URL (22 KB of it is the embedded pen grain); store the strokes from `detail` if that matters.
requiredboolean-An empty pad blocks the form's submit with the native validation, focuses the canvas (the name field in type mode) and shows the message. A form reset clears the pad and calls onValueChange("").
invalid / messageboolean / string"Please sign in the box."A red baseline and a polite alert. Set automatically when a required form is submitted empty.
disabled / readOnlyboolean-Draw nothing. Read-only hides the buttons and shows the signature.
mode / defaultMode / onModeChange"draw" | "type""draw"Draw with a pointer or type the name.
typedFallbackbooleantrueOffer "Type instead": the name is hand-lettered as outlines (no font needed in the exported image). Also the way in for people who cannot draw.
penColor / penSketchColor / "brush" | "felt""ink-you" / "brush"The brush swells on down-strokes like a fountain pen; the felt keeps an even line.
format"svg" | "png""svg"png is rasterized in the browser through a canvas; where that is not possible the svg is kept.
width / heightnumber480 / 180Canvas units; the pad scales to its container.

Accessibility

  • The canvas is a named application ("Signature"); the same keyboard drawing as Sketchpad works: arrows move a cursor, Space puts the pen down and lifts it. Typing the name is the accessible alternative and is one button away.
  • Type mode replaces the canvas by an image named "Signature, typed: Ada Lovelace" and a text field labeled "Type your full name".
  • Required: a visually hidden text input holds the value so the browser's own validation and message apply; the failure also shows a role="alert" line and moves focus to the canvas (the name field in type mode).
  • The baseline turns red pencil when invalid, and the message says why (color is never the only cue).
  • Windows high contrast keeps the ink colors of the strokes; the sheet gets a real border.

Source

The files the CLI copies into your project.

Loading the source