Skip to Content
Documentation
Saas UI
Get Pro
Getting started
Components
Overview

Select

Used to pick a value from predefined options.

SourceStorybookRecipeArk

Anatomy

import { Select } from '@saas-ui/react/select'
<Select.Root items={[]}>
  <Select.Label />
  <Select.Trigger>
    <Select.ValueText placeholder="Select" />
  </Select.Trigger>
  <Select.Content>
    <Select.Item />
  </Select.Content>
</Select.Root>

Examples

Sizes

Use the size prop to change the size of the select component.

Variants

Use the variant prop to change the appearance of the select component.

Option Group

Use the SelectItemGroup component to group select options.

Controlled

Use the value and onValueChange props to control the select component.

Hook Form

Here's an example of how to use the Select component with react-hook-form.

Disabled

Use the disabled prop to disable the select component.

Invalid

Use the invalid prop to indicate that the select component has an error.

This is an error

Positioning

Use the positioning prop to control the underlying floating-ui options of the select component.

Within Popover

Use the Select within a Popover component.

Avatar Select

Here's an example of how to compose the Select and the Avatar.

Clear Trigger

Pass the clearable prop to the SelectTrigger.

Overflow

Props

Root

PropDefaultType
collection *
ListCollection<T>

The collection of items

closeOnSelect true
boolean

Whether the select should close after an item is selected

composite true
boolean

Whether the select is a composed with other composite widgets like tabs or combobox

lazyMount false
boolean

Whether to enable lazy mounting

loopFocus false
boolean

Whether to loop the keyboard navigation through the options

skipAnimationOnMount false
boolean

Whether to allow the initial presence animation.

unmountOnExit false
boolean

Whether to unmount on exit.

colorPalette 'gray'
'gray' | 'zinc' | 'neutral' | 'stone' | 'red' | 'orange' | 'amber' | 'yellow' | 'lime' | 'green' | 'emerald' | 'teal' | 'cyan' | 'sky' | 'blue' | 'indigo' | 'violet' | 'purple' | 'fuchsia' | 'pink' | 'rose' | 'presence' | 'status' | 'sidebar' | 'sidebar.accent' | 'accent' | 'slate'

The color palette of the component

variant 'outline'
'outline' | 'subtle'

The variant of the component

size 'md'
'xs' | 'sm' | 'md' | 'lg'

The size of the component

asChild
boolean

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

For more details, read our Composition guide.
defaultHighlightedValue
string

The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the select.

defaultOpen
boolean

Whether the select's open state is controlled by the user

defaultValue
string[]

The initial default value of the select when rendered. Use when you don't need to control the value of the select.

deselectable
boolean

Whether the value can be cleared by clicking the selected item. **Note:** this is only applicable for single selection

disabled
boolean

Whether the select is disabled

form
string

The associate form of the underlying select.

highlightedValue
string

The controlled key of the highlighted item

id
string

The unique identifier of the machine.

ids
Partial<{ 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 }>

The ids of the elements in the select. Useful for composition.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

invalid
boolean

Whether the select is invalid

multiple
boolean

Whether to allow multiple selection

name
string

The `name` attribute of the underlying select.

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onFocusOutside
(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the component

onHighlightChange
(details: HighlightChangeDetails<T>) => void

The callback fired when the highlighted item changes.

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onOpenChange
(details: OpenChangeDetails) => void

Function called when the popup is opened

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onValueChange
(details: ValueChangeDetails<T>) => void

The callback fired when the selected item changes.

open
boolean

Whether the select menu is open

positioning
PositioningOptions

The positioning options of the menu.

present
boolean

Whether the node is present (controlled by the user)

readOnly
boolean

Whether the select is read-only

required
boolean

Whether the select is required

scrollToIndexFn
(details: ScrollToIndexDetails) => void

Function to scroll to a specific index

value
string[]

The controlled keys of the selected items

as
React.ElementType

The underlying element to render.

unstyled
boolean

Whether to remove the component's style.

Previous

Select (Native)

Next

Separator