Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-signature-canvas

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-signature-canvas

A signature pad implementation in React

  • 0.1.11
  • v0.1.x
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
283K
increased by5.03%
Maintainers
1
Weekly downloads
 
Created

What is react-signature-canvas?

The react-signature-canvas package is a React wrapper for the signature_pad library, which allows users to draw smooth signatures on a canvas element. It provides an easy way to integrate signature capture functionality into React applications.

What are react-signature-canvas's main functionalities?

Basic Signature Capture

This feature allows you to capture a signature on a canvas. The pen color is set to black, and the canvas dimensions are specified.

import React from 'react';
import SignatureCanvas from 'react-signature-canvas';

function SignaturePad() {
  return (
    <SignatureCanvas penColor='black' canvasProps={{width: 500, height: 200, className: 'sigCanvas'}} />
  );
}

export default SignaturePad;

Clear Signature

This feature allows you to clear the signature from the canvas. A button is provided to trigger the clear action.

import React, { useRef } from 'react';
import SignatureCanvas from 'react-signature-canvas';

function SignaturePad() {
  const sigCanvas = useRef(null);

  const clear = () => {
    sigCanvas.current.clear();
  };

  return (
    <div>
      <SignatureCanvas ref={sigCanvas} penColor='black' canvasProps={{width: 500, height: 200, className: 'sigCanvas'}} />
      <button onClick={clear}>Clear</button>
    </div>
  );
}

export default SignaturePad;

Save Signature as Image

This feature allows you to save the signature as an image. The signature is converted to a data URL, which can be used to display or store the image.

import React, { useRef } from 'react';
import SignatureCanvas from 'react-signature-canvas';

function SignaturePad() {
  const sigCanvas = useRef(null);

  const save = () => {
    const dataURL = sigCanvas.current.getTrimmedCanvas().toDataURL('image/png');
    console.log(dataURL);
  };

  return (
    <div>
      <SignatureCanvas ref={sigCanvas} penColor='black' canvasProps={{width: 500, height: 200, className: 'sigCanvas'}} />
      <button onClick={save}>Save</button>
    </div>
  );
}

export default SignaturePad;

Other packages similar to react-signature-canvas

Keywords

FAQs

Package last updated on 10 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc