Select

Displays a list of options for the user to pick from—triggered by a button.
# Select Demo
Startup
# Combobox Demo
Startup
# Creatable Select Demo
Startup
# 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.
Note: this component is created on top of react-select library, for more customizations you can directly use it.
# 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;