DocsBlog

Get Started

Components

Data Grid

Signals

Styling

Theming

↑↓Navigate
↵Select
EscClose
  • 1.8.0

  • Day

    Night

    Preview

    Switch mode
  • cerberus

    acheron

    elysium

    oceanus

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerContainer QueryDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTA ModalDate PickerDialogFieldFieldsetFile UploaderIconButtonInputLoading StatesMarqueeMenuNotificationsNumber InputPaginationPin InputPopoverProgress IndicatorsPrompt ModalRadioRatingSelectSliderSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFormat Relative TimeFrameHighlightJSON Tree ViewLocalePortalPresenceShowSwapsplitPropsTheme

Select

The Select component is a controlled component that can be used to select one option from a set. It can be used in a group with other selects to allow for multiple selections.

  • npm
  • source
  • recipe
  • Ark
View as Markdown
Open this page in Markdown
Anthropic
Open in Claude
Ask questions about this page
OpenAI
Open in ChatGPT
Ask questions about this page

Import

import {
  Select,
  Option,
  OptionGroup,
  OptionGroupLabel,
  createSelectCollection,
} from '@cerberus/react'

Usage

The Select component is a controlled component that can be used to select one option from a set. It can be used in a group with other selects to allow for multiple selections.

Loading example...

Grouped Options

To group options, use the OptionGroup and OptionGroupLabel components.

Loading example...

Sizes

Use the size prop to change the size of the Select.

Loading example...

With Dialog

Loading example...

Customizing

You can customize the Select by using style props or the Primitives.

Loading example...

Primitives

You can utilize the primitive components or the css prop to customize the select.

ComponentDescription
SelectRootThe context provider for the Select family
SelectLabelThe label that appears above the select input
SelectControlThe wrapper to the select trigger that opens the dropdown
SelectTriggerhe trigger that opens the dropdown
SelectValueTextThe text that appears in the trigger
SelectIndicatorThe indicator that appears in the trigger
SelectClearTriggerThe trigger that clears the selected value
SelectPositionerThe wrapper that positions the dropdown
SelectContentThe content of the dropdown (i.e. the container itself)
SelectItemGroupThe group of options in the dropdown
SelectItemGroupLabelThe label for the group of options
SelectItemThe option in the dropdown
SelectItemTextThe text label of the option
SelectItemIndicatorThe indicator shown when the option is selected
SelectHiddenInputThe native select for the select group.

Parts

The SelectParts API is an Object containing the full family of components.

Note

It is best to only use the SelectParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.

NameDescription
RootThe SelectRoot component which is the Provider for the family.
LabelThe SelectLabel component which displays the label and "required" notice.
ControlThe SelectControl component which is the visual field.
TriggerThe SelectTrigger component which is the trigger for the dropdown.
ClearTriggerThe SelectClearTrigger component which is the trigger to clear the selected value.
ValueTextThe SelectValueText component which displays the selected value.
IndicatorThe SelectIndicator component which displays the trigger indicator.
PositionerThe SelectPositioner component which is controls the positioning for the dropdown.
ContentThe SelectContent component which is the dropdown itself.
ItemGroupThe SelectItemGroup component which is the group of options in the dropdown.
ItemGroupLabelThe SelectItemGroupLabel component which is the label for the group of options.
ItemThe SelectItem component which is the option in the dropdown.
ItemTextThe SelectItemText component which is the text label of the option.
ItemIndicatorThe SelectItemIndicator component which displays based on the checked state.
HiddenInputThe SelectHiddenInput component which displays the native input.

API

Root

Props

PropTypeRequiredDefaultDescription
collectionListCollection<T>trueundefinedThe collection of items
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.
autoCompletestringfalseundefinedThe autocomplete attribute for the hidden select. Enables browser autofill (e.g. "address-level1" for state).
closeOnSelectbooleanfalsetrueWhether the select should close after an item is selected
compositebooleanfalsetrueWhether the select is a composed with other composite widgets like tabs or combobox
defaultHighlightedValuestringfalseundefinedThe initial value of the highlighted item when opened.
Use when you don't need to control the highlighted value of the select.
defaultOpenbooleanfalseundefinedWhether the select's open state is controlled by the user
defaultValuestring[]falseundefinedThe initial default value of the select when rendered.
Use when you don't need to control the value of the select.
deselectablebooleanfalseundefinedWhether the value can be cleared by clicking the selected item.

Note: this is only applicable for single selection
disabledbooleanfalseundefinedWhether the select is disabled
formstringfalseundefinedThe associate form of the underlying select.
hideModeHideModefalse'display-none'How to hide content when mounted but not present.
- 'display-none': HTML hidden attribute. Effects stay alive.
- 'activity': React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.
highlightedValuestringfalseundefinedThe controlled key of the highlighted item
idstringfalseundefinedThe unique identifier of the machine.
idsPartial<{ root: string, content: string, control: string, trigger: string, clearTrigger: string, label: string, hiddenSelect: string, positioner: string, item: (id: string | number) => string, itemGroup: (id: string | number) => string, itemGroupLabel: (id: string | number) => string }>falseundefinedThe ids of the elements in the select. Useful for composition.
immediatebooleanfalseundefinedWhether to synchronize the present change immediately or defer it to the next frame
invalidbooleanfalseundefinedWhether the select is invalid
lazyMountbooleanfalsefalseWhether to enable lazy mounting
loopFocusbooleanfalsefalseWhether to loop the keyboard navigation through the options
multiplebooleanfalseundefinedWhether to allow multiple selection
namestringfalseundefinedThe name attribute of the underlying select.
onExitCompleteVoidFunctionfalseundefinedFunction called when the animation ends in the closed state
onFocusOutside(event: FocusOutsideEvent) => voidfalseundefinedFunction called when the focus is moved outside the component
onHighlightChange(details: HighlightChangeDetails<T>) => voidfalseundefinedThe callback fired when the highlighted item changes.
onInteractOutside(event: InteractOutsideEvent) => voidfalseundefinedFunction called when an interaction happens outside the component
onOpenChange(details: OpenChangeDetails) => voidfalseundefinedFunction called when the popup is opened
onPointerDownOutside(event: PointerDownOutsideEvent) => voidfalseundefinedFunction called when the pointer is pressed down outside the component
onSelect(details: SelectionDetails) => voidfalseundefinedFunction called when an item is selected
onValueChange(details: ValueChangeDetails<T>) => voidfalseundefinedThe callback fired when the selected item changes.
openbooleanfalseundefinedWhether the select menu is open
positioningPositioningOptionsfalseundefinedThe positioning options of the menu.
presentbooleanfalseundefinedWhether the node is present (controlled by the user)
readOnlybooleanfalseundefinedWhether the select is read-only
requiredbooleanfalseundefinedWhether the select is required
scrollToIndexFn(details: ScrollToIndexDetails) => voidfalseundefinedFunction to scroll to a specific index
skipAnimationOnMountbooleanfalsefalseWhether to allow the initial presence animation.
translationsIntlTranslationsfalseundefinedSpecifies the localized strings that identifies the accessibility elements and their states
unmountOnExitbooleanfalsefalseWhether to unmount on exit.
valuestring[]falseundefinedThe controlled keys of the selected items

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partroot
data-invalidPresent when invalid
data-readonlyPresent when read-only

ClearTrigger

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partclear-trigger
data-invalidPresent when invalid

Content

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partcontent
data-state"open" | "closed"
data-nestedlistbox
data-has-nestedlistbox
data-placementThe placement of the content
data-sideThe side of the trigger that the content is positioned on
data-activedescendantThe id the active descendant of the content

Control

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partcontrol
data-state"open" | "closed"
data-focusPresent when focused
data-disabledPresent when disabled
data-invalidPresent when invalid

HiddenSelect

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Indicator

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partindicator
data-state"open" | "closed"
data-disabledPresent when disabled
data-invalidPresent when invalid
data-readonlyPresent when read-only

ItemGroupLabel

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

ItemGroup

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partitem-group
data-disabledPresent when disabled

ItemIndicator

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partitem-indicator
data-state"checked" | "unchecked"

Item

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.
itemanyfalseundefinedThe item to render
persistFocusbooleanfalseundefinedWhether hovering outside should clear the highlighted state

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partitem
data-valueThe value of the item
data-state"checked" | "unchecked"
data-highlightedPresent when highlighted
data-disabledPresent when disabled

ItemText

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partitem-text
data-state"checked" | "unchecked"
data-disabledPresent when disabled
data-highlightedPresent when highlighted

Label

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partlabel
data-disabledPresent when disabled
data-invalidPresent when invalid
data-readonlyPresent when read-only
data-requiredPresent when required

List

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Positioner

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

RootProvider

Props

PropTypeRequiredDefaultDescription
valueUseSelectReturn<T>trueundefinedundefined
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.
hideModeHideModefalse'display-none'How to hide content when mounted but not present.
- 'display-none': HTML hidden attribute. Effects stay alive.
- 'activity': React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.
immediatebooleanfalseundefinedWhether to synchronize the present change immediately or defer it to the next frame
lazyMountbooleanfalsefalseWhether to enable lazy mounting
onExitCompleteVoidFunctionfalseundefinedFunction called when the animation ends in the closed state
presentbooleanfalseundefinedWhether the node is present (controlled by the user)
skipAnimationOnMountbooleanfalsefalseWhether to allow the initial presence animation.
unmountOnExitbooleanfalsefalseWhether to unmount on exit.

Trigger

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-parttrigger
data-state"open" | "closed"
data-disabledPresent when disabled
data-invalidPresent when invalid
data-readonlyPresent when read-only
data-placementThe placement of the trigger
data-sideThe side of the trigger that the trigger is positioned on
data-placeholder-shownPresent when placeholder is shown

ValueText

Props

PropTypeRequiredDefaultDescription
asChildbooleanfalseundefinedUse the provided child element as the default rendered element, combining their props and behavior.
placeholderstringfalseundefinedText to display when no value is selected.

Data Attributes

AttributeDescription / Value
data-scopeselect
data-partvalue-text
data-disabledPresent when disabled
data-invalidPresent when invalid
data-focusPresent when focused

Context

API:

PropertyTypeDescription
focusedbooleanWhether the select is focused
openbooleanWhether the select is open
emptybooleanWhether the select value is empty
highlightedValuestring | nullThe value of the highlighted item
highlightedItemV | nullThe highlighted item
setHighlightValue(value: string) => voidFunction to highlight a value
clearHighlightValueVoidFunctionFunction to clear the highlighted value
selectedItemsV[]The selected items
hasSelectedItemsbooleanWhether there's a selected option
valuestring[]The selected item keys
valueAsStringstringThe string representation of the selected items
selectValue(value: string) => voidFunction to select a value
selectAllVoidFunctionFunction to select all values
setValue(value: string[]) => voidFunction to set the value of the select
clearValue(value?: string) => voidFunction to clear the value of the select.
If a value is provided, it will only clear that value, otherwise, it will clear all values.
focusVoidFunctionFunction to focus on the select input
getItemState(props: ItemProps) => ItemStateReturns the state of a select item
setOpen(open: boolean) => voidFunction to open or close the select
collectionListCollection<V>Function to toggle the select
reposition(options?: Partial<PositioningOptions>) => voidFunction to set the positioning options of the select
multiplebooleanWhether the select allows multiple selections
disabledbooleanWhether the select is disabled

Accessibility

Complies with the Listbox WAI-ARIA design pattern.

Keyboard Support

KeyDescription
SpaceWhen focus is on trigger, opens the select and focuses the first selected item.
When focus is on the content, selects the highlighted item.
EnterWhen focus is on trigger, opens the select and focuses the first selected item.
When focus is on content, selects the focused item.
ArrowDownWhen focus is on trigger, opens the select.
When focus is on content, moves focus to the next item.
ArrowUpWhen focus is on trigger, opens the select.
When focus is on content, moves focus to the previous item.
EscCloses the select and moves focus to trigger.
A-Z + a-zWhen focus is on trigger, selects the item whose label starts with the typed character.
When focus is on the listbox, moves focus to the next item with a label that starts with the typed character.

On this page

  • Import
  • Usage
  • Grouped Options
  • Sizes
  • With Dialog
  • Customizing
  • Primitives
    • Parts
  • API
    • Root
      • Props
      • Data Attributes
    • ClearTrigger
      • Props
      • Data Attributes
    • Content
      • Props
      • Data Attributes
    • Control
      • Props
      • Data Attributes
    • HiddenSelect
      • Props
    • Indicator
      • Props
      • Data Attributes
    • ItemGroupLabel
      • Props
    • ItemGroup
      • Props
      • Data Attributes
    • ItemIndicator
      • Props
      • Data Attributes
    • Item
      • Props
      • Data Attributes
    • ItemText
      • Props
      • Data Attributes
    • Label
      • Props
      • Data Attributes
    • List
      • Props
    • Positioner
      • Props
    • RootProvider
      • Props
    • Trigger
      • Props
      • Data Attributes
    • ValueText
      • Props
      • Data Attributes
    • Context
  • Accessibility
    • Keyboard Support
Edit this page on Github
Hades
Persephone
Zeus
Poseidon
Hera
The fam
Hades
Persephone
Zeus
Poseidon
Hera
Hades
Persephone
Zeus
Poseidon
Hera
Hades
Persephone
Zeus
Poseidon
Hera
Hades
Persephone
Zeus
Poseidon
Hera

Some heading

This is a description for the dialog. You can use this space to provide more context or instructions for the user.
Hades
Persephone
Zeus
Poseidon
Hera
The fam
Hades
✓
Persephone
✓
Zeus
✓
Poseidon
✓
Hera
✓