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';
<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
strokeWidthheight<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.
<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 adata:image/svg+xmlURL.signatureToPath(strokes)returns the path'sd, to draw withreact-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
| Prop | Type | Default | Description |
|---|---|---|---|
value | SignatureStroke[] | — | The strokes; [] clears it. |
defaultValue | SignatureStroke[] | [] | When uncontrolled. |
onValueChange | (strokes) => void | — | A stroke is finished, or the pad is cleared. |
onBegin / onEnd | () => void | — | The pen lands and lifts. |
strokeColor | string | the theme's text colour | |
strokeWidth | number | 3 | |
height | number | 200 | |
showClear | boolean | true | A Clear button once something's drawn. |
disabled | boolean | false | |
labels | Partial<SignatureLabels> | English | placeholder, clear, label, signed, empty. |
style | StyleProp<ViewStyle> | — | |
theme / design | provider's | A gray card on iOS, an outlined field in Material, a dashed border on the web and brand. |