Command palette

@yasinsensoy/native

React Native · Components

SignaturePad

Signature area: sign with a finger or a stylus.

5 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Code

import { SignaturePad } from "@yasinsensoy/native";

<SignaturePad ref={ref} className="h-48" />

Events

  1. Events appear here when you interact with the preview.

Import

import { SignaturePad } from "@yasinsensoy/native";

SignaturePad

component

Signature area: sign with a finger or a stylus. Contract approval, delivery confirmation.

  • Strokes are smoothed with the same rules as web; they thin with speed.
  • Strokes are stored relative to the area; when the area size changes the signature is redrawn keeping its ratio. The value has the same format as the web SignaturePad.
  • The enclosing scroll stops while drawing.
  • toSVG(), clear(), undo(), redo() via ref.
SignaturePad(props: SignaturePadProps): JSX.Element

Examples

const ref = useRef<SignaturePadHandle>(null);
<SignaturePad ref={ref} onValueChange={setSignature} />
<Button onPress={() => upload(ref.current?.toSVG())}>Send</Button>

A point of a signature. Positions are fractions of the pad size (0–1).

NameTypeDescription
xnumberHorizontal position (0–1, relative to the pad width).
ynumberVertical position (0–1, relative to the pad height).
wnumberStroke width at this point (relative to the pad width).

Functions accessed on SignaturePad via ref.

NameTypeDescription
toSVG() => stringConverts the signature to an SVG string (to send to a server or write to a file).
clear() => voidClears the signature.
undo() => voidUndoes the last stroke.
redo() => voidRedoes what was undone.
isEmpty() => booleanIs the signature empty?

The whole signature: strokes in order.

type SignatureValue = readonly SignatureStroke[]

SignaturePad props.

Extends: FieldProps

NameTypeDefaultDescription
value?SignatureValueControlled signature (strokes; positions relative to the area).
defaultValue?SignatureValueInitial signature.
onValueChange?(value: SignatureValue) => voidAfter each stroke ends, on clear and on undo.
color?stringthe theme's text colorInk color.
minWidth?number0.8Thinnest stroke (px).
maxWidth?number2.8Thickest stroke (px).
placeholder?ReactNode{@link UIProvider} `signatureHint` textHint shown while empty; null hides it.
toolbar?booleantrueUndo, redo and clear buttons.
readOnly?booleanDisplay only; cannot be drawn on.
disabled?booleanDisabled.
aria-label?string{@link UIProvider} `signatureLabel` textScreen reader name.
ref?Ref<SignaturePadHandle>Access: toSVG, clear, undo…
height?number160Height of the area.
style?StyleProp<ViewStyle>Container style.