Skip to main content

SignaturePad

A pad to sign with a finger, a pen or the mouse. It's drawn with plain views, so it needs no WebView, canvas or SVG library. Its value is the strokes as points; turn them into an SVG with signatureToSvg to save or upload, or into a path with signatureToPath.

import { SignaturePad, signatureToSvg } from 'patine-ui';
Loading…
<VStack gap="md" style={{ width: 340 }}>
  <SignaturePad value={strokes} onValueChange={setStrokes} />
  <Button disabled={!strokes.length} onPress={() => setSaved(signatureToSvg(strokes, { width: 340, height: 200 }))}>
    Save
  </Button>
  {saved ? <Text size="xs" color="textSecondary">{`SVG, ${saved.length} characters`}</Text> : null}
</VStack>

Try the props​

Props
strokeWidth
height
<SignaturePad />

Example: sign for a delivery​

A courier app's handover screen: the recipient's name and signature are both needed before Confirm, and Clear starts the signature again.

Loading…
<Box border radius="lg" padding="lg" gap="md" style={{ width: '100%', maxWidth: 380 }}>
  <VStack gap="xs">
    <Text weight="semibold">Parcel 3 of 3 · 2.4 kg</Text>
    <Text size="sm" color="textSecondary">Keizersgracht 120, 2nd floor</Text>
  </VStack>
  <TextField label="Received by" placeholder="Full name" value={name} onChangeText={setName} />
  <SignaturePad value={strokes} onValueChange={setStrokes} height={160} />
  <Button disabled={!name.trim() || !strokes.length} onPress={() => setDone(signatureToSvg(strokes, { width: 340, height: 160 }))}>
    Confirm delivery
  </Button>
</Box>

Saving the signature​

  • signatureToSvg(strokes, { width, height, color, strokeWidth, backgroundColor }) returns a standalone SVG document: upload it, store it, or show it in an <img> with a data:image/svg+xml URL.
  • signatureToPath(strokes) returns the path's d, to draw with react-native-svg's <Path> or in a browser <svg>.
  • isSignatureEmpty(strokes) tells you whether anything was drawn.

Points are in the pad's own coordinates, from its top left, so use the pad's size as the SVG's width and height.

In a scroll view or sheet​

The pad claims the touch as soon as the pen lands, so a ScrollView or BottomSheet around it doesn't scroll while you sign. On iOS, pass onBegin and onEnd to turn the ScrollView's scrollEnabled off and on if the native scroll still moves.

Accessibility​

The pad is named "Signature" and reads "Signed" or "Empty". Screen readers get a Clear action, and the Clear button is a 44pt target. Drawing needs a pointer; if a signature is required, offer another way to confirm, such as typing the name.

Props​

PropTypeDefaultDescription
valueSignatureStroke[]—The strokes; [] clears it.
defaultValueSignatureStroke[][]When uncontrolled.
onValueChange(strokes) => void—A stroke is finished, or the pad is cleared.
onBegin / onEnd() => void—The pen lands and lifts.
strokeColorstringthe theme's text colour
strokeWidthnumber3
heightnumber200
showClearbooleantrueA Clear button once something's drawn.
disabledbooleanfalse
labelsPartial<SignatureLabels>Englishplaceholder, clear, label, signed, empty.
styleStyleProp<ViewStyle>—
theme / designprovider'sA gray card on iOS, an outlined field in Material, a dashed border on the web and brand.