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

decent-input

v1.0.0

Published

A customizable input field for React and Next.js

Downloads

2

Readme

This is a Next.js project

Getting Started

React Input Component

This is a highly customizable and feature-rich Input component for React applications. It's built with TypeScript and styled-components, providing a flexible and reusable input field that can be easily integrated into various projects.

Features

  • Multiple input types support (text, password, email, number, date, etc.)
  • Various visual variants (normal, outlined, filled, underlined, rounded, floating label)
  • Icon support
  • Prefix and suffix
  • Clearable input
  • Password visibility toggle
  • Loading state
  • Disabled and read-only states
  • Error, warning, and success states
  • Help text and validation messages
  • Character limit
  • Fully customizable styling
  • Theme configuration supported

Installation

To use this component in your project, you need to have React and styled-components installed. If you haven't already, install them:

React Input Component

| Prop | Type | Description | |---------------------|---------------------|--------------------------------------------------------| | type | string | Input type (e.g., 'text', 'password', 'email', 'number', etc.) | | label | string | Label text for the input | | placeholder | string | Placeholder text for the input | | isLoading | boolean | Whether the input is in a loading state | | variant | string | Visual style variant ('normal', 'outlined', 'filled', 'underlined', 'rounded', 'floating') | | isDisabled | boolean | Whether the input is disabled | | isReadOnly | boolean | Whether the input is read-only | | isError | boolean | Whether the input is in an error state | | isWarning | boolean | Whether the input is in a warning state | | isSuccess | boolean | Whether the input is in a success state | | icon | React.ReactNode | Icon component to display with the input | | prefix | string | Text or symbol to display before the input | | suffix | string | Text or symbol to display after the input | | clearable | boolean | Whether the input can be cleared | | helpText | string | Additional help text to display below the input | | characterLimit | number | Maximum number of characters allowed | | validationMessage | string | Message to display for validation states (error, warning, success) | | value | string | Controlled value for the input | | onChange | function | Function to handle input changes |

Example


'use client'
import React, { useState } from 'react';
import { ThemeProvider } from 'styled-components';
import { Input, defaultDarkTheme, defaultLightTheme } from 'decent-input';
import { FaUser } from 'react-icons/fa';
import { RiGitRepositoryPrivateFill } from "react-icons/ri";

const MyForm = () => {

 /// theme state
 const [isDarkTheme, setIsDarkTheme] = useState(true);

 /// Change the theme
 const toggleTheme = () => {
   setIsDarkTheme(!isDarkTheme);
 };

 /// Set the theme
 const currentTheme = isDarkTheme ? defaultDarkTheme : defaultLightTheme;


 return (
   <ThemeProvider theme={currentTheme}>
     <div style={{ backgroundColor: currentTheme.primaryColor }} className='w-full min-h-screen flex flex-col justify-center items-center pt-20 transition-colors duration-300'>


       <div className='w-[90%] sm:w-[500px] md:w-[600px] xl:w-[30%]'>
         <h1 style={{ color: currentTheme.secondaryColor }} className='text-[22px] md:text-3xl font-bold mb-8 transition-colors duration-300 text-center'>Form Using decent-input</h1>

           <div style={{ backgroundColor: currentTheme.inputBackgroundColor }} className='w-full p-6 rounded-xl shadow-2xl flex flex-col gap-6 transition-colors duration-300'>
             <Input
               value="Enter User Name"
               type="text"
               name="userName"
               label="User Name"
               placeholder="Enter Your email"
               suffix='.com'
               icon={<FaUser />}
               setTheme={isDarkTheme ? 'dark' : 'light'}
             />

             <Input
               value="12345678"
               type="password"
               name="password"
               label="Password"
               placeholder="Enter your Password"
               icon={<RiGitRepositoryPrivateFill />}
               setTheme={isDarkTheme ? 'dark' : 'light'}
             />

             <button 
               type="submit" 
               className={`${isDarkTheme ? 'bg-slate-800 hover:bg-slate-700' : 'bg-violet-500 hover:bg-violet-600'} 
                 text-white font-bold py-[13px] px-4 rounded transition-colors duration-300`}
             >
               Submit
             </button>
           </div>
       </div>

     </div>
   </ThemeProvider>
 );
};

export default MyForm;