Signature Pad

Pro

A page to sign on with a mouse, a finger or a stylus. It keeps each pen stroke as a smooth SVG path, in writing order, so a Signature can play the hand back and a form can submit it.

Sign with your mouse, a finger or a stylus.

Installation#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add signature-pad

Usage#

This example is part of Koala UI Pro

The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.

Have a license? Unlock it here

Anatomy#

import {  SignaturePad,  SignaturePadActions,  SignaturePadUndo,  SignaturePadClear,} from "@/components/ui/signature-pad"<SignaturePad>  <SignaturePadActions>    <SignaturePadUndo />    <SignaturePadClear />  </SignaturePadActions></SignaturePad>

Play it back#

The value is one SVG path per stroke, in the order the hand wrote them, which is exactly what a Signature takes as its children. signatureViewBox(strokes) gives it the box around the ink, so it takes its width from the first paint. The Signature page has the full playground, with every speed and size.

Sign the pad and your hand is written back here.

States#

Inside a Field, the pad takes the field's label and hint as its name and description, and its hasError and disabled cascade in, the same as an Input. An error paints the frame; a disabled pad keeps its signature on show but no longer takes the pen or offers Undo and Clear. Both props can also be set on the pad itself. Focus works like any field's: the first stroke focuses the pad, and it stays lit through every lift of the pen and every Undo until you click away, so a signature of five strokes does not blink five times. While it has focus, Ctrl / ⌘ + Z takes back the last stroke.

Sign to accept the agreement.

Signed

Signed on 12 September 2026. The agreement is locked.

Without actions#

Undo and Clear are parts, not props: leave SignaturePadActions out and the pad is only a page, for an initial box or a flow that clears it some other way. With them in, they stay hidden until there is a stroke to take back. placeholder replaces the line under the empty page.

In a form#

With a name, the pad submits the drawing as a standalone SVG document, its ink in currentColor: store it, email it, or render it back. Sign, then submit, to see exactly what the form receives. signatureToSvg(strokes) builds the same document from a controlled value.

API reference#

SignaturePad

A <div role="group" tabIndex={-1}> framing the page, 160px tall (an h-* class sets another height); the pen focuses it and the tab stops are Undo and Clear. Forwards all native <div> props, and every part accepts className, merged last.

PropTypeDefaultDescription
valuestring[]-The strokes, one SVG path per pen stroke in writing order (controlled).
defaultValuestring[][]The strokes to start from (uncontrolled).
onValueChange(strokes: string[]) => void-Called when a stroke lands, and on undo and clear, with every stroke so far.
namestring-Submits the drawing under this name as a standalone SVG document (see signatureToSvg).
placeholderReact.ReactNode"Sign here"The text on the baseline while the page is empty.
hasErrorbooleanfalsePaints the destructive frame. Falls back to the enclosing Field's error state.
disabledbooleanfalseStops the pen and dims the pad. Falls back to the enclosing Field's disabled state.
Data attributeDescription
data-emptyPresent while there are no strokes and the pen is up.
data-drawingPresent while a stroke is being written.
data-disabledPresent when the pad is disabled.

SignaturePadActions

The top-right corner holding Undo and Clear, hidden while the pad is empty. Forwards all native <div> props.

SignaturePadUndo

A ghost sm Button that takes back the last stroke (also Cmd/Ctrl+Z while the pad has focus); disabled while the pad is empty. Forwards every Button prop.

PropTypeDefaultDescription
childrenReact.ReactNode"Undo"The label.
onClickReact.MouseEventHandler<HTMLButtonElement>-Runs before the undo; call event.preventDefault() to cancel it.

SignaturePadClear

A ghost sm Button that wipes the page; disabled while the pad is empty. Forwards every Button prop.

PropTypeDefaultDescription
childrenReact.ReactNode"Clear"The label.
onClickReact.MouseEventHandler<HTMLButtonElement>-Runs before the clear; call event.preventDefault() to cancel it.

signatureViewBox

A function returning the box around the ink, padded, as a viewBox string. Pass it to a Signature to reserve its width from the first paint.

PropTypeDefaultDescription
strokes*string[]-The pad's value.
paddingnumber4Space added around the ink, in pad pixels.

signatureToSvg

A function returning the drawing as a standalone SVG document with currentColor ink: the value the pad submits under name. Returns "" for no strokes.

PropTypeDefaultDescription
strokes*string[]-The pad's value.

FAQ#

An array of strings, one SVG path per pen stroke in the order it was written, each a smooth curve through the points the pen touched. It is small, it is plain text, and a Signature renders it as it is.