Select

Displays a list of options for the user to pick from, triggered by a button.

Preview ​

Installation ​

npx sigma-ui@latest add select

Usage ​

vue
<script setup lang="ts">
import {
  Select,
  SelectContent,
  SelectGroup,
  SelectItem,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/select';
</script>

<template>
  <Select>
    <SelectTrigger>
      <SelectValue placeholder="Select a fruit" />
    </SelectTrigger>
    <SelectContent>
      <SelectGroup>
        <SelectLabel>Fruits</SelectLabel>
        <SelectItem value="apple">
          Apple
        </SelectItem>
      </SelectGroup>
    </SelectContent>
  </Select>
</template>
  • Use v-model to control the selected value, or defaultValue to set an initial one.
  • SelectValue shows the selected item, or its placeholder when nothing is selected.
  • size on SelectTrigger is default or sm. The selected item shows a check on the right.

Examples ​

Scrollable ​

Form ​

API Reference ​

Select ​

Props

PropType Default
open

The controlled open state of the Select. Can be bind as v-model:open.

boolean-
defaultOpen

The open state of the select when it is initially rendered. Use when you do not need to control its open state.

boolean-
defaultValue

The value of the select when initially rendered. Use when you do not need to control the state of the Select

AcceptableValue | AcceptableValue[]-
modelValue

The controlled value of the Select. Can be bind as v-model.

AcceptableValue | AcceptableValue[]-
nullableValue

The value of the hidden native select option when the model value is nullish.

string-
by

Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.

string | ((a: AcceptableValue, b: AcceptableValue) => boolean)-
dir

The reading direction of the combobox when applicable. <br> If omitted, inherits globally from ConfigProvider or assumes LTR (left-to-right) reading mode.

Direction-
multiple

Whether multiple options can be selected or not.

boolean-
autocomplete

Native html input autocomplete attribute.

string-
disabled

When true, prevents the user from interacting with Select

boolean-
name

The name of the field. Submitted with its owning form as part of a name/value pair.

string-
required

When true, indicates that the user must set the value before the owning form can be submitted.

boolean-

Events

EventPayload
update:modelValue

Event handler called when the value changes.

[value: AcceptableValue]
update:open

Event handler called when the open state of the context menu changes.

[value: boolean]

Slots

SlotScope
default

The content of the component.

-

SelectValue ​

Props

PropType Default
placeholder

The content that will be rendered inside the SelectValue when no value or defaultValue is set.

string-
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectTrigger ​

Props

PropType Default
size

Height of the trigger. sm matches the small button.

"default" | "sm""default"
disabled
boolean-
reference

The reference (or anchor) element that is being referred to for positioning.

If not provided will use the current component as anchor.

ReferenceElement-
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectContent ​

Props

PropType Default
forceMount

Used to force mounting when more control is needed. Useful when controlling animation with Vue animation libraries.

boolean-
position

The positioning mode to use

item-aligned (default) - behaves similarly to a native MacOS menu by positioning content relative to the active item. <br> popper - positions content in the same way as our other primitives, for example Popover or DropdownMenu.

"popper" | "item-aligned""popper"
bodyLock

The document.body will be lock, and scrolling will be disabled.

booleantrue
loop

When true, keyboard navigation will loop from last item to first, and vice versa.

booleanfalse
memoDependencies

Reactive dependencies that should invalidate the memoized content subtree.

unknown[]-
side

The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.

"top" | "right" | "bottom" | "left""bottom"
sideOffset

The distance in pixels from the trigger.

number0
sideFlip

Flip to the opposite side when colliding with boundary.

booleantrue
align

The preferred alignment against the trigger. May change when collisions occur.

"center" | "start" | "end""center"
alignOffset

An offset in pixels from the start or end alignment options.

number0
alignFlip

Flip alignment when colliding with boundary. May only occur when prioritizePosition is true.

booleantrue
avoidCollisions

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

booleantrue
collisionBoundary

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.

Element | (Element | null)[] | null[]
collisionPadding

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 }.

number | Partial<Record<"top" | "right" | "bottom" | "left", number>>0
arrowPadding

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.

number0
hideShiftedArrow

When true, hides the arrow when it cannot be centered to the reference element.

booleantrue
sticky

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.

"partial" | "always""partial"
hideWhenDetached

Whether to hide the content when the trigger becomes fully occluded.

booleanfalse
positionStrategy

The type of CSS position property to use.

"absolute" | "fixed"-
updatePositionStrategy

Strategy to update the position of the floating element on every animation frame.

"always" | "optimized"'optimized'
disableUpdateOnLayoutShift

Whether to disable the update position for the content when the layout shifted.

booleanfalse
prioritizePosition

Force content to be position within the viewport.

Might overlap the reference element, which may not be desired.

booleanfalse
reference

The custom element or virtual element that will be set as the reference to position the floating element.

If provided, it will replace the default anchor element.

ReferenceElement-
dir

The reading direction of the popper content when applicable. <br> If omitted, inherits globally from ConfigProvider or assumes LTR (left-to-right) reading mode.

Direction-
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"
disableOutsidePointerEvents

When true, hover/focus/click interactions will be disabled on elements outside the DismissableLayer. Users will need to click twice on outside elements to interact with them: once to close the DismissableLayer, and again to trigger the element.

boolean-

Events

EventPayload
escapeKeyDown

Event handler called when the escape key is down. Can be prevented.

[event: KeyboardEvent]
pointerDownOutside

Event handler called when a pointerdown event happens outside of the DismissableLayer. Can be prevented.

[event: PointerDownOutsideEvent]
closeAutoFocus
[event: Event]

Slots

SlotScope
default

The content of the component.

-

SelectGroup ​

Props

PropType Default
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectItem ​

Props

PropType Default
valuerequired

The value given as data when submitted with a name.

AcceptableValue-
disabled

When true, prevents the user from interacting with the item.

boolean-
textValue

Optional text used for typeahead purposes.

By default the typeahead behavior will use the .textContent of the SelectItemText part.

Use this when the content is complex, or you have non-textual content inside.

string-
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectItemText ​

Props

PropType Default
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectLabel ​

Props

PropType Default
for
string-
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectSeparator ​

Props

PropType Default
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

SelectScrollUpButton ​

Props

PropType Default
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

SelectScrollDownButton ​

Props

PropType Default
asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read our Composition guide for more details.

boolean-
as

The element or component this component should render as. Can be overwritten by asChild.

AsTag | Component"div"

Slots

SlotScope
default

The content of the component.

-

Accessibility ​

Adheres to the ListBox WAI-ARIA design pattern. Reka UI handles the roles, focus management, and typeahead.

KeyDescription
SpaceWhen focus is on the trigger, opens the select and focuses the selected item. When focus is on an item, selects it.
EnterWhen focus is on the trigger, opens the select and focuses the selected item. When focus is on an item, selects it.
ArrowDownWhen focus is on the trigger, opens the select. When focus is on an item, moves focus to the next item.
ArrowUpWhen focus is on the trigger, opens the select. When focus is on an item, moves focus to the previous item.
EscCloses the select and moves focus to the trigger.
Edit this page on GitHub