# @salmonui/inputs/signature-pad API reference

> 7 exported symbols of @salmonui/inputs/signature-pad: 1 component, 4 interfaces and 2 types.

Canonical: https://salmonui.dev/docs/reference/inputs/signature-pad

```ts
import { … } from '@salmonui/inputs/signature-pad';
```

## Components

### SignaturePad

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignaturePad

```ts
function SignaturePad(props: SignaturePadProps): ReactNode;
```

Signature capture: a Canvas 2D pad drawn with Pointer Events,
a "type your name" keyboard mode, undo / redo (`Mod+Z`, `Mod+Shift+Z`),
PNG / JPEG / SVG output and form participation through a hidden input.
`ref` is a `SignaturePadApi`.

Props: [`SignaturePadProps`](https://salmonui.dev/docs/reference/inputs/signature-pad/SignaturePadProps) (its members are the props)

## Interfaces

### SignatureChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignatureChangeDetails

```ts
interface SignatureChangeDetails {
    readonly source: 'pointer' | 'touch' | 'keyboard' | 'api';
    readonly reason: SignatureAction;
    readonly action: SignatureAction;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'pointer' \| 'touch' \| 'keyboard' \| 'api';` |  |  |
| `reason` | `readonly reason: SignatureAction;` |  |  |
| `action` | `readonly action: SignatureAction;` |  |  |

### SignatureImageOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignatureImageOptions

```ts
interface SignatureImageOptions {
    readonly background?: boolean | undefined;
}
```

Image options of `toDataURL` / `toBlob`.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `background` | `readonly background?: boolean \| undefined;` | optional | Include `backgroundColor` and `backgroundImage`. Default true. |

### SignaturePadApi

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignaturePadApi

```ts
interface SignaturePadApi {
    readonly element: HTMLDivElement | null;
    undo(): void;
    redo(): void;
    canUndo(): boolean;
    canRedo(): boolean;
    clear(): void;
    isEmpty(): boolean;
    drawText(text: string, options?: {
        readonly fontFamily?: string | undefined;
        readonly fontSize?: number | undefined;
    }): void;
    load(source: string): Promise<void>;
    toDataURL(type?: 'image/png' | 'image/jpeg', options?: SignatureImageOptions): string;
    toBlob(type?: 'image/png' | 'image/jpeg', options?: SignatureImageOptions): Promise<Blob | null>;
    toSVG(options?: SignatureImageOptions): string;
    focus(): void;
}
```

`ref` of `SignaturePad`.

Members (13):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `readonly element: HTMLDivElement \| null;` |  | The root element. |
| `undo` | `undo(): void;` |  |  |
| `redo` | `redo(): void;` |  |  |
| `canUndo` | `canUndo(): boolean;` |  |  |
| `canRedo` | `canRedo(): boolean;` |  |  |
| `clear` | `clear(): void;` |  |  |
| `isEmpty` | `isEmpty(): boolean;` |  |  |
| `drawText` | `drawText(text: string, options?: {     readonly fontFamily?: string \| undefined;     readonly fontSize?: number \| undefined; }): void;` |  | Replaces the signature with centered text. |
| `load` | `load(source: string): Promise<void>;` |  | Loads an image (data URL or URL) as the signature; resolves when drawn. |
| `toDataURL` | `toDataURL(type?: 'image/png' \| 'image/jpeg', options?: SignatureImageOptions): string;` |  | PNG (default) or JPEG at the canvas resolution. |
| `toBlob` | `toBlob(type?: 'image/png' \| 'image/jpeg', options?: SignatureImageOptions): Promise<Blob \| null>;` |  |  |
| `toSVG` | `toSVG(options?: SignatureImageOptions): string;` |  | Vector markup from the stroke model, in CSS pixels. |
| `focus` | `focus(): void;` |  |  |

### SignaturePadProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignaturePadProps

```ts
interface SignaturePadProps extends FieldCommonProps {
    readonly value?: string | null | undefined;
    readonly defaultValue?: string | null | undefined;
    readonly onValueChange?: ((value: string | null, details: SignatureChangeDetails) => void) | undefined;
    readonly strokeColor?: string | undefined;
    readonly minStrokeWidth?: number | undefined;
    readonly maxStrokeWidth?: number | undefined;
    readonly velocity?: number | undefined;
    readonly backgroundColor?: string | undefined;
    readonly backgroundImage?: string | undefined;
    readonly height?: number | string | undefined;
    readonly toolbar?: boolean | undefined;
    readonly fontFamily?: string | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly required?: boolean | undefined;
    readonly disabled?: boolean | undefined;
    readonly readOnly?: boolean | undefined;
    readonly localeText?: SignaturePadLocaleText | undefined;
    readonly id?: string | undefined;
    readonly dir?: 'ltr' | 'rtl' | 'auto' | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly label?: string;
        readonly surface?: string;
        readonly canvas?: string;
        readonly toolbar?: string;
        readonly description?: string;
        readonly error?: string;
    } | undefined;
    readonly ref?: Ref<SignaturePadApi> | undefined;
}
```

Members (31):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |
| `value` | `readonly value?: string \| null \| undefined;` | optional | Controlled signature as a data URL (`null` empty). |
| `defaultValue` | `readonly defaultValue?: string \| null \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: string \| null, details: SignatureChangeDetails) => void) \| undefined;` | optional | After a stroke, undo, redo, clear, load, typed text or reset, with the PNG data URL (`null` empty). |
| `strokeColor` | `readonly strokeColor?: string \| undefined;` | optional | Default `'#000000'` (image data, not theme). |
| `minStrokeWidth` | `readonly minStrokeWidth?: number \| undefined;` | optional | Default 0.5. |
| `maxStrokeWidth` | `readonly maxStrokeWidth?: number \| undefined;` | optional | Default 2.5. |
| `velocity` | `readonly velocity?: number \| undefined;` | optional | Velocity filter weight 0..1; higher follows speed changes faster. Default 0.7. |
| `backgroundColor` | `readonly backgroundColor?: string \| undefined;` | optional | Canvas fill. Default none (transparent). |
| `backgroundImage` | `readonly backgroundImage?: string \| undefined;` | optional | Image drawn under the strokes, stretched to the pad. Same-origin or CORS-enabled. |
| `height` | `readonly height?: number \| string \| undefined;` | optional | Pad height (CSS length or px). Default 160. |
| `toolbar` | `readonly toolbar?: boolean \| undefined;` | optional | Shows the Clear button and the "type your name" toggle. Default true. |
| `fontFamily` | `readonly fontFamily?: string \| undefined;` | optional | Font of typed text. Default `'cursive'`. |
| `name` | `readonly name?: string \| undefined;` | optional | Submits the PNG data URL (empty when there is no signature). |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `required` | `readonly required?: boolean \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `readOnly` | `readonly readOnly?: boolean \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: SignaturePadLocaleText \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `dir` | `readonly dir?: 'ltr' \| 'rtl' \| 'auto' \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `classNames` | `readonly classNames?: {     readonly label?: string;     readonly surface?: string;     readonly canvas?: string;     readonly toolbar?: string;     readonly description?: string;     readonly error?: string; } \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<SignaturePadApi> \| undefined;` | optional |  |

## Types

### SignatureAction

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignatureAction

```ts
type SignatureAction = 'stroke' | 'undo' | 'redo' | 'clear' | 'load' | 'text' | 'reset';
```

What changed (`onValueChange` details).

### SignaturePadLocaleText

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/signature-pad/SignaturePadLocaleText

```ts
type SignaturePadLocaleText = FieldValidationText & {
    readonly empty?: string;
    readonly signed?: string;
    readonly typeMode?: string;
    readonly typeLabel?: string;
    readonly clear?: string;
};
```

User-visible strings.

Members (22):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `validationCreditcard` | `validationCreditcard?: string;` | optional, inherited |  |
| `validationDate` | `validationDate?: string;` | optional, inherited |  |
| `validationDateIso` | `validationDateIso?: string;` | optional, inherited |  |
| `validationDigits` | `validationDigits?: string;` | optional, inherited |  |
| `validationEmail` | `validationEmail?: string;` | optional, inherited |  |
| `validationMax` | `validationMax?: string;` | optional, inherited |  |
| `validationMaxLength` | `validationMaxLength?: string;` | optional, inherited |  |
| `validationMin` | `validationMin?: string;` | optional, inherited |  |
| `validationMinLength` | `validationMinLength?: string;` | optional, inherited |  |
| `validationNumber` | `validationNumber?: string;` | optional, inherited |  |
| `validationPattern` | `validationPattern?: string;` | optional, inherited |  |
| `validationRange` | `validationRange?: string;` | optional, inherited |  |
| `validationRangeLength` | `validationRangeLength?: string;` | optional, inherited |  |
| `validationRequired` | `validationRequired?: string;` | optional, inherited |  |
| `validationTel` | `validationTel?: string;` | optional, inherited |  |
| `validationUrl` | `validationUrl?: string;` | optional, inherited |  |
| `validationValidate` | `validationValidate?: string;` | optional, inherited |  |
| `empty` | `empty?: string;` | optional, inherited | Canvas name while empty. Default `'Signature, empty'`. |
| `signed` | `signed?: string;` | optional, inherited | Canvas name with a signature. Default `'Signature, signed'`. |
| `typeMode` | `typeMode?: string;` | optional, inherited | Mode toggle. Default `'Type your name'`. |
| `typeLabel` | `typeLabel?: string;` | optional, inherited | Label of the name field. Default `'Name'`. |
| `clear` | `clear?: string;` | optional, inherited | Default `'Clear'`. |
