@ilyaxtom/custom-components-lib v1.0.7
@ilyaxtom/custom-components-lib
Task custom-component-lib
Usage
Run npm i @ilyaxtom/custom-components-lib to install the library in your project
Then inmport library components into you source file
import {Button, Checkbox, Modal, Select, Switch, TextField} from '@ilyaxtom/custom-components-lib';Components
Button
A customizable button component built on top of the native HTML <button/> element, extended with styling props and states.
variant:'text'|'contained'|'outlined'– defines the button style, default is'contained'sz:'small'|'medium'|'large'– sets the button size, default is'medium'color:'secondary'|'success'|'error'– applies a color theme to the button, default is'secondary'disabled:boolean– disables the button whentrue, default isfalseloading:boolean– shows a loading state and disables interaction whentrue, default isfalse
<Button
variant="outlined"
sz="large"
color="success"
onClick={() => console.log('Clicked!')}
>
Submit
</Button>Checkbox
A customizable checkbox component built on top of the native HTML <input type="checkbox"/> element, extended with styling props and label support.
sz:'small'|'medium'|'large'– sets the checkbox size, default is'medium'color:'blue'|'purple'|'green'|'grey'|'pink'– applies a color theme to the checkbox, default is'blue'label:string– text label displayed next to the checkboxrequired:boolean– marks the checkbox as required in a form, default isfalsedisabled:boolean– disables the checkbox whentrue, default isfalse
<Checkbox
sz="small"
color="green"
label="Accept terms and conditions"
required
/>Switch
A customizable switch (toggle) component built on top of the native HTML <input type="checkbox"/> element, styled to represent an on/off toggle with optional label and sizing.
sz:'small'|'medium'|'large'– sets the switch size, default is'small'color:'default'|'purple'|'orange'|'grey'|'pink'– applies a color theme to the switch, default is'default'label:string– text label displayed next to the switchdisabled:boolean– disables the switch whentrue, default isfalsedefaultChecked:boolean– determines whether the switch is initially checked, default isfalserequired:boolean– marks the switch as required in a form, default isfalse
<Switch
sz="medium"
color="orange"
label="Enable notifications"
defaultChecked
/>TextField
A flexible input component supporting different variants, input types, and optional multiline mode. Built to handle both standard input fields and textareas, with enhanced styling.
variant:'outlined'|'filled'|'standard'– defines the style of the text field, default is'outlined'type:'text'|'number'|'password'– sets the input type, default is'text'label:string– label displayed in the inputhelperText:string– additional helper text displayed below the inputvalue:string– current value of the input (controlled input)required:boolean– marks the field as required, default isfalsereadonly:boolean– makes the field read-only without disabling it, default isfalsedisabled:boolean– disables the input whentrue, default isfalseerror:boolean– applies styles for error case, default isfalsemultiline:boolean– renders a<textarea>instead of a single-line<input>, default isfalseonChange:(e: ChangeEvent<TextFieldElements>) => void– event handler triggered on value change
<TextField
variant="filled"
type="password"
label="Password"
helperText="Minimum 8 characters"
required
error
onChange={(e) => console.log(e.target.value)}
/>Select
A customizable dropdown/select component supporting different variants, sizes, and form states. Allows composition with custom option components via children.
variant:'outlined'|'filled'|'standard'– defines the visual style of the select, default is'outlined'sz:'small'|'standard'– sets the size of the select, default is'standard'selectedTitle:string– text displayed as the currently selected valuelabel:string– label displayed in the select fieldhelperText:string– additional helper text displayed below the select fielddisabled:boolean– disables the select whentrue, default isfalseerror:boolean– applies styles for error case, default isfalserequired:boolean– marks the select as required, default isfalsechildren:React.ReactNode– a list ofSelectItemcomponents representing options
SelectItem
Represents a single item inside a Select component. Uses a generic id and notifies parent on selection.
id:T– unique identifier for the optionselected:boolean– indicates whether this item is currently selectedonChange:(id: T) => void– callback triggered when the item is selected
const [selectedId, setSelectedId] = useState<number | null>(null);
const optionsList = options.map(({ id, title }) => (
<SelectItem<number>
key={id}
id={id}
selected={selectedId === id}
onChange={setSelectedId}
>
{title}
</SelectItem>
));
const selectedTitle = useMemo(() => {
const option = options.find((o) => o.id === selectedId);
return option ? option.title : '';
}, [selectedId]);
return (
<Select selectedTitle={selectedTitle}>
{optionsList}
</Select>
);Modal
A flexible modal component, used to display overlay dialogs. Component automatically insert onClose button in modal box.
open:boolean– controls whether the modal is visible, default isfalseonOpen:() => void– callback fired when the modal is openedonClose:() => void– callback fired when the modal is closedchildren:React.ReactNode– content displayed inside the modal
<Modal
open={isOpen}
onOpen={() => console.log('Modal opened')}
onClose={() => setIsOpen(false)}
>
<h2>Modal Title</h2>
<p>This is the modal content.</p>
<button onClick={() => setIsOpen(false)}>Close</button>
</Modal>