Signature Pad

A component that allows users to draw a signature using a signature pad.

Loading...

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.

AttributeDefaultType
asChild
boolean

Use 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
boolean

Whether the signature pad is disabled.

drawing'{ size: 2, simulatePressure: true }'
DrawingOptions

The drawing options.

ids
ElementIds

The ids of the signature pad elements. Useful for composition.

name
string

The name of the signature pad. Useful for form submission.

onDraw
(details: DrawDetails) => void

Callback 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) => void

Callback when the signature pad is done drawing.

paths
string[]

The controlled paths of the signature pad.

readOnly
boolean

Whether 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
boolean

Whether the signature pad is required.

translations
IntlTranslations

The translations of the signature pad. Useful for internationalization.

AttributeDescription
[data-signature-pad-root]<uid>
[data-disabled]Present when disabled

ClearTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[data-signature-pad-control]<uid>
[data-disabled]Present when disabled

Guide

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[data-signature-pad-guide]<uid>
[data-disabled]Present when disabled

HiddenInput

Defines the <input> element.

AttributeDefaultType
value
string

asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[data-signature-pad-label]<uid>
[data-disabled]Present when disabled
[data-required]Present when required

RootProvider

Defines the <div> element.

AttributeDefaultType
value
UseSignaturePadReturn

asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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

PropertyType
empty
boolean

Whether the signature pad is empty.

drawing
boolean

Whether the user is currently drawing.

currentPath
string | null

The 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
VoidFunction

Clears the signature pad.

getRootState
() => RootState

Returns the state of the root