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-signature-library

v1.0.3

Published

Lightweight and customizable React signature pad component

Readme

✍️ React Signature Library

A lightweight and customizable React signature pad component built using signature_pad.

🚀 Features

  • Undo / Redo
  • Clear Signature
  • Download as Image
  • Controlled & Uncontrolled Modes
  • Custom Menu UI (renderMenu)
  • Full Styling Control
  • Base64 & Blob Export
  • Internal CSS (No setup required)

📦 Installation

npm install react-signature-library

🧑‍💻 Usage (useRef)

import { useRef } from "react";
import { Signature } from "react-signature-library";

function App() {
  const sigRef = useRef(null);

  const handleSubmit = async () => {
    const base64 = sigRef.current.getSignatureBase64();
    const blob = await sigRef.current.getSignatureBlob();

    console.log(base64, blob);
  };

  return (
    <div>
      <Signature ref={sigRef} />
      <button onClick={handleSubmit}>Submit</button>
    </div>
  );
}

🔁 Usage (Controlled)

import { useState } from "react";
import { Signature, dataURLtoBlob } from "react-signature-library";

function App() {
  const [signature, setSignature] = useState("");

  const handleSubmit = () => {
    const blob = dataURLtoBlob(signature);
    console.log(blob);
  };

  return (
    <>
      <Signature value={signature} onChange={setSignature} />
      <button onClick={handleSubmit}>Submit</button>
    </>
  );
}

🎨 Custom Menu

You can fully customize the menu UI using the renderMenu prop.

This gives you complete control over:

Actions (Undo, Redo, Clear, Download) Colors (Pen & Background) Stroke width Menu visibility

<Signature value={signature} onChange={setSignature} 
        renderMenu={({
          undo,
          redo,
          clear,
          download,
          penColor,
          bgColor,
          strokeWidth,
          setPenColor,
          setBgColor,
          setStrokeWidth,
        }) => (
          <div style={{ marginBottom: "10px" }}>
            
            {/* ACTION BUTTONS */}
            <div style={{ display: "flex", gap: "10px", marginBottom: "10px" }}>
              <button type="button" onClick={undo}>Undo</button>
              <button type="button" onClick={redo}>Redo</button>
              <button type="button" onClick={clear}>Clear</button>
              <button type="button" onClick={download}>Download</button>
            </div>

            {/* COLOR CONTROLS */}
            <div style={{ display: "flex", gap: "10px", marginBottom: "10px" }}>
              <label>
                Pen:
                <input
                  type="color"
                  value={penColor}
                  onChange={(e) => setPenColor(e.target.value)}
                />
              </label>

              <label>
                Background:
                <input
                  type="color"
                  value={bgColor}
                  onChange={(e) => setBgColor(e.target.value)}
                />
              </label>
            </div>

            {/* STROKE CONTROL */}
            <div style={{ marginBottom: "10px" }}>
              <label>
                Stroke: {strokeWidth}
                <input
                  type="range"
                  min="1"
                  max="10"
                  value={strokeWidth}
                  onChange={(e) =>
                    setStrokeWidth(Number(e.target.value))
                  }
                />
              </label>
            </div>
          </div>
        )}>
          
</Signature>

🎮 Ref API

const sigRef = useRef(null);

sigRef.current.undo();
sigRef.current.redo();
sigRef.current.clear();
sigRef.current.download();
sigRef.current.isEmpty();
const base64 = sigRef.current.getSignatureBase64();
const blob = await sigRef.current.getSignatureBlob();

/>

🧰 Utility

import { dataURLtoBlob } from "react-signature-library";
const blob = dataURLtoBlob(base64);

🌐 Backend Integration (Upload Signature)

You can send the signature to your backend using Base64 or Blob.

📌 Upload as Blob (Recommended)

const blob = await sigRef.current.getSignatureBlob();

const formData = new FormData();
formData.append("signature", blob, "signature.png");

await fetch("http://localhost:5000/upload-blob", {
  method: "POST",
  body: formData
});

📌 Upload as Base64

const base64 = sigRef.current.getSignatureBase64();

await fetch("http://localhost:5000/upload-base64", {
  method: "POST",
  headers: {
    "Content-Type": "application/json"
  },
  body: JSON.stringify({ signature: base64 })
});

🎨 Styling Options

Pass custom class names to target specific parts of the component:

<Signature
  className="wrapper"        // Main container
  canvasClass="canvas"      // Canvas element
  menuClass="menu-icon"     // Menu toggle icon
  buttonClass="btn"         // Buttons inside menu
/>

| Prop | Description | | ------------- | -------------------------------------------------- | | className | Wrapper container of the signature pad | | canvasClass | Canvas element where drawing happens | | menuClass | Menu toggle (☰ icon) styling | | buttonClass | Buttons inside the default menu (Undo, Redo, etc.) |

🎨 Using Inline Style

You can directly apply styles to the canvas:

<Signature
  style={{ border: "2px solid red", borderRadius: "12px" }}
/>

🎨 Using CSS Variables

Customize default UI colors using built-in CSS variables:

.rsl-signature-menu {
  --rsl-menu-bg: #222;
}

.rsl-signature-menu button {
  --rsl-btn-bg: #444;
  --rsl-btn-color: #fff;
}

| Variable | Description | | ----------------- | ----------------------- | | --rsl-menu-bg | Menu background color | | --rsl-btn-bg | Button background color | | --rsl-btn-color | Button text color |

🙌 Author

Ravi Thakur