Web · Components
SignaturePad
Signature pad: sign with a finger, pen or mouse.
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Import
Signature pad: sign with a finger, pen or mouse. Contract approval, delivery confirmation, form signature.
- Strokes are smoothed; they thicken and thin by speed and pen pressure.
- Sharp on high-resolution screens; when the area resizes, the signature is redrawn keeping its proportions (strokes are stored as vectors).
- Undo / redo / clear buttons; Ctrl+Z and Ctrl+Shift+Z work too.
- Mobile: the page doesn't scroll while drawing; multi-finger touch is ignored.
- Form: with
namethe signature is submitted as PNG/SVG/JSON;requiredjoins browser validation. For labeled use seeSignatureField. toDataURL(),toSVG(),toBlob()are available viaref.
Examples
signatureToSvg
functionConverts a signature to an SVG string (to save as a file or send to the server). Strokes are written as paths at pad size.
Examples
isSignatureEmpty
functionIs the signature empty (no strokes)?
SignaturePoint
interfaceA point of a signature. Positions are fractions of the pad size (0–1).
| Name | Type | Description |
|---|---|---|
x | number | Horizontal position (0–1, relative to the pad width). |
y | number | Vertical position (0–1, relative to the pad height). |
w | number | Stroke width at this point (relative to the pad width). |
SignatureStroke
typeA single stroke drawn without lifting the pen.
SignatureValue
typeThe whole signature: strokes in order.
SignaturePadHandle
interfaceFunctions of SignaturePad accessed with ref.
| Name | Type | Description |
|---|---|---|
toDataURL | (type?: "image/png" | "image/jpeg" | "image/webp", quality?: number) => string | Converts the signature to an image URL (image/png by default). "" if empty. |
toSVG | () => string | Converts the signature to an SVG string. |
toBlob | (type?: "image/png" | "image/jpeg" | "image/webp") => Promise<Blob | null> | Converts the signature to a file (for uploading to a server). null if empty. |
clear | () => void | Clears the signature. |
undo | () => void | Undoes the last stroke. |
redo | () => void | Redoes what was undone. |
isEmpty | () => boolean | Whether the signature is empty. |
SignaturePadClassNames
interfaceClasses that can be passed to the inner parts of SignaturePad.
| Name | Type | Description |
|---|---|---|
canvas? | string | Drawing area (<canvas>). |
hint? | string | "Sign here" hint and signature line. |
toolbar? | string | Undo / redo / clear buttons. |
SignatureFormat
typeFormat of the value submitted with the form.
SignaturePadProps
interfaceProps of the SignaturePad component.
Extends: Omit<ComponentProps<"div">, "defaultValue" | "onChange" | "ref" | "color">
| Name | Type | Default | Description |
|---|---|---|---|
value? | SignatureValue | Signature (strokes) in controlled use. See SignatureValue. | |
defaultValue? | SignatureValue | Initial signature in uncontrolled use. | |
onValueChange? | (value: SignatureValue) => void | Called when each stroke ends, on clear and on undo. | |
color? | string | the theme's text color | Ink color (CSS). |
minWidth? | number | 0.8 | Thinnest line (px). |
maxWidth? | number | 2.8 | Thickest line (px). |
placeholder? | ReactNode | {@link UIProvider} text | Hint shown in the middle while empty: text or content. null hides it. |
toolbar? | boolean | true | Undo, redo, clear buttons. |
readOnly? | boolean | Display only; can't be drawn on. | |
disabled? | boolean | Disabled. | |
name? | string | Form field name; the signature is submitted according to format. | |
format? | SignatureFormat | "png" | Value submitted with the form: a png image URL (data:image/png…), an svg string or the strokes' json (to redraw later). |
required? | boolean | The form can't be submitted without a signature. | |
form? | string | Id of the form it belongs to. | |
aria-label? | string | {@link UIProvider} text ("İmza alanı") | Screen reader name. |
aria-labelledby? | string | Id of the element naming the drawing area (e.g. the field label). | |
ref? | Ref<SignaturePadHandle> | Access: toDataURL, toSVG, clear… See SignaturePadHandle. | |
classNames? | SignaturePadClassNames | Classes added to the inner parts. |