Ir al contenido
Español
Panel de firma viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

Strokes are stored as points with a width rather than as pixels. Coalesced pointer events give dense samples; each segment is a quadratic curve from midpoint to midpoint, and the width follows speed through a low-pass filter so it never steps. Because the data is kept, undo is exact, the canvas redraws sharply at any pixel ratio, the signature rescales when the pad changes width, and the ink colour follows the theme.

Úsalo para

  • Accepting a proposal, a delivery or a consent form where a drawn signature is expected.
  • Collecting a quick sketch or initials on a tablet or phone.

Busca otra opción cuando

  • A legally binding signature flow on its own: pair it with identity and audit steps on the server.
  • As the only way to confirm: always offer a typed-name or checkbox alternative for people who cannot draw.

Uso

import { useRef, useState } from 'react'
import { SignaturePad } from './SignaturePad.jsx'

export function SignStep() {
  const pad = useRef(null)
  const [empty, setEmpty] = useState(true)
  return (
    <>
      <SignaturePad ref={pad} height={180} onChange={(s) => setEmpty(s.isEmpty)} />
      <button disabled={empty} onClick={() => upload(pad.current.toSVG())}>
        Accept and sign
      </button>
    </>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
onChange({ isEmpty, strokes }) => void—Called after each stroke, undo or clear.
defaultStrokes[x, y][][]—Strokes to start with, as points normalised to the pad (0 to 1), such as a saved signature.
heightnumber180Pad height in px; the width fills the container and the drawing rescales with it.
minWidthnumber0.9Thinnest line, at fast strokes.
maxWidthnumber3.2Thickest line, at slow strokes; pen pressure can add up to 30%.
colorstring—Ink colour. By default the ink follows --ds-sign-ink, then --ds-text, so it flips with the theme.
baselinebooleantrueDraws the dashed line and × mark.
disabledbooleanfalseLocks the pad, for example after submitting.
labelsobject—Replaces built-in text: pad, hint, undo, clear, empty, signed, strokes(n).
ref{ undo, clear, isEmpty, toDataURL, toSVG }—Imperative handle: toDataURL(type) returns an image, toSVG() a resolution-free path drawing.

Accesibilidad

  • The canvas is a focusable role="img" whose label states whether it is signed and how many strokes it has.
  • Keyboard: Ctrl / Cmd+Z undoes the last stroke, Delete or Backspace clears. Drawing itself needs a pointer, so offer a typed alternative next to it.
  • Undo and Clear are real buttons, 32px high, hidden only while the pad is empty.
  • touch-action: none stops the page from scrolling while signing. Reduced motion removes the hint and tool fades.

Movimiento

Ink appears under the pen with no delay. The hint fades and rises 4px in 240ms when the first stroke starts; the tools fade in over 200ms once there is something to undo.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

SignaturePad.jsxsignature-pad.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Formularios
Cuadrícula de disponibilidad viene con Pro. La vista previa aparece al desbloquearlo.
Operaciones booleanas viene con Pro. La vista previa aparece al desbloquearlo.
Selector en cascada viene con Pro. La vista previa aparece al desbloquearlo.