Skip to main content

Select

The Select component renders a Bootstrap-styled dropdown control for selecting one or more options.

It supports single and multiple selection, controlled and uncontrolled values, custom sizing, disabled and required states, visible option lists, and all utility props inherited from Prime.

Options are defined using the Select.Option subcomponent.

Import​

import { Form } from "@promethey/bsui";

Note

Select inherits all utility props supported by the Prime component, including spacing, typography, colors, borders, sizing, positioning, and other Bootstrap utility APIs.

Basic usage​

Use Select.Option to define the available options.

Selected option​

Use the selected prop on Select.Option to define the initially selected option.

For controlled selects, use the value prop on Select instead.

Size​

Use the size prop to control the visual size of the select.

Supported values are:

  • sm — small
  • lg — large

Small​

Large​

Controlled​

Use value and onChange to control the selected value with React state.

Uncontrolled​

Use defaultValue when the select should manage its own state.

Multiple selection​

Use the multiple prop to allow selecting multiple options.

For a multiple select, value and defaultValue can contain an array of strings.

Visible options​

Use visibleOptions to render the select as a list box with multiple visible options.

visibleOptions controls the native size attribute of the underlying <select> element.

Disabled​

Use disabled to prevent user interaction.

Required​

Use required when the user must select a value before submitting a form.

Form example​

Select can be combined with Label and other BSUI form components.

Utility props​

All utility props provided by Prime are supported.

API​

Select​

PropTypeDefaultDescription
childrenReactNode—Select options rendered inside the control.
size"sm" | "lg"nullControls the visual size of the select.
valuestring | string[]nullControls the currently selected value or values.
defaultValuestring | string[]nullSets the initial selected value or values.
multiplebooleanfalseAllows multiple options to be selected.
disabledbooleanfalsePrevents user interaction.
requiredbooleanfalseRequires a value before form submission.
autoFocusbooleanfalseAutomatically focuses the select when mounted.
namestringnullForm field name.
visibleOptionsnumber0Number of visible options when rendered as a list box.
onChangefunctionnullCalled when the selected value changes.
onFocusfunctionnullCalled when the select receives focus.
onBlurfunctionnullCalled when the select loses focus.
classNamestring | object | string[]nullAdditional class names applied to the select.
styleobjectnullInline styles applied to the select.

Select also supports all props provided by Prime.

Select.Option​

Select.Option represents an individual selectable option within Select.

PropTypeDefaultDescription
childrenReactNode—Content displayed for the option.
valuestring | string[]—Value submitted when the option is selected.
selectedbooleanfalseMarks the option as selected by default.
classNamestring | object | string[]nullAdditional class names applied to the option.
styleobjectnullInline styles applied to the option.

Select.Option also supports the props provided by Prime.