@docuseal/signature-maker-js

中文文档
1.1.1发布于 2026/11/09MITTypeScriptESM + CJS近 30 天下载 4.1万

JS library for drawing, typing and uploading signatures

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

Signature Maker

Signature Maker JS

Web component that lets users draw, type or upload their signature and returns it as a PNG.

Live demo · Documentation · React · Vue

Installation

npm install @docuseal/signature-maker-js
# or
yarn add @docuseal/signature-maker-js
import '@docuseal/signature-maker-js'

Importing the package registers the <signature-maker> element. The import is safe in server-side rendered apps. Without a bundler, load it from a CDN:

<script src="https://cdn.jsdelivr.net/npm/@docuseal/signature-maker-js@1/dist/index.cjs.js"></script>

Usage

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

<signature-maker data-download-on-save="true"></signature-maker>

Handle the signature when the user clicks Submit:

<signature-maker id="signatureMaker"></signature-maker>

<script>
  signatureMaker.addEventListener('save', (e) => {
    fetch('/save-signature', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ file: e.detail.base64 }),
    })
  })
</script>

Embed in a form without the Submit button. A nested file input receives the PNG on every change:

<form method="POST" action="/submit-form">
  <input name="name" type="text">
  <signature-maker data-with-submit="false">
    <input type="file" name="signature">
  </signature-maker>
  <button type="submit">Submit</button>
</form>

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

<signature-maker
  class="block my-8"
  data-save-button-text="Télécharger"
  data-undo-button-text="Annuler"
  data-clear-button-text="Clair"
  data-draw-type-button-text="Dessiner"
  data-text-type-button-text="Type"
  data-upload-type-button-text="Télécharger"
  data-text-input-placeholder="Tapez votre signature ici"
  data-type-buttons-container-class="flex gap-2 mb-4 justify-center"
  data-draw-type-button-class="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"
  data-draw-type-button-active-class="bg-neutral text-white font-semibold"
  data-text-type-button-class="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"
  data-text-type-button-active-class="bg-neutral text-white font-semibold"
  data-upload-type-button-class="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"
  data-upload-type-button-active-class="bg-neutral text-white font-semibold"
  data-text-input-class="input mb-4 input-bordered bg-white text-2xl w-full h-14 rounded-2xl"
  data-canvas-class="bg-white border border-base-300 rounded-2xl w-full"
  data-undo-button-class="btn btn-outline btn-sm font-medium"
  data-clear-button-class="btn btn-outline btn-sm font-medium"
  data-save-button-class="btn btn-neutral text-white text-base w-full"
>
</signature-maker>

Events

EventWhene.detail
saveSubmit button clicked{ base64, blob }
changeSignature drawn, typed, uploaded or cleared{ base64, blob }, both null when empty

The element also exposes enableDrawPanel(), enableTextPanel(), enableUploadPanel() and the underlying signature_pad instance as pad. TypeScript declarations are included; the payload type is SignatureDetail:

import type { SignatureDetail } from '@docuseal/signature-maker-js'

el.addEventListener('save', (e: CustomEvent<SignatureDetail>) => console.log(e.detail.base64))

Attributes

Behavior:

AttributeDefaultDescription
data-with-drawntrueShow the Draw tab
data-with-typedtrueShow the Type tab
data-with-uploadtrueShow the Upload tab
data-with-color-selecttrueShow the pen color picker
data-with-submittrueShow the Submit button
data-download-on-savefalseDownload the PNG on Submit
data-font-urlDancing ScriptWOFF font used for typed signatures

Labels: data-save-button-text, data-undo-button-text, data-clear-button-text, data-draw-type-button-text, data-text-type-button-text, data-upload-type-button-text, data-text-input-placeholder.

Styles: every element below accepts data-<element>-class and data-<element>-style. A class replaces the default inline styles, a style overrides them. State variants are appended to the base class or style.

ElementState variants
save-buttondisabled-class, disabled-style
draw-type-button, text-type-button, upload-type-buttonactive-class, active-style
undo-button, clear-button, text-input, canvas, type-buttons-container, control-buttons-container

Example: data-draw-type-button-class="tab" plus data-draw-type-button-active-class="tab-active" renders class="tab tab-active" while Draw is selected.

License

MIT

版本与发布记录

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

版本发布日期距今
1.1.1latest2026/11/094 天前
1.1.02026/11/094 天前
1.0.12024/11/032 年前
1.0.02024/09/172 年前

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

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

JS library for drawing, typing and uploading signatures

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

在项目目录运行 npm install @docuseal/signature-maker-js,或使用 pnpm add / yarn add / bun add。

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

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

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

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

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

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

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

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

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

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

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

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