suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Signature Pad

A drawing area that captures a handwritten signature as strokes and can export it as an SVG string.

Signature Pad is an open-source component from suiss/ui for React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

React Native
Signature pad demo in React Native, light modeSignature pad demo in React Native, dark mode
import { SignaturePad } from "@/components/ui/signature-pad"

export default function SignaturePadDemo() {
  return <SignaturePad />
}
import SwiftUI

struct SignaturePadExample: View {
  var body: some View {
    SignaturePadDemo(initial: [])
  }
}

struct SignaturePadDemo: View {
  var strokeWidth: CGFloat = 2.5

  @State private var strokes: [SignatureStroke]

  init(initial: [SignatureStroke], strokeWidth: CGFloat = 2.5) {
    self.strokeWidth = strokeWidth
    _strokes = State(initialValue: initial)
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.SignaturePad

@Composable
fun SignaturePadExample() {
    SignaturePad(Modifier.fillMaxWidth())
}

SignaturePad is a View with a single-finger pan gesture from react-native-gesture-handler. Each touch records a stroke of points, and the strokes are drawn as smoothed paths with react-native-svg. A signature line with an × mark and a placeholder sits near the bottom, and a ghost Clear button appears in the top corner once something is drawn.

Installation

$ pnpm dlx shadcn@latest add @esuiss/signature-pad

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add signature-pad
$ pnpm dlx shadcn@latest add @esuiss/signature-pad

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add signature-pad --platform swift
$ pnpm dlx shadcn@latest add @esuiss/signature-pad

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add signature-pad --platform kotlin

The CLI also adds what it builds on: Button, Icon, Text.

  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-gesture-handler react-native-svg
  1. Add the pieces it builds on: Button, Icon, Text.

  2. Copy and paste the following code into components/ui/signature-pad.tsx:

uniwind/components/ui/signature-pad.tsx
import { cn } from "cn"
import type { IconProps as PhosphorIconProps } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Gesture, GestureDetector } from "react-native-gesture-handler"
import Svg, { Path } from "react-native-svg"
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type SignaturePadPoint = { x: number; y: number }

type SignaturePadStroke = SignaturePadPoint[]

type SignaturePadHandle = {
  toSVG: (options?: { color?: string }) => string
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-gesture-handler react-native-svg
  1. Add the pieces it builds on: Button, Icon, Text.

  2. Copy and paste the following code into components/ui/signature-pad.tsx:

nativewind/components/ui/signature-pad.tsx
import { cn } from "cn"
import type { IconProps as PhosphorIconProps } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Gesture, GestureDetector } from "react-native-gesture-handler"
import Svg, { Path } from "react-native-svg"
import { Button } from "@/components/ui/button"
import { Icon } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type SignaturePadPoint = { x: number; y: number }

type SignaturePadStroke = SignaturePadPoint[]

type SignaturePadHandle = {
  toSVG: (options?: { color?: string }) => string
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install react-native-gesture-handler react-native-svg
  1. Add the pieces it builds on: Button, Text.

  2. Copy and paste the following code into components/ui/signature-pad.tsx:

stylesheet/components/ui/signature-pad.tsx
import * as React from "react"
import { type StyleProp, StyleSheet, View, type ViewStyle } from "react-native"
import { Gesture, GestureDetector } from "react-native-gesture-handler"
import Svg, { Path } from "react-native-svg"
import { Button } from "@/components/ui/button"
import { Text } from "@/components/ui/text"
import { fontSize, radius, useTheme } from "@/components/ui/theme"

type SignaturePadPoint = { x: number; y: number }

type SignaturePadStroke = SignaturePadPoint[]

type SignaturePadHandle = {
  toSVG: (options?: { color?: string }) => string
  clear: () => void
  isEmpty: () => boolean
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source and every file it uses:
swift/Components/SignaturePad.swift
import PhosphorSwift
import SwiftUI
import UIKit

public struct SignatureStroke: Hashable, Sendable {
  public var points: [CGPoint]

  public init(_ points: [CGPoint]) {
    self.points = points
  }
}

enum SignatureMath {
  static func path(for stroke: [CGPoint], strokeWidth: CGFloat) -> Path {
    var path = Path()
    guard let first = stroke.first else { return path }
swift/Components/Button.swift
import SwiftUI

public struct VariantButtonStyle: ButtonStyle {
  public enum Variant: CaseIterable, Sendable {
    case `default`, outline, secondary, tinted, ghost, plain, destructive, link
  }

  public enum Size: CaseIterable, Sendable {
    case `default`, xs, sm, lg, xl, form, icon, iconXs, iconSm, iconLg, iconXl

    var height: CGFloat {
      switch self {
      case .xs, .iconXs: Metrics.Height.buttonXs
      case .sm, .iconSm: Metrics.Height.buttonSm
      case .default, .icon: Metrics.Height.button
      case .lg, .iconLg: Metrics.Height.buttonLg
swift/Components/ButtonGroup.swift
import SwiftUI

extension EnvironmentValues {
  @Entry var buttonGroup: Axis? = nil
  @Entry var buttonGroupSize: CGSize = .zero
}

enum ButtonGroupSpace: Hashable {
  case group
}

struct ButtonGroupFrame {
  let bounds: Anchor<CGRect>
  let outlined: Bool
}
swift/Components/Field.swift
import SwiftUI

extension EnvironmentValues {
  @Entry public var isInvalid = false
  @Entry var fieldInset = false
  @Entry var fieldSize = FieldSize.default
  @Entry var fieldGroupInset = false
  @Entry var fieldSetInset = false
}

extension View {
  public func invalid(_ isInvalid: Bool = true) -> some View {
    environment(\.isInvalid, isInvalid)
  }
}
swift/Components/Separator.swift
import SwiftUI

public struct Separator: View {
  let orientation: Axis

  public init(_ orientation: Axis = .horizontal) {
    self.orientation = orientation
  }

  public var body: some View {
    Rectangle()
      .fill(EsuissColor.border)
      .frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
      .frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
      .accessibilityHidden(true)
  }
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/SignaturePad.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.awaitEachGesture
import androidx.compose.foundation.gestures.awaitFirstDown
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.getValue
kotlin/components/Button.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
kotlin/components/ButtonGroup.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { SignaturePad } from "@/components/ui/signature-pad"
<SignaturePad />
import SwiftUI

struct SignaturePadExample: View {
  var body: some View {
    SignaturePadDemo(initial: [])
  }
}

struct SignaturePadDemo: View {
  var strokeWidth: CGFloat = 2.5

  @State private var strokes: [SignatureStroke]

  init(initial: [SignatureStroke], strokeWidth: CGFloat = 2.5) {
    self.strokeWidth = strokeWidth
    _strokes = State(initialValue: initial)
  }

  var body: some View {
    SignaturePad(value: $strokes, strokeWidth: strokeWidth)
      .frame(height: 192)
      .frame(maxWidth: .infinity)
  }
}
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.esuiss.ui.components.SignaturePad

@Composable
fun SignaturePadExample() {
    SignaturePad(Modifier.fillMaxWidth())
}

Examples

Signed

A pad that starts with a saved signature.

React Native
Signature pad signed in React Native, light modeSignature pad signed in React Native, dark mode
import {
  SignaturePad,
  type SignaturePadStroke,
} from "@/components/ui/signature-pad"

function wave(
  startX: number,
  baseY: number,
  length: number,
  amplitude: number,
  turns: number
): SignaturePadStroke {
  return Array.from({ length: 48 }, (_, index) => {
    const progress = index / 47
    return {
      x: startX + progress * length,
import SwiftUI

struct SignaturePadSignedExample: View {
  var body: some View {
    SignaturePadDemo(initial: signaturePadSample)
  }
}

func signaturePadWave(startX: CGFloat, baseY: CGFloat, length: CGFloat, amplitude: CGFloat, turns: CGFloat) -> SignatureStroke {
  SignatureStroke((0..<48).map { index in
    let progress = CGFloat(index) / 47
    return CGPoint(
      x: startX + progress * length,
      y: baseY - sin(progress * .pi * turns) * amplitude * (1 - progress * 0.4)
    )
  })
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import com.esuiss.ui.components.SignaturePad
import com.esuiss.ui.components.SignatureStroke
import kotlin.math.PI
import kotlin.math.sin

@Composable
fun SignaturePadSignedExample() {
    SignaturePad(Modifier.fillMaxWidth(), defaultValue = signaturePadSample)
}

fun signaturePadWave(startX: Float, baseY: Float, length: Float, amplitude: Float, turns: Float): SignatureStroke =
    SignatureStroke(

Thick stroke

A signature drawn with strokeWidth={5}.

React Native
Signature pad thick stroke in React Native, light modeSignature pad thick stroke in React Native, dark mode
import {
  SignaturePad,
  type SignaturePadStroke,
} from "@/components/ui/signature-pad"

function wave(
  startX: number,
  baseY: number,
  length: number,
  amplitude: number,
  turns: number
): SignaturePadStroke {
  return Array.from({ length: 48 }, (_, index) => {
    const progress = index / 47
    return {
      x: startX + progress * length,
import SwiftUI

struct SignaturePadThickStrokeExample: View {
  var body: some View {
    SignaturePadDemo(initial: signaturePadSample, strokeWidth: 5)
  }
}

func signaturePadWave(startX: CGFloat, baseY: CGFloat, length: CGFloat, amplitude: CGFloat, turns: CGFloat) -> SignatureStroke {
  SignatureStroke((0..<48).map { index in
    let progress = CGFloat(index) / 47
    return CGPoint(
      x: startX + progress * length,
      y: baseY - sin(progress * .pi * turns) * amplitude * (1 - progress * 0.4)
    )
  })
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.unit.dp
import com.esuiss.ui.components.SignaturePad
import com.esuiss.ui.components.SignatureStroke
import kotlin.math.PI
import kotlin.math.sin

@Composable
fun SignaturePadThickStrokeExample() {
    SignaturePad(Modifier.fillMaxWidth(), defaultValue = signaturePadSample, strokeWidth = 5.dp)
}

fun signaturePadWave(startX: Float, baseY: Float, length: Float, amplitude: Float, turns: Float): SignatureStroke =

Disabled

A disabled pad that ignores touches and hides the Clear button.

React Native
Signature pad disabled in React Native, light modeSignature pad disabled in React Native, dark mode
import {
  SignaturePad,
  type SignaturePadStroke,
} from "@/components/ui/signature-pad"

function wave(
  startX: number,
  baseY: number,
  length: number,
  amplitude: number,
  turns: number
): SignaturePadStroke {
  return Array.from({ length: 48 }, (_, index) => {
    const progress = index / 47
    return {
      x: startX + progress * length,
import SwiftUI

struct SignaturePadDisabledExample: View {
  var body: some View {
    SignaturePadDemo(initial: signaturePadSample)
      .disabled(true)
  }
}

func signaturePadWave(startX: CGFloat, baseY: CGFloat, length: CGFloat, amplitude: CGFloat, turns: CGFloat) -> SignatureStroke {
  SignatureStroke((0..<48).map { index in
    let progress = CGFloat(index) / 47
    return CGPoint(
      x: startX + progress * length,
      y: baseY - sin(progress * .pi * turns) * amplitude * (1 - progress * 0.4)
    )
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import com.esuiss.ui.components.SignaturePad
import com.esuiss.ui.components.SignatureStroke
import kotlin.math.PI
import kotlin.math.sin

@Composable
fun SignaturePadDisabledExample() {
    SignaturePad(Modifier.fillMaxWidth(), defaultValue = signaturePadSample, enabled = false)
}

fun signaturePadWave(startX: Float, baseY: Float, length: Float, amplitude: Float, turns: Float): SignatureStroke =
    SignatureStroke(

Controlled

A controlled pad that reads the signature through the ref and exports it with toSVG.

React Native
Signature pad controlled in React Native, light modeSignature pad controlled in React Native, dark mode
import * as React from "react"
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import {
  SignaturePad,
  type SignaturePadHandle,
  type SignaturePadStroke,
} from "@/components/ui/signature-pad"
import { Text } from "@/components/ui/text"

function wave(
  startX: number,
  baseY: number,
  length: number,
  amplitude: number,
  turns: number
import * as React from "react"
import { View } from "react-native"
import { Button } from "@/components/ui/button"
import {
  SignaturePad,
  type SignaturePadHandle,
  type SignaturePadStroke,
} from "@/components/ui/signature-pad"
import { Text } from "@/components/ui/text"
import { fontSize, useTheme } from "@/components/ui/theme"

function wave(
  startX: number,
  baseY: number,
  length: number,
  amplitude: number,
import SwiftUI

func signaturePadWave(startX: CGFloat, baseY: CGFloat, length: CGFloat, amplitude: CGFloat, turns: CGFloat) -> SignatureStroke {
  SignatureStroke((0..<48).map { index in
    let progress = CGFloat(index) / 47
    return CGPoint(
      x: startX + progress * length,
      y: baseY - sin(progress * .pi * turns) * amplitude * (1 - progress * 0.4)
    )
  })
}

@MainActor let signaturePadSample: [SignatureStroke] = [
  signaturePadWave(startX: 40, baseY: 120, length: 70, amplitude: 40, turns: 3),
  signaturePadWave(startX: 110, baseY: 115, length: 110, amplitude: 22, turns: 5),
  SignatureStroke([CGPoint(x: 60, y: 140), CGPoint(x: 140, y: 136), CGPoint(x: 230, y: 134)]),
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.LiveRegionMode
import androidx.compose.ui.semantics.liveRegion
import androidx.compose.ui.semantics.semantics

Accessibility

  • The pad is a single accessible element labeled by accessibilityLabel.
  • Its value is announced as "Empty" or "Signed", and disabled is reported in its state.
  • When it has a signature and is not disabled, it offers a clear accessibility action, so VoiceOver and TalkBack users can clear it without finding the button.

API Reference

SignaturePad

The SignaturePad component captures a handwritten signature as strokes.

PropTypeDefault
valueSignaturePadStroke[]-
defaultValueSignaturePadStroke[]-
onChange(value: SignaturePadStroke[]) => void-
strokeWidthnumber2.5
disabledbooleanfalse
placeholderReact.ReactNode"Sign here"
clearLabelReact.ReactNode"Clear"
refReact.Ref<SignaturePadHandle>-

Also accepts the props of React.ComponentProps<typeof View>.

Use it uncontrolled with defaultValue, or controlled with value and onChange. The value is an array of strokes, where each stroke is an array of { x, y } points. onChange is called with the full list of strokes after each stroke ends or the pad is cleared. Points closer than one point to the previous point are skipped while drawing. disabled turns off drawing, hides the Clear button and dims the pad. placeholder is shown on the signature line while the pad is empty.

Pass a ref to get a SignaturePadHandle with toSVG(), clear() and isEmpty(). toSVG returns an SVG string sized to the pad and accepts an optional color (defaults to currentColor). The SignaturePadHandle, SignaturePadPoint and SignaturePadStroke types are also exported.

SignatureStroke

ParameterTypeDefault
_ points[CGPoint]-
PropertyType
points[CGPoint]

SignaturePad

The SignaturePad component captures a handwritten signature as strokes.

ParameterTypeDefault
valueBinding<[SignatureStroke]>-
strokeWidthCGFloat2.5
placeholderLocalizedStringKey"Sign here"
clearableBooltrue

SignaturePad.path

ParameterTypeDefault
_ strokes[SignatureStroke]-
strokeWidthCGFloat2.5

Returns Path.

SignaturePad.image

ParameterTypeDefault
_ strokes[SignatureStroke]-
sizeCGSize-
strokeWidthCGFloat2.5
colorColorEsuissColor.foreground
colorSchemeColorScheme.light
scaleCGFloat3

Returns UIImage?.

SignatureStroke

ParameterTypeDefault
pointsList<Offset>-

toPath

Receiver: List<SignatureStroke>.

ParameterTypeDefault
scaleFloat1f

Returns Path.

toSvg

Receiver: List<SignatureStroke>.

ParameterTypeDefault
widthFloat-
heightFloat-
strokeWidthFloat2.5f
colorString"#000000"

Returns String.

toImageBitmap

Receiver: List<SignatureStroke>.

ParameterTypeDefault
widthDp-
heightDp-
densityDensity-
colorColorColor.Black
strokeWidthDp2.5.dp
backgroundColorColor.Transparent

Returns ImageBitmap.

SignaturePad

The SignaturePad component captures a handwritten signature as strokes.

ParameterTypeDefault
modifierModifierModifier
valueList<SignatureStroke>?null
onValueChange((List<SignatureStroke>) -> Unit)?null
defaultValueList<SignatureStroke>emptyList()
strokeWidthDp2.5.dp
enabledBooleantrue
placeholderString"Sign here"
clearLabelString"Clear"
showClearButtonBooleantrue
NextSkeletonPreviousSidebar

On this page

  1. 01Installation
  2. 02Usage
  3. 03Examples
    • Signed
    • Thick stroke
    • Disabled
    • Controlled
  4. 04Accessibility
  5. 05API Reference
    • SignaturePad
    • SignatureStroke
    • SignaturePad
    • SignaturePad.path
    • SignaturePad.image
    • SignatureStroke
    • toPath
    • toSvg
    • toImageBitmap
    • SignaturePad