Docs
Inputs

Signature Pad

A signature field with smooth, velocity-weighted ink and a glass toolbar for undo and clear, exporting to PNG or vector PDF.

$npx swiftpieces add SignaturePad
See it in a Pro app On a real screen in one of the Pro apps: open it with Pro, take it apart, remix it, and copy the SwiftUI.
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasssignatureinkdrawingcanvasformsexportpdfaccessibility
Type
SignaturePad
Files
SignaturePad.swift
Depends on
Nothing (Apple frameworks only)
Version
1.5.0

Signature capture that feels like ink, bound to a SignaturePad.Signature value you own. Strokes are smoothed through midpoint quadratics and weighted by speed (fast strokes run thin, slow turns run full), drawn in a Canvas one layer per stroke so finished strokes never redraw while you sign. Points are stored in the pad's coordinate space together with the pad size they were captured at, so the signature rescales with the pad on rotation and exports at any size. A drag that starts in the pad draws and never scrolls an enclosing ScrollView; a drag that starts outside still scrolls. swift @State private var signature = SignaturePad.Signature() SignaturePad(signature: $signature) Button("Confirm delivery") { upload(signature.pngData(size: CGSize(width: 600, height: 200))) } .disabled(signature.isEmpty)

Notes

  • Ink is weighted by speed, the way a pen behaves: each sample's width falls from Style.lineWidth toward about half of it as the finger speeds up, eased over 35 ms so strokes swell and thin smoothly. The line runs through the midpoints of the touch samples as quadratic curves, cut into short pieces whose widths interpolate, so there are no corners or width steps, and long gaps from very fast strokes are bridged by the same curves.
  • Each stroke is its own Canvas layer, grouped into a few paths by width. Finished strokes never redraw while you sign, so long signatures stay smooth.
  • A tap draws a dot. isEmpty stays true until there is at least Signature.minimumInk of ink (12% of the pad width, about 40pt on a phone) or a typed name, so a stray tap or speck never enables your submit button. strokes.isEmpty tells you whether anything is on the pad at all, and inkLength lets you set a stricter rule.
  • Points are stored in the pad's coordinates together with the pad size they were captured at (canvasSize). When the pad changes size (rotation, split view, a different Style.height) the signature scales uniformly, anchored to the bottom and the leading edge so it stays on the line next to the cross. Strokes added after a resize join the same space.
  • Undo removes the last stroke with a short fade and a rigid tick. Clear fades out the whole signature at once with a medium tick, and Undo right after Clear fades it all back in, until anything else changes. A soft tick marks the first touch of each stroke. With a hardware keyboard, Command-Z undoes and Command-Delete clears.
  • The ink itself is never animated: each stroke draws under the finger as it moves and stays exactly as drawn when the finger lifts, so the export matches the screen. Only the chrome around it moves, and quietly.
  • The "Sign here" hint fades and drops a few points on the first touch, and settles back in when the pad is empty again.
  • Once the signature counts and the pad has been still for a moment, a small sage glass Signed chip pops in at the far end of the status line under the baseline, where the hint sat, with a bounce and a success tap, the first time for each signature. When it comes back after a later pause it lands with just a little give and no tap, so a signature written in parts doesn't celebrate on every pause. Ink and a typed name arm apart: the tap re-arms once the ink no longer counts or the name is blank, so Type instead and back never replays it for the same strokes, and a draft passed in already signed doesn't tap on appear. It steps out quickly when the finger comes back, and a stroke that starts under it still draws.
  • The toolbar is one liquid glass shape floating centred under the paper, on the page rather than on the paper, where clear glass would all but vanish. Type instead is the pill in the middle; Undo (a round bubble) rests joined to its leading end and Clear (a capsule) to its trailing end, so liquid necks hold the three together and they read as one control. Each bubble is there only while it can act. The moment there is something to take back or clear, it buds out of its end of the pill, born inside it and springing to its place; when there is nothing left to undo or clear it melts back into the pill on a spring with no bounce, its label going first. Clear melts home after Clear, while Undo stays out to bring the signature back. Both side slots keep their width while a bubble is away, so the pill never moves.
  • The bubbles sink about 1.5 pt a side under the finger and spring back with a little bounce, and their labels dim while pressed. Glass is neutral; Style.control tints it.
  • A drag that starts in the pad draws from the first touch and never scrolls an enclosing ScrollView or Form; a drag that starts outside the pad scrolls as usual. If the system cancels a touch (a call, a presented sheet), the stroke so far is kept.
  • Type instead turns the line into a text field set in a script face (Snell Roundhand, a system font, so nothing is bundled). The pill's label morphs letter by letter to Draw instead and its glyph blurs from the keyboard to the signature; Undo melts home, since typing has nothing to undo, and Clear buds back out beside the pill once there is a name to clear. The ink fades out first and the field follows a beat behind, so strokes and the name barely overlap; the field takes focus and the keyboard rises at once. Draw instead brings the ink back with a short, firm fade, at full strength about 0.3 s after the tap. The name sits on the same baseline and shrinks to fit when it is long. Scripts the face lacks fall back to the system font. Drawn strokes are kept while typing, so Draw instead brings them back; while typedName is non-nil it is the signature for isEmpty and export.
  • Export: image(size:scale:ink:lineWidth:trimmed:) and pngData give a transparent PNG, and pdfData gives a one-page vector PDF. trimmed (the default) crops to the ink so the signature fills the image; false keeps the whole pad area with the signature where it sat. Ink defaults to black, whatever the on-screen appearance. A typed signature exports in the same script face. Both can be called off the main actor.
  • Signature is Codable and Equatable, so a draft can be saved and restored, and .onChange(of:) sees every stroke.
  • VoiceOver: the pad reads "Signature" with a value of Empty, Too short to count as a signature, or Signed. Double-tapping lets a VoiceOver user draw directly on it (direct touch), and the pad offers Type your name instead, Undo and Clear as actions. Undo, Clear and restores are announced. The typed field reads "Signature, typed name".
  • Reduce Motion: the hint and the Signed chip fade without moving, Undo and Clear fade in and out where they rest instead of budding, the mode label cross-fades instead of morphing, and the controls shift brightness instead of sinking (their labels still dim). Reduce Transparency draws the glass solid. Strokes and mode switches are fades either way; the mode hand-off becomes a quick crossfade. Haptics and announcements are unchanged.
  • Dynamic Type: the toolbar controls scale, and Undo and Clear move to a second row under Type instead when they no longer fit on one line; they bud down out of the middle of the pill there. The hint grows up to accessibility sizes and shrinks to fit under the line; the cross and baseline keep a fixed position so they stay aligned with stored strokes.
  • allowsTyping: false removes Type instead. It is the accessible path for people who cannot draw a signature, so turn it off only when your flow offers another way to sign.
  • Style sets the pad, ink, label and secondary colors, the glass tint of the toolbar bubbles (control, neutral by default) and of the Signed chip (signed), ink weight, corner radius and the paper's height (nil fills the height offered, for a full-screen signing sheet). .disabled(true) dims the pad and stops drawing.
  • v1.2: the pad is one card. Type instead sits at the leading end of a toolbar along the top, Undo and Clear at the trailing end, and a hairline separates the toolbar from the drawing area. Ink is clipped to the drawing area, so a stroke carried up past the hairline never draws over the controls. Under the baseline is a status line: the hint while the pad is empty, the Signed chip at its far end once the signature counts.
  • v1.3: heavier ink. lineWidth defaults to 5pt (was 3.6) for drawing and for image, pngData and pdfData, and fast strokes thin to about half the width instead of about 40%, so a quick signature still reads as a confident pen line.
  • v1.4: liquid glass. Type instead, Undo and Clear are glass bubbles in one cluster at the leading end of the toolbar; Undo and Clear bud out of Type instead when they can act and melt back into it when they can't, instead of dimming. The Signed chip is sage glass. All text and symbols are semibold.
  • v1.5: the paper is the whole card, with a hairline edge and a soft lift, and no toolbar strip inside it. The toolbar floats centred under the paper as one liquid shape: Undo buds out of the Type instead pill's leading end and Clear out of its trailing end, resting joined to it, so the necks hold.

Usage

SignaturePadExample()

Parameters

ParameterDescription
signatureThe bound signature. Drawn strokes, or a typed name when the person chose Type instead. isEmpty stays true until there is a typed name or enough ink to count (a stray dot or speck does not), so it is the right check for enabling a submit button. Setting it from outside redraws the pad; a stroke removed from outside inside withAnimation fades out.
promptThe hint under the baseline, shown until the first stroke. Defaults to "Sign here".
allowsTypingOffers Type instead, which sets the typed name in a script face on the same baseline. This is the accessible path for people who cannot draw a signature (VoiceOver, motor impairments), so turn it off only when your flow offers another way to sign.
styleColors, ink weight, corner radius and pad height. Defaults to the SwiftPieces house palette, adapting to light and dark.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add SignaturePad

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Signature Pad" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All inputs and forms →

Build it yourself: SwiftUI haptics guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

Explore Pro