Skip to content
Haze UI

Signature pad

Draw and export a signature with stroke undo and redo, alongside an always available typed name field.

pnpm dlx shadcn@latest add @haze/signature-pad
Open preview in a new tab
Livesmall script

When to use

  • A delivery or acknowledgment form benefits from an optional drawn mark plus a typed signer name.
  • A local signature drawing needs PNG export and a form value without an external drawing dependency.

When not to use

  • Use input when a typed name is sufficient for the acknowledgment.
  • Use a dedicated signing service when identity verification, audit trails or legal signing workflows are required.

Installation

Add the Haze registry to components.json once, then install Signature pad with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/signature-pad
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Unique caller supplied prefix for the control and its associated content.
namestringidName submitted by the native form control.
drawingNamestringname-drawingName of the hidden PNG data URL field.
labelstringYour signatureLegend for the drawing and name controls.
signerstringEmptyInitial typed full name.
requiredbooleanfalseRequires the typed name; drawing remains optional.
disabledbooleanfalsePrevents user changes through the native disabled state.
fileNamestringsignatureBase file name used for PNG download.
classstring–Additional classes on this component's outer wrapper.
[key: string]unknown–Other attributes applied to the typed name input.

Keyboard interactions

Ctrl/⌘ Z on the pad
Undo the latest stroke; add Shift to redo.
Escape on the pad
Cancel an in progress stroke.
Tab
Reach the drawing tools and the equivalent typed name field.

Accessibility

  • The typed full name is an equivalent always available input; a signature never requires the ability to draw with a pointer.
  • Undo, redo, clear and PNG export are labelled buttons, and the drawing's accessible name includes the stroke count.
  • Only the canvas disables touch scrolling; pen, mouse and primary touch strokes use pointer capture and a canceled stroke is discarded.
  • Clearing the drawing preserves the typed name, while a form reset clears the drawing and restores native field defaults.
  • The PNG field and haze:signature-change event carry local drawing data; the component performs no remote signing or upload.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Signature pad" with `npx shadcn@latest add @haze/signature-pad`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import SignaturePad from "@/components/haze/ui/signature-pad.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/signature-pad.md

  • Customize with real content

    Adapt the Haze signature-pad ui for our product. Replace the demo values of these props with our real content: id, name, drawingName, label, signer, required, disabled, fileName, class, [key: string]. Keep the layout, the heading level rules and these accessibility details: The typed full name is an equivalent always available input; a signature never requires the ability to draw with a pointer. Undo, redo, clear and PNG export are labelled buttons, and the drawing's accessible name includes the stroke count. Only the canvas disables touch scrolling; pen, mouse and primary touch strokes use pointer capture and a canceled stroke is discarded. Clearing the drawing preserves the typed name, while a form reset clears the drawing and restores native field defaults. The PNG field and haze:signature-change event carry local drawing data; the component performs no remote signing or upload. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using signature-pad, check it fits: use it when a delivery or acknowledgment form benefits from an optional drawn mark plus a typed signer name.; a local signature drawing needs png export and a form value without an external drawing dependency.. Avoid it when use input when a typed name is sufficient for the acknowledgment.; use a dedicated signing service when identity verification, audit trails or legal signing workflows are required.. Alternatives: @haze/input, @haze/textarea, @haze/file-upload.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog