1.0.8 • Published 8 months ago

@prerak12/chaoscomponents v1.0.8

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Introduction

A library built over tailwindcss where you can customize your components as per your needs (not necessary except for colors and some basic props). With just one word change you can switch from normal to google's floating style.

It's that simple!!!

Installation

Install chaoscomponents

npm i @prerak12/chaoscomponents@latest

Ensure you have lucide-react installed:

npm install lucide-react

Input

A customizable React input component with support for various styles, password visibility toggle, and Google-style floating labels.

Features

  • Customizable width, height, colors, and border radius.
  • Supports normal and Google-style floating labels.
  • Password visibility toggle with Lucide icons.
  • Fully controlled input with value and setValue props.
  • Min and max length constraints.
  • Disabled state support.

Usage

Import

import { Input } from '@prerak12/chaoscomponents';
import '@prerak12/chaoscomponents/styles';

The first line imports the input component.

The second line imports the styles for it.

Its necessary to import the styles to make the components look and work as they intend.

Example Usage

import { Input } from '@prerak12/chaoscomponents';
import '@prerak12/chaoscomponents/styles'; 
import { useState } from 'react';

const App = () => {
    const [inputValue, setInputValue] = useState('');
    
    return (
        <Input 
            placeholder="Enter text"
            type="text"
            width="250px"
            height="50px"
            bgColor="#333"
            textColor="white"
            borderColor="blue"
            outlineColor="cyan"
            rounded="md"
            value={inputValue}
            setValue={setInputValue}
        />
    );
};

export default App;

Password Toggle

If type="password", an eye icon will appear to toggle visibility.

Props

PropTypeDefaultDescription
placeholderstring-Placeholder text for the input
typetext \| password \| numbertextInput type (text, password, etc.)
widthstring200pxWidth of the input field
heightstring40pxHeight of the input field
bgColorstring#000Background color of the input
outlineColorstringrgb(0, 150, 255)Color of the input when focused
textColorstringwhiteText color of the input
borderColorstringrgb(0, 150, 255)Border color of the input
roundednone \| sm \| md \| lg \| fullsmBorder radius size
buttonStylegoogle \| normalnormalDetermines label positioning style
minLengthnumber1Minimum length for input value
maxLengthnumber-Maximum length for input value
valuestring-Current input value
setValuefunction-Function to update input value
disabledbooleanfalseWhether input is disabled

Select

A customizable React select dropdown component that supports both single and multiple selection modes. This component features dynamic search, keyboard navigation, and customizable styling for both the select box and its options.

Features

  • Single & Multiple Selection: Choose one or multiple options.
  • Keyboard Navigation: Use arrow keys to navigate and type to search options.
  • Customizable Styles: Easily adjust colors, dimensions, border styles, and more.
  • Dynamic Option Scrolling: Automatically scrolls options into view on navigation.
  • Toggle Selection: Optionally remove a selected item by clicking it again (in multiple selection mode).

Usage

Import

import { Select } from '@prerak12/chaoscomponents';
import '@prerak12/chaoscomponents/styles';

Example Usage

import { Select } from '@prerak12/chaoscomponents';
import '@prerak12/chaoscomponents/styles'; 

const App = () => {
  const [selectedOptions, setSelectedOptions] = useState<string[]>([]);

  return (
    <div style={{ padding: "20px", backgroundColor: "#222" }}>
      <Select 
        label="Select fruit"
        optionsList={[
          'Apple', 'Banana', 'Mango', 'Orange', 'Pineapple', 'Strawberry'
        ]}
        selectedOptions={selectedOptions}
        setSelectedOptions={setSelectedOptions}
        type="multiple"
        width="300px"
        height="40px"
        bgColor="#333"
        textColor="#fff"
        borderColor="#fff"
        hoverBgColor="#444"
        hoverTextColor="#fff"
        optionsBgColor="#000"
        optionsTextColor="#fff"
        selectedOptionsBgColor="#fff"
        selectedOptionsTextColor="#000"
      />
    </div>
  );
};

export default App;

Props

PropTypeDefaultDescription
labelstring-The default text to display on the select box.
widthstring'200px'Width of the select box.
heightstring'40px'Height of the select box.
bgColorstring'transparent'Background color of the select box.
textColorstring'white'Text color of the select box.
roundednone \| sm \| md \| lg \| full'none'Border radius style for the select box.
hoverBgColorstring'#444'Background color when hovering over the select box.
hoverTextColorstring'white'Text color when hovering over the select box.
borderColorstring'white'Border color of the select box.
optionsBgColorstring'black'Background color of the dropdown options list.
optionsTextColorstring'white'Text color for the options list.
optionsHoverBgColorstring'white'Background color for an option on hover.
optionsHoverTextColorstring'black'Text color for an option on hover.
optionsBorderColorstring'transparent'Border color for the options list.
optionsSeperatorColorstring'transparent'Color for the separator between options.
maxOptionsHeightstring'200px'Maximum height of the options list before scrolling.
optionHeightstring'40px'Height for each option item.
optionsListstring[][]Array of options to display in the dropdown.
selectedOptionsBgColorstring'white'Background color for selected options.
selectedOptionsTextColorstring'black'Text color for selected options.
typesingle \| multiple'single'Selection mode: single or multiple.
disabledbooleanfalseDisables the select box if true.
opacitynumber0.7Opacity level when the select box is disabled.
selectedOptionsstring[]-Array of currently selected options.
scrollbarColorstring'white'Color of the scrollbar in the options list.
setbooleantrueControls whether new selections are added (component-specific behavior).
removeFromSelectedOptionsAllowedbooleantrueAllows removing a selected option when clicked again (in multiple mode).
setSelectedOptionsfunction-Callback to update the selected options.

Button

The Button component is a customizable React button that supports various properties to modify its appearance and behavior. It can display a label or custom children, adjust its dimensions, colors, hover effects, border styles, and more.

Features

  • Customizable dimensions (width and height) and padding.
  • Dynamic hover effects for background and text colors.
  • Support for various border-radius options: none, sm, md, lg, and full.
  • Option to disable the button.
  • Ability to render custom child elements along with an optional label.

Usage

Import

import { Button } from '@prerak12/chaoscomponents';
import '@prerak12/chaoscomponents/styles';

Example Usage

import Button from './Button';

const App = () => {
  return (
    <div>
      <Button 
        label="Click Me"
        onClick={() => console.log("Button clicked!")}
        width="150px"
        height="50px"
        bgColor="#007BFF"
        textColor="#FFF"
        rounded="md"
        hoverBgColor="#0056b3"
        hoverTextColor="#FFF"
        borderColor="#007BFF"
        gap="8px"
      />
    </div>
  );
};

export default App;

Props

PropTypeDefaultDescription
labelstring \| React.ReactNode-Text or element to display inside the button.
widthstringautoWidth of the button.
heightstringautoHeight of the button.
disabledbooleanfalseDisables the button if set to true.
onClickfunction-Function to be called on button click.
bgColorstringwhiteBackground color of the button.
textColorstringblackText color of the button.
roundednone \| sm \| md \| lg \| 'full'smDefines the border radius of the button.
hoverBgColorstringrgb(0, 150, 255)Background color on hover.
hoverTextColorstringwhiteText color on hover.
borderColorstringtransparentBorder color of the button.
gapstring0pxGap between children elements inside the button.
childrenReact.ReactNode-Additional elements to render inside the button (optional).
1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.0.19

8 months ago

0.0.18

8 months ago

0.0.17

8 months ago

0.0.16

8 months ago

0.0.15

8 months ago

0.0.14

8 months ago

0.0.13

8 months ago

0.0.12

8 months ago

0.0.11

8 months ago

0.0.9

8 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago