Ark Logo
GitHub
Components
Signature pad

Signature Pad

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

Signature

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-part attribute 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:

import { SignaturePad } from '@ark-ui/react'

export const Basic = () => (
  <SignaturePad.Root>
    <SignaturePad.Label>Sign below</SignaturePad.Label>
    <SignaturePad.Control>
      <SignaturePad.Segment />
      <SignaturePad.ClearTrigger>Clear</SignaturePad.ClearTrigger>
      <SignaturePad.Guide />
    </SignaturePad.Control>
  </SignaturePad.Root>
)

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

import { useState } from 'react'
import { SignaturePad } from '@ark-ui/react'

export const ImagePreview = () => {
  const [imageUrl, setImageUrl] = useState('')

  return (
    <>
      <SignaturePad.Root
        onDrawEnd={(details) => details.getDataUrl('image/png').then((url) => setImageUrl(url))}
      >
        <SignaturePad.Label>Sign below</SignaturePad.Label>
        <SignaturePad.Control>
          <SignaturePad.Segment fill="orange" />
          <SignaturePad.ClearTrigger>Clear</SignaturePad.ClearTrigger>
          <SignaturePad.Guide />
        </SignaturePad.Control>
      </SignaturePad.Root>

      {imageUrl && <img src={imageUrl} alt="Signature" />}
    </>
  )
}

API Reference

Root

PropDefaultType
asChild
boolean

Render as a different element type.

disabled
boolean

Whether the signature pad is disabled.

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

The drawing options.

id
string

The unique identifier of the machine.

ids
Partial<{ root: string; control: string; hiddenInput: string }>

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.

onDrawEnd
(details: DrawEndDetails) => void

Callback when the signature pad is done drawing.

readOnly
boolean

Whether the signature pad is read-only.

Data AttributeValue
[data-scope]signature-pad
[data-part]root
[data-disabled]Present when disabled

ClearTrigger

PropDefaultType
asChild
boolean

Render as a different element type.

Control

PropDefaultType
asChild
boolean

Render as a different element type.

Data AttributeValue
[data-scope]signature-pad
[data-part]control
[data-disabled]Present when disabled

Guide

PropDefaultType
asChild
boolean

Render as a different element type.

Data AttributeValue
[data-scope]signature-pad
[data-part]guide
[data-disabled]Present when disabled

Label

PropDefaultType
asChild
boolean

Render as a different element type.

Data AttributeValue
[data-scope]signature-pad
[data-part]label
[data-disabled]Present when disabled

RootProvider

PropDefaultType
value
UseSignaturePadReturn

asChild
boolean

Render as a different element type.

Segment

PropDefaultType
asChild
boolean

Render as a different element type.