Signature component is used for online signatures, contract signing, handwriting input, etc. Built on Canvas, it supports finger or mouse drawing.
Use the aspectRatio prop to set the canvas width-to-height ratio. Default is [3, 1] (3:1). Adjust according to your needs, such as [2, 1], [4, 3], etc.
The signature component supports marking orientation, which is useful in landscape signing scenarios. Set the direction mark via the direction prop:
top (default): Top side faces upbottom: Bottom side faces upleft: Left side faces upright: Right side faces upWhen exporting signatures, SignatureResult includes direction information, which can be used to rotate the image accordingly.
Use showDirectionMark prop to control the visibility of the direction mark.
The current version no longer auto-adapts to light or dark mode. Defaults are:
#000000#ffffffSet lineColor and bgColor explicitly when you need dark mode styling.
Use lineColor and bgColor props to customize pen and background colors.
Use lineWidth prop to set pen thickness in pixels. Default is 3.
Canvas border radius defaults to the theme's large area radius config. Customize via radius prop.
By default, "Clear" and "Confirm" buttons are shown. Customize them as follows:
Use clearText and confirmText to set button labels.
Use clearButton and confirmButton to set button styles.
Set showButtons={false} to hide built-in buttons, then use component methods like clear and getSignature.
Supports PNG, JPEG, and WebP formats. Use imageType to configure the format. The exported image is a Base64 Data URL, which can be used directly in <img> tag's src attribute or uploaded to a server.
| Format | Features | Use Cases |
|---|---|---|
| PNG | Lossless compression, supports transparency, larger file size | High quality or transparent background needed |
| JPEG | Lossy compression, no transparency, smaller file size | File size sensitive, no transparency needed |
| WebP | Smaller file at same quality, supports transparency | Modern browsers, best compression ratio |
imageQuality only works for JPEG and WebP formats, range 0 to 1, default 0.92. Higher values mean better quality but larger files.
| Method | Description |
|---|---|
| clear() | Clear canvas |
| getSignature() | Get signature data |
| isEmpty() | Check if signature is empty |
isEmpty property before submission to avoid submitting empty signatures