Skip to content
Alea
Pro
  1. Alea
  2. Components
  3. Data entry
  4. SignaturePad

Data entry

SignaturePad

A pad to sign with a finger, a pencil or a mouse, for consent forms, deliveries and agreements. It gives back an image of the signature (a PNG with a transparent background), and it has a second way for people who cannot draw: typing the name.

import { SignaturePad } from '@alea-design/ui';

Examples

In a form

With name, the pad sends its PNG as a data URL with the other fields. Show the error when it is required and empty.

Tokens

The design tokens this component reads, with their value in the current theme. Override any of them to restyle it.

Color

  • --alea-border-strong…
  • --alea-focus-offset…
  • --alea-focus-ring…
  • --alea-status-danger…
  • --alea-surface…
  • --alea-text…
  • --alea-text-muted…

Space

  • --alea-space-2…
  • --alea-space-3…
  • --alea-space-4…
  • --alea-space-8…

Size

  • --alea-size-touch…

Radius

  • --alea-radius-md…

Type

  • --alea-font-family-body…
  • --alea-font-size-md…
  • --alea-font-weight-medium…

Component

  • --alea-input-radius…

Props

SignaturePad props

A pad to sign with a finger, a pencil or a mouse. It gives back a PNG with a transparent background, in the text color of the theme at the time of signing. Drawing needs a pointer, so a second way is part of the component: typing the name, which is drawn on the pad. Undo removes the last stroke, Clear empties it.

PropTypeDefaultDescription
labelrequiredstringThe visible label ("Patient signature").
allowTypedbooleantrueLets a person who cannot or does not want to draw type their name instead (drawn on the pad in a handwriting style). A pad that can only be drawn on is not usable by keyboard or voice. Default true.
classNamestringnoneExtra class names for the root element.
defaultValuestring | nullnullThe signature at first (uncontrolled).
descriptionstringnoneHelp text under the pad.
errorMessagestringnoneShows the error text under the pad and marks it invalid.
heightnumber160Height of the drawing area in px. Default 160.
isDisabledbooleanfalse
isReadOnlybooleanfalseShows the signature without letting it be changed.
isRequiredbooleanfalse
namestringnoneName of a hidden input that carries the data URL, so the pad works inside a form.
onChange((value: string | null) => void)noneCalled with the PNG data URL after each stroke, after a typed name, and with null when the pad is cleared.
valuestring | nullnoneThe signature as a PNG data URL (controlled). null when empty.

Specs

Generated from the source: the variants in the types, the states and tokens in the CSS, and the motion patterns that apply. The grids render the real component in both themes; the numbers are measured from the page.

States
Keyboard focusInvalidDisabled
Dark and light
Every color comes from theme tokens, so it follows data-theme (and presets like Graphite) on the page or any wrapper. Contrast is checked in both themes.
Styling hooks
.alea-signature.alea-signature-label.alea-signature-desc.alea-signature-area.alea-signature-canvas.alea-signature-hint.alea-signature-line.alea-signature-typed.alea-input.alea-signature-input.alea-signature-actions.alea-signature-error
Data attributes
data-locked

Accessibility

  • Drawing needs a pointer, so the typed name is part of the component and not an extra: "Type your name instead" turns the pad into a text field and draws the name on it, which a keyboard and a voice can use. Turn it off only when the law asks for a drawn signature, and say so in the description.
  • The pad is an image named by its label, and its description says "Empty. Not signed yet." or "Signed.", so a screen reader can tell whether there is a signature.
  • Undo and Clear are buttons with their own names, and what they did ("Last stroke removed", "Signature cleared") is said politely.
  • The ink is the text color of the theme at the moment of signing; the baseline and the hint are not part of the PNG.

Keyboard

KeyDoes
TabMoves between Undo, Clear and the typed name option
Enter or SpacePresses the focused button
Type your name insteadLets the name be typed in a text field instead of drawn

Do and don't

Do

  • Give it a label that says who signs ("Patient signature").
  • Use name to send the PNG with the form, and show an errorMessage when it is required and empty.
  • Save the image of the signature with the date, the name and what was signed: the image alone proves nothing.

Don't

  • Don't offer only the drawn way.
  • Don't treat the image of the signature as an electronic signature with legal weight without your lawyer: the law of each country decides what a signature needs.

In Figma

The properties of the Figma components, generated from the kit, so they always match it. The last column is the React prop each one stands for.

Signature pad · 2 variants

Figma propertyKindValuesDefaultReact prop
StateVariantEmpty, SignedEmptyisDisabled, isReadOnly, isRequired
Tested with axe, keyboard and screen reader roles