Signature pad
Draw, type or upload a signature; a PNG data URL out. A pen for the keyboard.
import { SignaturePad, signatureBlob, SIGNATURE_FONTS } from "@forgeron/ui";Draw with a pointer. From the keyboard: Space puts the pen down or lifts it, the arrows move it, Backspace undoes. Or use the Type or Upload tab.
import { SignaturePad, type SignatureValue } from "@forgeron/ui";
import { useState } from "react";
export default function Default() {
const [value, setValue] = useState<SignatureValue | null>(null);
return (
<div style={{ display: "grid", gap: 8, width: "100%", maxWidth: 560 }}>
<SignaturePad label="Your signature" value={value} onChange={setValue} />
<span style={{ color: "var(--ink-dim)", font: "400 11px/16px var(--font-mono)" }}>
{value ? `${value.method} · ${value.dataUrl.slice(0, 30)}…` : "Nothing signed yet"}
</span>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onChange | { dataUrl, method, text?, font? } | null | — | The signature: PNG data URL (SVG without a canvas). null when cleared. |
modes / mode / onModeChange | ("draw" | "type" | "upload")[] | all three | The ways to sign, in order. |
fonts | { id, label, family, italic? }[] | SIGNATURE_FONTS | The fonts of the Type tab (system fonts). |
ink | string | — | Colour of the exported image; dark by default, whatever the theme. |
maxUploadSize | number | 2 MB | Biggest image on the Upload tab, in bytes. |
label / defaultText / disabled | string; string; boolean | — | Name, first typed name, off. |
className | string | — | Extra classes. |