Xzero UI
Pro library

Signature pad

Smooth ink that thins with speed, with undo, replay, and PNG or SVG export.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/signature-pad
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/signature-pad

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { useState } from "react";
import { SignaturePad, signatureToSvg } from "@/components/xzero/signature-pad/signature-pad";
import type { InkStroke } from "@/components/xzero/signature-pad/signature-pad";

export function SignContract() {
  const [strokes, setStrokes] = useState<InkStroke[]>([]);

  return (
    <form onSubmit={event => { event.preventDefault(); submit(signatureToSvg(strokes)); }}>
      <SignaturePad signer="Ada Lovelace" fileName="ada-signature" onChange={setStrokes} />
      <button type="submit" disabled={!strokes.length}>Sign</button>
    </form>
  );
}

API reference

SignaturePad

A signature field with pressure-sensitive ink, undo and redo, a wipe to clear, replay, and PNG or SVG export.

PropTypeDefaultDescription
signerstring–Printed under the baseline, such as the signer's name.
hintstring"Sign here"Resting hint on the baseline before the first stroke.
defaultColor"black" | "blue" | "violet""black"Starting ink color.
defaultWidth"fine" | "medium" | "bold""medium"Starting nib width.
onChange(strokes: InkStroke[]) => void–Receives the strokes after every change, including undo, redo, and clear.
fileNamestring"signature"File name for exports, without extension.
labelstring"Signature pad"Accessible name of the drawing surface.
classNamestring–Extra class on the root.

signatureToSvg

Returns a standalone SVG string of the strokes, cropped to the ink with print ink colors. Empty string for no strokes.

PropTypeDefaultDescription
strokes (required)InkStroke[]–Strokes as received from onChange.

signatureToPng

Resolves to a transparent PNG Blob cropped to the ink. Rejects when there are no strokes.

PropTypeDefaultDescription
strokes (required)InkStroke[]–Strokes as received from onChange.
scalenumber3Multiple of the 600 by 260 pad resolution.

Keyboard interactions

KeysAction
Mod + ZUndoes the last change while the pad is focused.
Shift + Mod + Z / Mod + YRedoes.
Delete / BackspaceClears the signature with the wipe; undo brings it back.
EscapeStops a replay in progress.
Arrow keysMove between ink colors or nib widths inside each radio group.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in editors

Guidance for AI tools

Signature pad: Smooth ink that thins with speed, with undo, replay, and PNG or SVG export. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components