Signature Pad
A component that allows users to draw a signature using a signature pad.
Anatomy
To set up the signature pad correctly, you'll need to understand its anatomy and how we name its parts.
Each part includes a
data-partattribute to help identify them in the DOM.
Examples
Learn how to use the Signature Pad component in your project. Let's take a look at the most basic example:
Example not foundExample not foundExample not foundExample not foundImage Preview
After the user draws a signature, you can display a preview of the signature as an image. This is useful when you want to show the user a preview of the signature before saving it.
Example not foundExample not foundExample not foundExample not foundUsing the Field Component
The Field component helps manage form-related state and accessibility attributes of a signature pad. It includes
handling ARIA labels, helper text, and error text to ensure proper accessibility.
Example not foundExample not foundExample not foundExample not foundUsing the Root Provider
The RootProvider component provides a context for the signature-pad. It accepts the value of the useSignature-pad
hook. You can leverage it to access the component state and methods from outside the signature-pad.
Example not foundExample not foundExample not foundExample not foundIf you're using the
RootProvidercomponent, you don't need to use theRootcomponent.
API Reference
Props
Root
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. 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 | Partial<{ root: string; control: string; hiddenInput: string; label: string }>The 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. | |
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. | |
required | booleanWhether the signature pad is required. | |
translations | IntlTranslationsThe translations of the signature pad. Useful for internationalization. |
| Data Attribute | Value |
|---|---|
[data-scope] | signature-pad |
[data-part] | root |
[data-disabled] | Present when disabled |
ClearTrigger
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Control
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | signature-pad |
[data-part] | control |
[data-disabled] | Present when disabled |
Guide
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | signature-pad |
[data-part] | guide |
[data-disabled] | Present when disabled |
HiddenInput
| Prop | Default | Type |
|---|---|---|
value | string | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Label
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
| Data Attribute | Value |
|---|---|
[data-scope] | signature-pad |
[data-part] | label |
[data-disabled] | Present when disabled |
[data-required] | Present when required |
RootProvider
| Prop | Default | Type |
|---|---|---|
value | UseSignaturePadReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Segment
| Prop | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. |
Context
These are the properties available when using UsignatureUpad.Context, useUsignatureUpadContext hook or useUsignatureUpad hook.
API
| Property | Type |
|---|---|
empty | booleanWhether the signature pad is empty. |
drawing | booleanWhether the user is currently drawing. |
currentPath | stringThe 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. |