@docuseal/signature-maker-react

中文文档
1.1.0发布于 2026/11/11MITTypeScriptESM + CJS近 30 天下载 3.9万

React component for drawing, typing and uploading signatures

原始使用文档
文档目录5 节
  1. Installation
  2. Usage
  3. Events
  4. Props
  5. License

Signature Maker

Signature Maker React

React component that lets users draw, type or upload their signature and returns it as a PNG. A thin wrapper around the signature-maker-js web component.

Live demo · Documentation · JS · Vue

Installation

npm install @docuseal/signature-maker-react
# or
yarn add @docuseal/signature-maker-react

Requires React 18 or 19. Works with server-side rendering.

Usage

No handlers needed: the Submit button downloads the signature as a PNG.

import { SignatureMaker } from '@docuseal/signature-maker-react'

export function App() {
  return <SignatureMaker downloadOnSave={true} />
}

Handle the signature when the user clicks Submit:

import { SignatureMaker } from '@docuseal/signature-maker-react'

export function App() {
  const handleSave = (detail) => {
    fetch('/save-signature', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ file: detail.base64 }),
    })
  }

  return <SignatureMaker onSave={handleSave} />
}

Embed in a form without the Submit button and track every change:

import { useState } from 'react'
import { SignatureMaker } from '@docuseal/signature-maker-react'

export function App() {
  const [signatureBase64, setSignatureBase64] = useState(null)

  const handleSubmit = (event) => {
    event.preventDefault()

    fetch('/submit-form', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ name: event.target.name.value, signature: signatureBase64 }),
    })
  }

  return (
    <form onSubmit={handleSubmit}>
      <input name="name" type="text" />
      <SignatureMaker withSubmit={false} onChange={(detail) => setSignatureBase64(detail.base64)} />
      <button type="submit">Submit</button>
    </form>
  )
}

Restyle with CSS classes and translate the labels. A full DaisyUI example:

import React from 'react'
import { SignatureMaker } from '@docuseal/signature-maker-react'

export function App() {
  return (
    <div className="app">
      <SignatureMaker
        className="block my-8"
        saveButtonText="Télécharger"
        undoButtonText="Annuler"
        clearButtonText="Clair"
        drawTypeButtonText="Dessiner"
        textTypeButtonText="Type"
        uploadTypeButtonText="Télécharger"
        textInputPlaceholder="Tapez votre signature ici"
        typeButtonsContainerClass="flex gap-2 mb-4 justify-center"
        drawTypeButtonClass="flex items center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold"
        drawTypeButtonActiveClass="bg-neutral text-white font-semibold"
        textTypeButtonClass="flex items center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold"
        textTypeButtonActiveClass="bg-neutral text-white font-semibold"
        uploadTypeButtonClass="flex items center justify-center py-3 w-40 uppercase border-neutral-focus space-x-2 border rounded-3xl cursor-pointer hover:bg-neutral hover:text-white hover:font-semibold"
        uploadTypeButtonActiveClass="bg-neutral text-white font-semibold"
        textInputClass="input mb-4 input-bordered bg-white text-2xl w-full h-14 rounded-2xl"
        canvasClass="bg-white border border-base-300 rounded-2xl w-full"
        undoButtonClass="btn btn-outline btn-sm font-medium"
        clearButtonClass="btn btn-outline btn-sm font-medium"
        saveButtonClass="btn btn-neutral text-white text-base w-full"
      />
    </div>
  );
}

Events

PropWhenArgument
onSaveSubmit button clicked{ base64, blob }
onChangeSignature drawn, typed, uploaded or cleared{ base64, blob }, both null when empty

ref gives access to the underlying element with enableDrawPanel(), enableTextPanel(), enableUploadPanel() and the signature_pad instance as pad. TypeScript declarations are included:

import { useRef } from 'react'
import { SignatureMaker, type SignatureDetail, type SignatureMakerElement } from '@docuseal/signature-maker-react'

const ref = useRef<SignatureMakerElement>(null)
const handleSave = (detail: SignatureDetail) => console.log(detail.base64)

<SignatureMaker ref={ref} onSave={handleSave} />

Props

Behavior:

PropDefaultDescription
withDrawntrueShow the Draw tab
withTypedtrueShow the Type tab
withUploadtrueShow the Upload tab
withColorSelecttrueShow the pen color picker
withSubmittrueShow the Submit button
downloadOnSavefalseDownload the PNG on Submit
fontUrlDancing ScriptWOFF font used for typed signatures
className, styleApplied to the <signature-maker> element itself

Labels: saveButtonText, undoButtonText, clearButtonText, drawTypeButtonText, textTypeButtonText, uploadTypeButtonText, textInputPlaceholder.

Styles: every element below accepts <element>Class and <element>Style (a CSS string). A class replaces the default inline styles, a style overrides them. State variants are appended to the base class or style.

ElementState variants
saveButtonsaveButtonDisabledClass, saveButtonsDisabledStyle
drawTypeButton, textTypeButton, uploadTypeButtonActiveClass, ActiveStyle
undoButton, clearButton, textInput, canvas, typeButtonsContainer, controlButtonsContainer

Example: drawTypeButtonClass="tab" plus drawTypeButtonActiveClass="tab-active" renders class="tab tab-active" while Draw is selected.

License

MIT

版本与发布记录

@docuseal/signature-maker-react 共发布 4 个版本,首次发布于 2024/09/17;过去 12 个月发布了 1 个版本。

版本发布日期距今
1.1.0latest2026/11/112 天前
1.0.22024/11/032 年前
1.0.12024/09/262 年前
1.0.02024/09/172 年前

关于 @docuseal/signature-maker-react 的常见问题

@docuseal/signature-maker-react 是什么?

React component for drawing, typing and uploading signatures

如何安装 @docuseal/signature-maker-react?

在项目目录运行 npm install @docuseal/signature-maker-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18.0.0 || ^19.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@docuseal/signature-maker-react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@docuseal/signature-maker-react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@docuseal/signature-maker-react 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@docuseal/signature-maker-react 可以商用吗?

@docuseal/signature-maker-react 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@docuseal/signature-maker-react 的下载量有多少?

根据 npm 官方下载统计,@docuseal/signature-maker-react 在 2026/10/13 – 2026/11/11 这 30 天内被下载 38,919 次,日均约 1,297 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@docuseal/signature-maker-react 还在维护吗?

最新版本 1.1.0 发布于 2026/11/11(2 天前);至今共发布 4 个版本,其中过去 12 个月发布了 1 个;首次发布于 2024/09/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。