Skip to content
Ballpoint

Signature Pad

A line to sign on with a mouse, a finger or a stylus, inked like a ballpoint. Submits with its form; exports SVG or PNG.

Only in Ballpoint

Installation

pnpm dlx shadcn@latest add @ballpoint/signature-pad

Usage

tsx
import { SignaturePad } from "@/components/ui/signature-pad"

<form action={sign}>
  <SignaturePad name="signature" required />
  <Button type="submit">Sign</Button>
</form>

Examples

Undo, clear, export

The ref hands back undo(), clear(), and exports; here a PNG, trimmed to the ink.

In a form

A required signature beside a name and a checkbox, read back from the form data.

API reference

name
string

The form field the signature is submitted under, as a data URL.

required
boolean

The form won't submit unsigned; the pad turns red and the browser says why.

valueFormat
default "svg"
"svg" | "png"

What the form receives.

onChange
(value: string) => void

After every stroke, and on clear, with the form value (empty when cleared).

ref
Ref<SignaturePadHandle>

clear(), undo(), isEmpty(), strokes(), toSVG(options), toDataURL(type, options). Exports are trimmed to the ink, in blue ballpoint unless you pass a color.

label
default "Signature"
string

Names the pad for screen readers.

placeholder
default "Sign here"
string

Written above the line until the first stroke.

disabled
boolean

Stops the pen.

seed
string | number

Pins the drawing of the box and the line.

Pen settings

The drawing also takes draw, roughness, weight and speed, as props or from the nearest InkProvider. What each one does.