Skip to content

SignaturePad

SignaturePad provides an SVG-based touch drawing canvas for capturing digital signatures. Supports undo, clear, and SVG export via ref methods.

Usage

SignatureExample.tsx
import { useRef } from 'react';
import { SignaturePad, type SignaturePadRef } from '@masumdev/rn-ui';
export function SignatureExample() {
const ref = useRef<SignaturePadRef>(null);
return (
<>
<SignaturePad
ref={ref}
height={200}
strokeWidth={3}
strokeColor="#6366F1"
showGuideLine
guideLineText="SIGN ABOVE THIS LINE"
/>
<Button onPress={() => ref.current?.clear()}>Clear</Button>
<Button onPress={() => ref.current?.undo()}>Undo</Button>
</>
);
}

Ref Methods

MethodReturnDescription
clear()voidClear all strokes
undo()voidRemove the last stroke
getPaths()string[]Get SVG path data strings
getSvg()stringExport as complete SVG markup
isEmpty()booleanCheck if canvas has strokes

Props API

PropTypeDefaultDescription
strokeColorstringStroke color for drawing.
strokeWidthnumber2Stroke width in pixels.
backgroundColorstringCanvas background color.
showGuideLinebooleantrueShow the dashed guide line.
guideLineTextstring"SIGN ABOVE THIS LINE"Text below the guide line.
onBegin() => voidCallback when drawing starts.
onEnd() => voidCallback when a stroke ends.
onChange(paths: string[]) => voidCallback when paths change.
heightnumber200Canvas height in pixels.
hapticFeedbackbooleantrueEnable haptic feedback on stroke start.