0.0.6 • Published 6 months ago

react-minimal-signature v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

react-minimal-signature

npm version License: ISC

A minimal and easy to use Signature Pad component for React applications, requires React version 18 or above.

Under the hood it utilizes Ark UI, a headless UI component library.

Features

  • 🚀 Easy to use and integrate
  • 🎨 Fully customizable
  • 🔧 TypeScript support

Demo

Live Demo

Installation

To install the library, you can use npm, yarn or any other package manager:

# npm
npm install react-minimal-signature

# yarn
yarn add react-minimal-signature

Usage

Simple

import { ReactMinimalSignature } from "react-minimal-signature";
// Import required styles
import "react-minimal-signature/rmc.css";

function App() {
  return <ReactMinimalSignature label="Sign here" />;
}

export default App;

Render image preview

import { useState } from "react";
import { ReactMinimalSignature } from "react-minimal-signature";
import "react-minimal-signature/rmc.css";

function App() {
  const [imageUrl, setImageUrl] = useState("");
  const [drawing, setDrawing] = useState<Boolean>(false);
  return (
    <>
      <ReactMinimalSignature
        onDraw={() => setDrawing(true)}
        onDrawEnd={(details) => {
          setDrawing(false);
          details.getDataUrl("image/png").then((url) => setImageUrl(url));
        }}
      />

      {drawing && <span>Drawing...</span>}
      {imageUrl && <img src={imageUrl} alt="Signature" />}
    </>
  );
}

export default App;

API Reference

PropTypeDefaultDescription
labelstringVisible label for the Signature Pad
withClearTriggerbooleantrueBoolean to handle the visibility of Clear trigger/button
withGuidebooleantrueBoolean to handle the visibility of guide line
onDraw(details: DrawDetails) => voidCallback when the signature pad is drawing.
onDrawEnd(details: DrawEndDetails) => voidCallback when the signature pad is done drawing.
getRootNode() => ShadowRoot \| Node \| DocumentA root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.
drawingDrawingOptions{ size: 2, simulatePressure: true }The drawing options.
disabledbooleanWhether the signature pad is disabled.
classNames{root?: string; label?: string; control?: string; clearTrigger?: string; guide?: string;}{}Add custom classnames to respective DOM nodes.

Contributing

Any improvements or suggestions are welcome. Feel free to open an issue or submit a pull request.

License

ISC

0.0.6

6 months ago

0.0.5

8 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago