New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-code-input-beautify

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-code-input-beautify

This React package allows you to easily add a code input component to your applications. It provides maximum and flexible functionality, helping you to make the UX more engaging and accessible for users, without unnecessary effort.

latest
Source
npmnpm
Version
0.0.7
Version published
Weekly downloads
1
Maintainers
0
Weekly downloads
 
Created
Source

CodeInput Component

CodeInput is a flexible React component that provides a customizable input for entering multi-character codes (e.g., OTP, verification codes). You can control the number of input fields, allowed characters, and easily manage input through callbacks for change and submission.

Installation

To install the package, use npm or yarn:

npm install react-code-input-beautify
# or
yarn add react-code-input-beautify

Usage

import React, { useState } from "react";
import { CodeInput } from "react-code-input-beautify";
import "./index.css";

const App = () => {
  const [code, setCode] = useState("");

  const handleChange = (value) => {
    setCode(value);
  };

  const handleSubmitEndCode = (value) => {
    console.log("Submitted Code:", value);
  };

  return (
    <CodeInput
      fields={6}
      value={code}
      onChange={handleChange}
      onSubmitEndCode={handleSubmitEndCode}
      condition="alphanumeric"
      classNameInput="example-classname-for-inputs"
      classNameInputsWrapper="example-classname-for-inputs-wrapper"
      typeLetterCase="upperCase"
      placeholder="______"
    />
  );
};

export default App;

Props

PropTypeDefaultDescription
fieldsnumberRequiredNumber of input fields (length of the code).
valuestringRequiredThe current value of the input.
onChange(value: string) => voidRequiredCallback for when the input value changes.
onSubmitEndCode(value: string) => voidOptionalCallback triggered when the last character is entered, provided that all fields are also entered
classNameInputstring""Custom class name for each input field.
classNameInputsWrapperstring""Custom class name for the input wrapper div.
condition"numbers", "letters", "alphanumeric", "any", RegExp"any"Condition that defines what type of characters are allowed.
typeLetterCase"upperCase", "lowerCase", "any""any"Specifies whether the input should be in uppercase or lowercase.
placeholderstring""Placeholder to show in the inputs.
InputsPropsReact.InputHTMLAttributes<HTMLInputElement>{}Additional props to pass to each input element.
WrapperPropsReact.HTMLAttributes<HTMLDivElement>{}Additional props to pass to the wrapper element.

Keywords

code

FAQs

Package last updated on 23 Sep 2024

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