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

rc-input-component

v1.0.0

Published

A customizable React Input component with various types and variations, supporting dark mode and theme management.

Downloads

10

Readme

Rc Input Component

A highly customizable, accessible, and feature-rich React input component library with support for multiple input types, states, and themes.

NPM Version License: MIT

✨ Features

  • 🎨 13 input types: Text, Password, Email, Number, Date, Time, DateTime-Local, Month, Search, URL, Telephone, File, and Textarea
  • 🖌️ 6 customizable variants: Normal, Floating Label, Outlined, Filled, Underlined, Rounded
  • 🚦 8 different states: Default, Hover, Focus, Disabled, Read-Only, Error, Success, Loading
  • 🌓 Dark mode support
  • 🎭 Themeable with CSS variables
  • ♿ Accessibility-friendly
  • 📏 TypeScript support
  • 📁 File input with drag and drop support and file preview
  • 🛠️ Extensive customization options

🚀 Installation

npm install rc-input-component

🏁 Quick Start

Wrap your app with the ThemeProvider:

import { ThemeProvider } from 'rc-input-component';

function App() {
  return (
    <ThemeProvider>
      {/* Your app components */}
    </ThemeProvider>
  );
}

Use the input components in your React components:

import { TextInput, EmailInput, PasswordInput } from 'rc-input-component';

function MyForm() {
  return (
    <form>
      <TextInput label="Name" placeholder="Enter your name" />
      <EmailInput 
        label="Email Address" 
        placeholder="Enter your email"
        helpText="We will never share your email."
        icon={<EmailIcon />}
        clearable={true}
        validationMessage="Please enter a valid email."
        characterLimit={255}
        prefix="@"
        suffix=".com"
        autocomplete="email"
        variant="floating"
        inputState="error"
      />
      <PasswordInput label="Password" placeholder="Enter your password" />
    </form>
  );
}

🧩 Available Components

  • <TextInput />
  • <PasswordInput />
  • <EmailInput />
  • <NumberInput />
  • <DateInput />
  • <TimeInput />
  • <DateTimeInput />
  • <MonthInput />
  • <SearchInput />
  • <UrlInput />
  • <TelephoneInput />
  • <FileInput />
  • <TextareaInput />

🎨 Customization

Variants

  • normal: Standard input field
  • floating: Placeholder transitions to floating label on focus/input
  • outlined: Input with a pronounced border
  • filled: Input with a solid background color
  • underlined: Minimalist design with only a bottom border
  • rounded: Input with rounded corners
<TextInput variant="floating" label="Username" />

States

  • default: Standard state
  • hover: Styles applied on hover
  • focus: Styles applied when input is focused
  • disabled: Input is inactive
  • readonly: Content can be read but not edited
  • error: Displays validation errors
  • success: Indicates correct input
  • loading: Shows a loading state
<TextInput inputState="error" validationMessage="This field is required" />

Additional Features

  • icon: Add an icon inside the input
  • clearable: Add a clear button to reset input
  • characterLimit: Set and display character limit
  • prefix/suffix: Add text or icons at the start/end of input
  • mask: Format input in a specific pattern
<TextInput 
  icon={<UserIcon />}
  clearable={true}
  characterLimit={50}
  prefix="$"
  suffix=".00"
  mask={(value) => value.replace(/\D/g, '')}
/>

🔧 Props

The Input Component accepts the following props:

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value | | wrapperStyle | React.CSSProperties | undefined | Custom styles for the wrapper element | | inputStyle | React.CSSProperties | undefined | Custom styles for the input element | | labelStyle | React.CSSProperties | undefined | Custom styles for the label | | helpTextStyle | React.CSSProperties | undefined | Custom styles for the help text | | validationMessageStyle | React.CSSProperties | undefined | Custom styles for the validation message | | characterCountStyle | React.CSSProperties | undefined | Custom styles for the character count | | prefixStyle | React.CSSProperties | undefined | Custom styles for the prefix | | suffixStyle | React.CSSProperties | undefined | Custom styles for the suffix | | customClasses | object | {} | Custom CSS classes for various parts of the component |

Additionally, the Input Component accepts all standard HTML input attributes.

🔧 Props for Each Input Component

Below are tables listing the props for each individual input component. Note that all components also accept standard HTML attributes corresponding to their input types.

TextInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value |

PasswordInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value | | showPasswordToggle | boolean | true | Whether to show the password toggle button |

EmailInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value |

NumberInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value | | min | number | undefined | The minimum value allowed | | max | number | undefined | The maximum value allowed | | step | number | undefined | The step value for the number input |

DateInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | min | string | undefined | The minimum date allowed | | max | string | undefined | The maximum date allowed |

TimeInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | step | number | undefined | The step value for the time input (in seconds) |

DateTimeInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | min | string | undefined | The minimum date and time allowed | | max | string | undefined | The maximum date and time allowed | | step | number | undefined | The step value for the time part (in seconds) |

MonthInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | min | string | undefined | The minimum month allowed | | max | string | undefined | The maximum month allowed |

SearchInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value | | showSearchIcon | boolean | true | Whether to show the search icon |

UrlInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value |

TelephoneInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | icon | React.ReactNode | undefined | Icon to display inside the input | | clearable | boolean | false | Whether to show a clear button | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | prefix | React.ReactNode | undefined | Content to display before the input | | suffix | React.ReactNode | undefined | Content to display after the input | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | mask | (value: string) => string | undefined | Function to mask/format the input value |

FileInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | validationMessage | React.ReactNode | undefined | Validation or error message | | variant | 'normal' | 'floating' | 'outlined' | 'filled' | 'underlined' | 'rounded' | 'normal' | Visual variant of the input | | inputState | 'default' | 'hover' | 'focus' | 'disabled' | 'readonly' | 'error' | 'success' | 'loading' | 'default' | Current state of the input | | onValidate | (value: string) => string | null | undefined | Custom validation function | | accept | string | undefined | File types to accept | | multiple | boolean | false | Whether to allow multiple file selection | | preview | boolean | false | Whether to show file preview | | fileUploadText | React.ReactNode | undefined | Text to display for file upload |

TextareaInput

| Prop Name | Type | Default | Description | |-----------|------|---------|-------------| | label | React.ReactNode | undefined | Label for the input field | | helpText | React.ReactNode | undefined | Additional help text displayed below the input | | validationMessage | React.ReactNode | undefined | Validation or error message | | characterLimit | number | undefined | Maximum number of characters allowed | | variant | 'normal' | 'floating' | 'outlined' | 'filled' \

Usage Example

<Input
  label="Username"
  helpText="Enter your username or email"
  icon={<UserIcon />}
  clearable={true}
  validationMessage="Username is required"
  characterLimit={50}
  prefix="@"
  suffix=".com"
  variant="outlined"
  inputState="default"
  onValidate={(value) => value.length < 3 ? "Username too short" : null}
  mask={(value) => value.toLowerCase()}
  wrapperStyle={{ marginBottom: '20px' }}
  inputStyle={{ fontWeight: 'bold' }}
/>

This example demonstrates many of the available props. Adjust as needed for your specific use case.

🎭 Theming

Customize the theme by passing a theme object to the ThemeProvider:

import { ThemeProvider, lightTheme } from 'rc-input-component';

const customTheme = {
  ...lightTheme,
  colors: {
    ...lightTheme.colors,
    primary: '#007bff',
    secondary: '#6c757d',
  },
};

function App() {
  return (
    <ThemeProvider initialTheme="light" theme={customTheme}>
      {/* Your app components */}
    </ThemeProvider>
  );
}

♿ Accessibility

  • Every input has an associated label
  • Keyboard navigation support
  • ARIA attributes for enhanced screen reader support
  • Clear error identification for users with disabilities

🛠️ Development

To start the development server:

npm run dev

To build the package:

npm run build

📄 License

MIT

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📚 Documentation

For full documentation and a showcase of all input variations, clone this repository and run:

npm run dev

This will start a development server with a showcase page demonstrating all input types, variations, and states.


Made with ❤️ by Debraj Karmakar