For more examples, visit the Storybook.

Example
<StudsSelect>
    <StudsSelectTrigger>
        <StudsSelectValue placeholder="Select an option" />
    </StudsSelectTrigger>
    <StudsSelectContent>
        <StudsSelectItem value="option1">Option 1</StudsSelectItem>
        <StudsSelectItem value="option2">Option 2</StudsSelectItem>
        <StudsSelectItem value="option3">Option 3</StudsSelectItem>
    </StudsSelectContent>
</StudsSelect>

StudsSelect Props

defaultValue
string

The default value of the select.

value
string

The controlled value of the select.

onValueChange
function

Callback function that is called when the value changes.

defaultOpen
boolean
default:"false"

If true, the select will be open by default.

open
boolean

If true, the select will be open.

onOpenChange
function

Callback function that is called when the open state changes.

dir
"ltr" | "rtl"
default:"ltr"

The direction of the select.

name
string

The name of the select.

disabled
boolean
default:"false"

If true, the select will be disabled.

required
boolean
default:"false"

If true, the select is required.

StudsSelectContent Props

asChild
boolean
default:"false"

If true, the select content will render as a child component.

onCloseAutoFocus
function

Event handler called when focus moves to the trigger after closing. It can be prevented by calling event.preventDefault.

onEscapeKeyDown
function

Event handler called when the escape key is down. It can be prevented by calling event.preventDefault.

onPointerDownOutside
function

Event handler called when a pointer event occurs outside the bounds of the component. It can be prevented by calling event.preventDefault.

position
"item-aligned" | "popper"
default:"item-aligned"

The positioning mode to use, item-aligned is the default and behaves similarly to a native MacOS menu by positioning content relative to the active item.

side
"top" | "right" | "bottom" | "left"
default:"bottom"

The side of the trigger to position the content.

sideOffset
number
default:"0"

The distance in pixels from the anchor. Only available when position is set to popper.

align
"start" | "center" | "end"
default:"start"

The alignment of the content when side is set to “right” or “left”.

alignOffset
number
default:"0"

An offset in pixels from the “start” or “end” alignment options. Only available when position is set to popper.

avoidCollisions
boolean
default:"true"

When true, overrides the side andalign preferences to prevent collisions with boundary edges.

collisionBoundary
Boundary

The element used as the collision boundary. By default this is the viewport, though you can provide additional element(s) to be included in this check. Only available when position is set to popper.

collisionPadding
number | Padding
default:"10"

The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { top: 20, left: 20 }. Only available when position is set to popper.

arrowPadding
number
default:"0"

The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Only available when position is set to popper.

sticky
"partial" | "always"
default:"partial"

The sticky behavior on the align axis. “partial” will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst “always” will keep the content in the boundary regardless. Only available when position is set to popper.

hideWhenDetached
boolean
default:"false"

Whether to hide the content when the trigger becomes fully occluded. Only available when position is set to popper.

StudsSelectValue Props

asChild
boolean
default:"false"

If true, the select value will render as a child component.

placeholder
string

The placeholder text for the select value.

StudsSelectItem Props

asChild
boolean
default:"false"

If true, the select item will render as a child component.

value
string
required

The value of the select item.

disabled
boolean
default:"false"

If true, the select item will be disabled.

textValue
string

Optional text used for typeahead purposes.

StudsSelectSeparator, StudsSelectScrollUpButton, StudsSelectScrollDownButton, StudsSelectGroup, StudsSelectLabel, StudsSelectTrigger Props

asChild
boolean
default:"false"

If true, the select separator will render as a child component.