Select

Select one or multiple options from a list.

options contains { display, value, disabled, badge } objects. multiple enables multi-select; search enables filtering. An option's badge is either Badge props or an element. leftAddon and rightAddon place a button to the left or right of the field. In controlled mode, clearing the selection clears the field.

Live example

Example controls

Usage

import { Select } from '@prosazhin/pbcomponents';

const options = ['One', 'Two', 'Three', 'Four', 'Five'].map((display, index) => ({
  display,
  value: String(index),
}));

<Select
  options={options}
  placeholder='Placeholder'
/>;

Component API

PropType / variantsPurposeDefault
size's' | 'm's · mComponent size.m
disabledbooleanDisables interaction.false
errorbooleanShows the error state.false
placeholderstringHint in an empty field.—
classNamestringClass of the root element.—
wrapperClassNamestringClass of the outer wrapper.—
valueOption | Option[]Currently selected choice.—
onChange(value: Option | Option[]) => voidCalled when the value changes.—
defaultValueOption | Option[]Initially selected choice.—
optionsOption[]Choices with display, value and optional disabled and badge (Badge props or an element).—
multiplebooleanAllows multiple values.false
searchbooleanAdds filtering of choices.false
searchPlaceholderstringSearch field hint.—
leftAddonReactNodeButton or other element to the left of the field.—
rightAddonReactNodeButton or other element to the right of the field.—
popoverClassNamestringClass of the options list.—
popoverItemClassNamestringClass of an option.—

Native HTML attributes are accepted where the component renders the corresponding element. className props only affect styling.