npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-digital-signature

v1.0.1

Published

A simple digital signature pad

Downloads

27

Readme

React Digital Signature

A React signature component using signature_pad and based on other libraries of the same functionality.

Installation

You can install the latest release using npm:

npm install --save react-digital-signature

or Yarn:

yarn add react-digital-signature

Usage TS

import { useRef } from 'react'
import './App.css'
import DigitalSignature, { SignaturePad } from 'react-digital-signature'

function App() {

  const ref = useRef<SignaturePad>()
  const handleCLear = () =>{
    ref.current?.clear()
  }
  return (
    <div className="App">
      <button onClick={handleCLear}>Clear</button>
        <br />
        <br />
      <DigitalSignature 
        signaturePadRef={ref}
        canvasProps={{
          style:{
            background:"white",
            border:"1px solid black"
          }
        }}
      />
    </div>
  )
}
export default App

Usage JS

import { useRef } from 'react'
import './App.css'
import DigitalSignature from 'react-digital-signature'

function App() {

  const ref = useRef()
  const handleCLear = () =>{
    ref.current?.clear()
  }
  return (
    <div className="App">
      <button onClick={handleCLear}>Clear</button>
        <br />
        <br />
      <DigitalSignature 
        signaturePadRef={ref}
        canvasProps={{
          style:{
            background:"white",
            border:"1px solid black"
          }
        }}
      />
    </div>
  )
}
export default App

Props <DigitalSignature />

| Prop | Type | Default Value | Description | |-----------------------|------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------| | velocityFilterWeight | number | 0.7 | Controls the weight/impact of velocity on the pen stroke. | | minWidth | number | 0.5 | Minimum width of the pen stroke. | | maxWidth | number | 2.5 | Maximum width of the pen stroke. | | minDistance | number | 5 | Minimum distance between two points to be considered as a valid stroke. | | dotSize | number or function | () => (min + max)/2 | The size of the dot that is placed at the beginning and end of each stroke. | | penColor | string | 'black' | Color of the pen stroke. | | throttle | number | 16 | The time in milliseconds between each mouse/touchmove event that is considered as a new stroke. | | onEnd | function | | A callback function that is called when a stroke ends. | | onBegin | function | | A callback function that is called when a stroke begins. | | canvasProps | object | | Props that are directly passed to the underlying <canvas /> element. | | backgroundColor | string | "rgba(0,0,0,0)" | Background color of the canvas element. | | eraseOnResize | bool | true | Whether or not the canvas should be cleared when the window resizes (Usually used on ios devices and browser with bottom navigation bar variable). |

Note: All props, except for canvasProps and eraseOnResize, are passed through to signature_pad as its options. If you want know more of the props of the component you can check the original docs

API

  • refDigitalPad.toDataURL(); Returns signature image as data URL (see https://mdn.io/todataurl for the list of possible parameters)

  • refDigitalPad.toDataURL("image/jpeg"); save image as PNG

  • refDigitalPad.toDataURL("image/jpeg", 0.5); save image as JPEG with 0.5 image quality

  • refDigitalPad.toDataURL("image/svg+xml"); save image as SVG data url

  • refDigitalPad.toSVG(); Return svg string without converting to base64

  • refDigitalPad.toSVG({includeBackgroundColor: true}); add background color to svg output

  • refDigitalPad.fromDataURL("data:image/png;base64,iVBORw0K..."); Draws signature image from data URL (mostly uses https://mdn.io/drawImage under-the-hood)

  • refDigitalPad.fromDataURL("data:image/png;base64,iVBORw0K...", { ratio: 1, width: 400, height: 200, xOffset: 100, yOffset: 50 }); Draws signature image from data URL and alters it with the given options

  • const data = refDigitalPad.toData(); Returns signature image as an array of point groups

  • refDigitalPad.fromData(data); Draws signature image from an array of point groups

  • refDigitalPad.fromData(data, { clear: false }); Draws signature image from an array of point groups, without clearing your existing image (clear defaults to true if not provided)

  • refDigitalPad.clear(); Clears the canvas

  • refDigitalPad.isEmpty(); Returns true if canvas is empty, otherwise returns false

  • refDigitalPad.off(); Unbinds all event handlers

  • refDigitalPad.on(); Rebinds all event handlers

You can use the API using a useRef() hook for example:

function App() {
  const refDigitalPad = useRef()
  const handleCLear = () =>{
    refDigitalPad.current?.clear()
  }
  return (
    <div className="App">
      <button onClick={handleCLear}>Clear</button>
        <br />
        <br />
      <DigitalSignature 
        signaturePadRef={refDigitalPad}
        canvasProps={{
          style:{
            background:"white",
            border:"1px solid black"
          }
        }}
      />
    </div>
  )
}

Example

If you want execute the example of the project:

cd example && npm install && npm run start

and navigate to http://localhost:1234/