JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q29327F

PIN code Component for React

Package Exports

  • @prkhch/react-pincode
  • @prkhch/react-pincode/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@prkhch/react-pincode) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Quick Start

PIN code Component for React

npm install @prkhch/react-pincode
import { Pincode } from "@prkhch/react-pincode";

function App() {
  const onComplete = ({ inputValue, setMessage, setErrorMessage }) => {
    // Request correct password from the server.
    // Example correct password : 0000
    if (inputValue === "0000") {
      setMessage("Correct!");
      setErrorMessage("");
    }

    if (inputValue !== "0000") {
      setMessage("");
      setErrorMessage("InCorrect!");
    }
  };

  return (
    <div>
      <Pincode
        onComplete={onComplete}
        // randomKeypad={true}
        length={4}
        defaultMessage="Enter PIN"
        // styleBottomLayout={true}
        styleBackgroundColor="#ffffff"
        styleBackgroundOpacity={1}
        styleMessageColor="#000000"
        styleErrorMessageColor="#ff0000"
        styleInputBoxColor="#efefef"
        styleInputCircleColor="#000000"
        styleNumberFontColor="#000000"
        styleNumberButtonColor="#efefef"
        styleResetButtonColor="#000000"
        styleDeleteButtonColor="#000000"
        styleHoverColor="#bbbbbb"
      />
    </div>
  );
}

export default App;

Options

* : Required
Name Description Default Type
*onComplete Callback function when input is complete - function
randomKeypad Randomizes the number pad false boolean
length Length of the password 4 (4~8) number
defaultMessage Default message displayed - string
styleBottomLayout Enable/disable bottom layout style false boolean
styleBackgroundColor Background color of the component - string
styleBackgroundOpacity Opacity of the background 1 (0~1) number
styleMessageColor Text color for the message - string
styleErrorMessageColor Text color for the error message - string
styleInputBoxColor Color of the input box - string
styleInputCircleColor Color of the input circles - string
styleNumberFontColor Color of the number fonts - string
styleNumberButtonColor Color of the number buttons - string
styleResetButtonColor Color of the reset button - string
styleDeleteButtonColor Color of the delete button - string
styleHoverColor Hover color for the buttons - string

onComplete Function

  • *inputValue: The PIN entered by the user.
  • setMessage: Function to display a message.
  • setErrorMessage: Function to display an error message.

The onComplete function is called when the user finishes entering their PIN. It checks the PIN and, depending on whether it's correct or not, executes a user-defined event.

Example

Default Bottom Layout
Default BottomLayout
Random Keypad Customizing
Random Keypad Customizing