Select

A Select or ComboBox component is a UI element that allows users to choose one or more options from a dropdown list. It typically displays a default value or prompt, and when clicked, it expands to show a list of available choices. Users can either select an option from the list or, in the case of a ComboBox, input custom values. This component is ideal for conserving space in forms and making it easy for users to make selections quickly.
# Demo

Select Demo

Startup

Combo Box Demo

Startup
Note: this component is created on top of react-select library, for more customizations you can directly use it.
# Attributes
NameTypeDefaultDetails
classNamestring' 'You can customise by passing tailwind classes.
labelClassNamestring' 'You can customise by passing tailwind classes.
selectClassNamestring' 'You can customise by passing tailwind classes.
isMultibooleanfalseYou can pass isMulti option to switch between single / multi select.
isLoadingbooleanfalseYou can pass isLoading option to show loading indicator.
isCreatablebooleanfalseYou can pass isCreatable option to add create options feature.
isClearablebooleanfalseYou can pass isClearable option to show clear option for select.
isSearchablebooleanfalseYou can pass isSearchable option to enable searching feature.
isDisabledbooleanfalseYou can pass isDisabled option to disable select.
placeholderstringRequiredYou can pass placeholder for select.
labelstring' 'You can pass label to show label for select.
optionsReactSelectOption[]RequiredYou can pass options for the select.
valueReactSelectOption[]RequiredYou can pass default selected items.
onChangeOptions(values: ReactSelectOption[]) => void;RequiredYou can get callback when select changed.
onCreateOptions(value: string) => void;RequiredYou can get callback when new select item created.
# Usage
import { useState } from 'react'; import { NSelect } from 'nayan'; const items = [ { value: 'startup', label: 'Startup' }, { value: 'business', label: 'Business' }, { value: 'enterprise', label: 'Enterprise' } ]; const Select = () => { const [selected, setSelected] = useState(items[0]); return ( <NSelect isMulti={true} isCreatable={true} placeholder="Select something..." isClearable={true} isSearchable={true} isDisabled={false} value={selected} options={items} onCreateOptions={value => console.log(value)} onChangeOptions={values => setSelected(values)} /> ); }; export default Select;