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
Consent
Sign with a finger, a pencil or a mouse. Undo removes the last stroke; "Type your name instead" is the way for someone who cannot draw.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
labelrequired | string | The visible label ("Patient signature"). | |
allowTyped | boolean | true | Lets 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. |
className | string | none | Extra class names for the root element. |
defaultValue | string | null | null | The signature at first (uncontrolled). |
description | string | none | Help text under the pad. |
errorMessage | string | none | Shows the error text under the pad and marks it invalid. |
height | number | 160 | Height of the drawing area in px. Default 160. |
isDisabled | boolean | false | |
isReadOnly | boolean | false | Shows the signature without letting it be changed. |
isRequired | boolean | false | |
name | string | none | Name of a hidden input that carries the data URL, so the pad works inside a form. |
onChange | ((value: string | null) => void) | none | Called with the PNG data URL after each stroke, after a typed name, and with null when the pad is cleared. |
value | string | null | none | The 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
| Key | Does |
|---|---|
| Tab | Moves between Undo, Clear and the typed name option |
| Enter or Space | Presses the focused button |
| Type your name instead | Lets 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 property | Kind | Values | Default | React prop |
|---|---|---|---|---|
| State | Variant | Empty, Signed | Empty | isDisabled, isReadOnly, isRequired |