Skip to main content

Select

A Select is a form control that lets users pick one or more options from a dropdown list. It is built on top of the Popover component and supports sections, search filtering, multi-select, and keyboard navigation out of the box.

Key Characteristics

  • Flexible Data: Provide options via the items prop or compose them declaratively with Select.Section and Select.Item.
  • Multi-Select: Toggle multiple to allow selecting more than one option, with chip-based value display.
  • Searchable: Enable the search prop to let users filter options by typing.
  • Accessible: Full keyboard navigation and focus management built in.

Import

There are 4 select-related components:

  • Select: The main select component.
  • SelectItem: An individual option.
  • SelectSection: A group of options with an optional title.
  • SelectDivider: A visual separator between sections.
import { Select, SelectItem, SelectSection, SelectDivider } from '@andrejground/lab';

Compound pattern is also supported:

  • Select.Item
  • Select.Section
  • Select.Divider

Usage

Favorite animal
Select an animal

Sections

Use Select.Section and Select.Item to group options with titles and descriptions.

Grouped items
Select an item

Multiple

Enable multiple to allow selecting more than one option. Selected values appear as removable chips.

Multiple selection
Select animals

Searchable

Enable search to let users filter options by typing in the trigger input.

Searchable select

Combine multiple, search, and popOnSelection for an autocomplete-style multi-select. Selected options are removed from the dropdown list.

Multi-select with search

Truncation Off

With all truncate options set to false, long option text, descriptions, and selected value chips wrap naturally into multiple lines.

Truncation off (text wraps)
Select items

Truncation On

With all truncate options set to true, long text is clipped to a single line with an ellipsis - for item text, item descriptions, value chips, and the selected value display.

Truncation on (text truncated)
Select items

Async & Infinite Scroll

Use infiniteScrollProps to load more options as the user scrolls. Combine with search, onSearchChange, and debounceCallback for a full async autocomplete experience.

Loading...

Controlled

Controlled select
Select an animal
Open: false