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

react-input-library

v1.1.0

Published

A react lightweight and customizable input library

Downloads

8

Readme

# React Input Library

A customizable and reusable input component for React applications. This library provides a flexible `InputField` component that can be easily integrated into your projects.


## Installation

To install the library, use npm or yarn:

```bash
npm install react-input-library

or

yarn add react-input-library

Usage

Here's an example of how to use the InputField component in your React application:

Basic Usage

Import the InputField component and use it in your React application:

import React, { useState } from 'react';
import { InputField } from 'react-input-library ';

const MyForm = () => {
  const [name, setName] = useState('');

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

  return (
    <div>
      <InputField
        type="text"
        placeholder="Enter your name"
        value={name}
        onChange={handleChange}
      />
    </div>
  );
};

export default MyForm;

Props

The InputField component accepts the following props:

| Prop | Type | Description | Default | |-------------|------------------------------|--------------------------------------------------------|------------| | type | string | The type of the input field | text | | placeholder | string | The placeholder text for the input field | '' | | value | string | The value of the input field (controlled component) | '' | | onChange | (value: string) => void | Callback function called when the input value changes | - | | onBlur | (value: string) => void | Callback function called when the input loses focus | - | | onFocus | () => void | Callback function called when the input gains focus | - | | name | string | Name attribute for the input field | - | | id | string | ID attribute for the input field | - | | maxLength | number | Maximum length of the input field | - | | minLength | number | Minimum length of the input field | - | | disabled | boolean | Whether the input field is disabled | false | | readOnly | boolean | Whether the input field is read-only | false | | required | boolean | Whether the input field is required | false | | style | React.CSSProperties | Inline styles for the input field | - | | className | string | Additional CSS class for the input field | - |

InputField OTP Component

The InputField OTP component is designed to provide a customizable input field for entering OTP (One Time Password) codes. It allows users to enter digits one by one and handles navigation between input fields automatically.

Usage

Import OTPInput into your component and use it within your JSX:

import React, { useState } from 'react';
import {OTPInput} from 'react-input-library';

const MyComponent = () => {
  const [otpValue, setOtpValue] = useState('');

  const handleChange = (value: string) => {
    setOtpValue(value);
  };

  return (
    <div>
      <h2>Enter OTP</h2>
      <OTPInput
        length={6}
        value={otpValue}
        onChange={handleChange}
        size="md"
        gap="10px"
        error={false}
      />
    </div>
  );
};

export default MyComponent;

Props

| Prop | Type | Default | Description | |-----------------|------------------------------------|-----------|-------------------------------------------------------------------------------------------------------| | length | number | Required | The length of the OTP input fields | | value | string | Required | The current value of the OTP input | | onChange | (value: string) => void | Required | Function called when the OTP value changes | | onBlur | (value: string) => void | Optional | Function called when focus is removed from the OTP input | | onFocus | () => void | Optional | Function called when the OTP input is focused | | size | 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'md' | Size of the OTP input fields. One of 'sm', 'md', 'lg', 'xl', 'xxl'. | | gap | string | '8px' | Gap between OTP input fields | | error | boolean | false | Indicates whether there is an error state in the OTP input | | className | string | undefined | Additional CSS class to apply to the OTPInput component | | style | React.CSSProperties | undefined | Additional inline styles to apply to each OTP input field | | borderStyle | string | '1px solid black' | Border style of the OTP input fields | | errorBorderColor| string | 'red' | Border color of the OTP input fields when in error state |

Customization

The InputField OTP component can be customized in various ways:

  • Size: Adjust the size of the OTP input fields using the size prop ('sm', 'md', 'lg', 'xl', 'xxl').
  • Styling: Apply custom CSS classes (className) and inline styles (style) to the OTP input fields.
  • Error Handling: Set the error prop to true to indicate an error state, which can change the appearance of the OTP input fields (errorBorderColor).

Examples

Basic InputField.OTP Usage

<OTPInput
  length={6}
  value={otpValue}
  onChange={handleChange}
/>

Customized InputField.OTP with Error State

<OTPInput
  length={4}
  value={otpValue}
  onChange={handleChange}
  size="lg"
  gap="12px"
  error={true}
  errorBorderColor="darkred || #000000"
  style={{ backgroundColor: 'lightyellow' }}
  className="custom-otp-input"
/>

Development

To build the library locally, run:

npm run build

Contributing

We welcome contributions! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature-name)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add new feature')
  5. Push to the branch (git push origin feature/your-feature-name)
  6. Create a new Pull Request

Please make sure to update tests as appropriate.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

[Awah Bright] - [https://github.com/Beemhuse/react-input-library.git/] - [[email protected]]