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 🙏

© 2024 – Pkg Stats / Ryan Hefner

signature-pad-package

v1.0.4

Published

A lightweight, customizable signature pad component for React, built with TypeScript. Capture user signatures, save them as images, clear the pad, and optionally download them in jpeg and png formats. Good for e-signatures applications.

Downloads

9

Readme

React Signature Pad

A lightweight, customizable signature pad component for React, built with TypeScript. Capture user signatures, save them as images, clear the pad, and optionally download them in jpeg and png formats. Good for e-signatures applications.

Screenshots

Screenshots

Features

  • Simple and Lightweight: Easily capture user signatures.
  • Customizable: Adjust pen color, canvas dimensions, icons, and more.
  • Cross-device Support: Works with both mouse and touch events (desktop and mobile).
  • Save, Clear, and Download: Save the signature, clear the pad, or download the signature as an image.
  • Stylable: Customize the appearance of the signature pad and the icons for actions.

Installation

Install the package using npm or yarn:

pnpm install signature-pad-package

Usage

Import the component into your React project and use it as follows:

Basic Usage

import React, { useState } from 'react';
import SignaturePad from 'signature-pad-package';

const App: React.FC = () => {
  const [signature, setSignature] = useState<string | null>(null);

  const handleSave = (dataURL: string) => {
    setSignature(dataURL); // Save the signature
  };

  return (
    <div>
      <h1>React Signature Pad</h1>
      <SignaturePad 
        width={500}
        height={300}
        onSave={handleSave}
        download={true}
        downloadFilename="my-signature"
        downloadFormat="image/png"
      />
      {signature && (
        <div>
          <h2>Your Signature:</h2>
          <img src={signature} alt="User signature" />
        </div>
      )}
    </div>
  );
};

export default App;

Advanced Usage with Additional Features

import React, { useState } from 'react';
import SignaturePad from 'signature-pad-package';

const App: React.FC = () => {
  const [signature, setSignature] = useState<string | null>(null);

  const handleSave = (dataURL: string) => {
    setSignature(dataURL); // Save the signature
  };

  return (
    <div>
      <h1>Advanced React Signature Pad</h1>
      <SignaturePad
        width={400}
        height={200}
        theme={dark}
        onSave={handleSave} // Custom handler to save the signature
        downloadFormat="image/jpeg" // Specify download format
        onDownload={() => console.log("Downloaded")} // Callback for download
        onClear={() => console.log("Cleared")} // Callback for clearing the canvas
        download={true} // Enable download button
        padStyles={{
          border: "1px solid #ccc",
          borderRadius: "10px",
        }} // Custom styling for the signature pad
        iconColor={{
          clear: "red",
          save: "green",
          download: "blue",
        }} // Custom icon colors for actions
      />
    </div>
  );
};

export default App;

Props

| Prop | Type | Default | Description | | ------------------- | ----------------- | --------------- | --------------------------------------------------------------------------- | | width | number | 500 | Width of the canvas (in pixels). | | height | number | 300 | Height of the canvas (in pixels). | | theme | 'dark' | 'light' | 'light' | Theme for the signature pad. | | | onSave | function(dataURL: string) | undefined | Callback that fires when the signature is copied (similar to onSave). | | onDownload | function() | undefined | Callback that triggers when the signature is downloaded. | | onClear | function() | undefined | Callback that triggers when the signature pad is cleared. | | download | boolean | false | Enables a download button to download the signature image. | | downloadFilename | string | 'signature' | Default filename when downloading the signature. | | downloadFormat | 'image/png' \| 'image/jpeg' | 'image/png' | Format of the downloaded image (PNG or JPEG). | | padStyles | object | undefined | Custom styles for the signature pad (e.g., border, border radius). | | iconColor | object | undefined | Customize the colors of the action icons (clear, save, download). |

Development

If you want to contribute or make changes to the package:

  1. Clone the repository:

    git clone https://github.com/unnikpanicker/react-signature-pad.git
  2. Install dependencies:

    pnpm install
  3. Run the development server:

    pnpm run dev
  4. Build the package:

    pnpm run build
  5. Test the package locally using a linked project:

    pnpm link

License

This project is licensed under the MIT License.