Signature
Signature Capture
Type a name or draw. The typed name shows in a script face on a signing line, as it will look in the document.
- @signnative/ui
- MIT
- Client only · no backend
A typed or drawn signature is a picture, not an identity check.
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.
Type or draw
A prefilled name is reported once, on mount, so the person can adopt it as it is.
Your signature
Style
onChange: null
import { useState } from "react";
import { SignatureCapture, type CapturedSignature } from "@signnative/ui";
import "@signnative/ui/styles.css";
import "@signnative/ui/fonts.css";
export function Example() {
const [signature, setSignature] = useState<CapturedSignature | null>(null);
return (
<div>
<SignatureCapture defaultName="Ada Example" onChange={setSignature} />
<pre>{JSON.stringify(signature)}</pre>
</div>
);
}
Empty, with Undo and a smaller pad
Your signature
Style
import { SignatureCapture } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
return <SignatureCapture undo padHeight={140} />;
}
On a signing line
SignaturePreview shows what was captured; inside SignatureLine a drawing sits on the line exactly as drawn.
Your signature
Style
What the document field shows
import { useState } from "react";
import { SignatureCapture, SignatureLine, SignaturePreview, signatureLineFor, type CapturedSignature } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
const [signature, setSignature] = useState<CapturedSignature | null>(null);
return (
<div>
<SignatureCapture defaultName="Ada Example" onChange={setSignature} headingLevel={3} />
<SignatureLine {...signatureLineFor(180)}>
{signature ? <SignaturePreview signature={signature} onLine padHeight={180} /> : "Empty"}
</SignatureLine>
</div>
);
}
Inside a card with its own heading
Adopt your signature
The card has its own heading, so the capture has none.
Style
import { SignatureCapture } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
return (
<section>
<h3>Adopt your signature</h3>
<SignatureCapture title="" defaultName="Bo Sample" />
</section>
);
}
Other wording
Signature
Pick a style
import { SignatureCapture } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
return (
<SignatureCapture
title="Signature"
defaultName="Cy Demo"
labels={{
type: "Type it",
draw: "Draw it",
name: "Name as it should appear",
style: "Pick a style",
pad: { placeholder: "Draw here", clear: "Start over" },
}}
/>
);
}
Phone width
Your signature
Style
import { SignatureCapture } from "@signnative/ui";
import "@signnative/ui/styles.css";
export function Example() {
return <SignatureCapture defaultName="Ada Example" padHeight={150} undo />;
}
Installation
npx shadcn@latest add …
Not published yet
API
className and children are left out: every component that takes them passes them on.
SignatureCapture
| Name | Type | Default | Description |
|---|---|---|---|
| onChange | (s: CapturedSignature | null) => void | { kind: "typed", text, font }, { kind: "drawn", png }, or null while there is none. | |
| defaultName | string | "" | Prefills the typed name. A prefilled name is reported once, on mount. |
| defaultValue | CapturedSignature | null | null | A signature captured earlier, read on mount. Change key to reset. |
| title | string | "Your signature" | Heading. Pass "" when a dialog or card around it has its own. |
| headingLevel | 2 | 3 | 2 | Heading level in the page outline. |
| padHeight | number | 180 | Height of the drawing area. |
| undo | boolean | false | Show Undo on the drawing pad. |
| labels | Partial<SignatureCaptureLabels> | English | Every text, for translation. labels.pad holds the pad's. |
SignaturePreview
| Name | Type | Default | Description |
|---|---|---|---|
| signature | CapturedSignature | What to show. | |
| onLine | boolean | false | Inside SignatureLine: a drawing sits on the line exactly as drawn. |
| padHeight | number | 180 | With onLine: the height of the pad it was drawn on, so it shows 1:1. |
SignatureLine
| Name | Type | Default | Description |
|---|---|---|---|
| height | number | 120 | Height in CSS pixels. |
| below | number | 24 | Space under the line. signatureLineFor(padHeight) gives a pad's geometry. |
Accessibility
- Typing is the keyboard and screen reader way to sign. Tab reaches the Type or Draw switch, the name input and the chosen font.
- The Type or Draw switch and the font choices are radio groups: arrow keys move inside them.
- The empty pad's name tells a screen reader user to choose Type.