Signature Pad
A component that allows users to draw a signature using a signature pad.
Anatomy
<SignaturePad.Root>
<SignaturePad.Label />
<SignaturePad.Control>
<SignaturePad.Segment />
<SignaturePad.ClearTrigger />
<SignaturePad.Guide />
</SignaturePad.Control>
</SignaturePad.Root>
Examples
Controlled
Control the paths with paths and onDraw (React/Solid), v-model:paths (Vue), bind:paths (Svelte), or the paths
attribute as JSON with the draw event (Web). The example tracks the path count and clears the signature from outside.
Image Preview
Show the drawn signature as an image preview before saving it.
Field
Field wires up the label, helper text, error text and ARIA attributes.
Root Provider
Use RootProvider with the useSignaturePad hook to access the state and methods from outside the component.
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
defaultPaths | string[]The default paths of the signature pad. Use when you don't need to control the paths of the signature pad. | |
disabled | booleanWhether the signature pad is disabled. | |
drawing | '{ size: 2, simulatePressure: true }' | DrawingOptionsThe drawing options. |
ids | ElementIdsThe ids of the signature pad elements. Useful for composition. | |
name | stringThe name of the signature pad. Useful for form submission. | |
onDraw | (details: DrawDetails) => voidCallback when the signature pad is drawing or the committed paths change. `paths` contains only committed strokes; use `currentPath` for the in-progress stroke. | |
onDrawEnd | (details: DrawEndDetails) => voidCallback when the signature pad is done drawing. | |
paths | string[]The controlled paths of the signature pad. | |
readOnly | booleanWhether the signature pad is read-only. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<SignaturePadRootState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
required | booleanWhether the signature pad is required. | |
translations | IntlTranslationsThe translations of the signature pad. Useful for internationalization. |
| Attribute | Description |
|---|---|
[data-signature-pad-root] | <uid> |
[data-disabled] | Present when disabled |
ClearTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Control
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-signature-pad-control] | <uid> |
[data-disabled] | Present when disabled |
Guide
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-signature-pad-guide] | <uid> |
[data-disabled] | Present when disabled |
HiddenInput
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
value | string | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Label
Defines the <label> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-signature-pad-label] | <uid> |
[data-disabled] | Present when disabled |
[data-required] | Present when required |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseSignaturePadReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | type ONLY_FOR_FORMAT =
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<SignaturePadRootProviderState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Segment
Defines the <svg> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Context
API
| Property | Type |
|---|---|
empty | booleanWhether the signature pad is empty. |
drawing | booleanWhether the user is currently drawing. |
currentPath | string | nullThe current path being drawn. |
paths | string[]The paths of the signature pad. |
getDataUrl | (type: DataUrlType, quality?: number) => Promise<string>Returns the data URL of the signature pad. |
clear | VoidFunctionClears the signature pad. |
getRootState | () => RootStateReturns the state of the root |