Skip to content

    Select

    Picks one value from a list. The trigger looks like Input, in the same four sizes; the list opens over it on the raised surface, with the current value aligned to the trigger and marked with a check.

    React

    Preview

    Props

    • size
    • disabled
    • placeholder
    • defaultValue
    • value
    • open
    • defaultOpen
    • dir
    • invalid
    • position
    • side
    • align
    • label
    • groups
    • aria-invalid
    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-96 max-w-full flex-col gap-xs">
      <label htmlFor="preview-select" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="preview-select">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Usage

    When to use

    • Pick one value from a known list of options, such as the role of a team member.
    • Fit a choice into the space of one field, next to an Input or Button of the same size.
    • A longer list split into labelled groups, with a line between them.

    When not to use

    • A yes or no choice. Use a native checkbox.
    • Going to another page or running an action. Use a link or Button.
    • Text the user types freely. Use Input.

    Platform support

    What each platform has, from the spec. A selected platform is highlighted.

    NameWebiOSAndroidNote
    sizeYesYesYes
    disabledYesYesYes
    placeholderYesYesYes
    defaultValueYesDeferredDeferredNot generated for iOS and Android.
    valueYesYesYes
    onValueChangeYesYesYes
    nameYesNoNoOnly on web. Not generated for iOS and Android.
    requiredYesNoNoOnly on web. Not generated for iOS and Android.
    openYesYesYes
    defaultOpenYesYesYes
    onOpenChangeYesYesYes
    dirYesNoNoOnly on web. Not generated for iOS and Android.
    leadingIconYesYesYes
    invalidYesYesYes
    positionYesNoNoOnly on web. Not generated for iOS and Android.
    sideYesNoNoOnly on web. Not generated for iOS and Android.
    alignYesNoNoOnly on web. Not generated for iOS and Android.
    optionsNoYesYesOnly on iOS, Android.
    sheetTitleNoYesYesOnly on iOS, Android.
    sheetSizeNoYesYesOnly on iOS, Android.
    value of keyboard: ArrowDown, ArrowUpYesDeferredDeferred
    value of keyboard: Home, EndYesDeferredDeferred
    value of keyboard: A to ZYesDeferredDeferred

    Variants

    size

    Trigger height from size-element-*, set on SelectTrigger: sm 28px, md 32px (the default), lg 36px, xl 44px with a mouse; on touch md is 36px, lg 44px and xl 48px. Match the Input or Button next to it: md in forms, sm only in dense mouse-first UI, lg or xl for the main field of a screen.

    • sm

    • mddefault

    • lg

    • xl

    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-96 max-w-full flex-col gap-xs">
      <label htmlFor="preview-select-size-sm" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="preview-select-size-sm" size="sm">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>
    <div className="flex w-96 max-w-full flex-col gap-xs">
      <label htmlFor="preview-select-size-md" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="preview-select-size-md">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>
    <div className="flex w-96 max-w-full flex-col gap-xs">
      <label htmlFor="preview-select-size-lg" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="preview-select-size-lg" size="lg">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>
    <div className="flex w-96 max-w-full flex-col gap-xs">
      <label htmlFor="preview-select-size-xl" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="preview-select-size-xl" size="xl">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Examples

    Default

    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-full max-w-sm flex-col gap-xs">
      <label htmlFor="member-role" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="member-role">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
          <SelectItem value="admin">Admin</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Grouped options

    Each group is labelled by its heading; the line between groups is decorative.

    import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-full max-w-sm flex-col gap-xs">
      <label htmlFor="member-access" className="text-sm text-text-secondary">Access</label>
      <Select>
        <SelectTrigger id="member-access">
          <SelectValue placeholder="Choose access" />
        </SelectTrigger>
        <SelectContent>
          <SelectGroup>
            <SelectLabel>Workspace</SelectLabel>
            <SelectItem value="viewer">Viewer</SelectItem>
            <SelectItem value="editor">Editor</SelectItem>
          </SelectGroup>
          <SelectSeparator />
          <SelectGroup>
            <SelectLabel>Billing</SelectLabel>
            <SelectItem value="billing-viewer">Billing viewer</SelectItem>
            <SelectItem value="billing-admin">Billing admin</SelectItem>
          </SelectGroup>
        </SelectContent>
      </Select>
    </div>

    Disabled

    Keeps its value visible but can't be opened.

    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-full max-w-sm flex-col gap-xs">
      <label htmlFor="locked-role" className="text-sm text-text-secondary">Role</label>
      <Select defaultValue="owner" disabled>
        <SelectTrigger id="locked-role">
          <SelectValue />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="owner">Owner</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Invalid

    The danger border plus error text linked with aria-describedby.

    Choose a role for the new member.

    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="flex w-full max-w-sm flex-col gap-xs">
      <label htmlFor="invite-role" className="text-sm text-text-secondary">Role</label>
      <Select>
        <SelectTrigger id="invite-role" invalid aria-describedby="invite-role-error">
          <SelectValue placeholder="Choose a role" />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="viewer">Viewer</SelectItem>
          <SelectItem value="editor">Editor</SelectItem>
        </SelectContent>
      </Select>
      <p id="invite-role-error" className="text-sm text-text-danger">Choose a role for the new member.</p>
    </div>

    Leading icon

    import { IconWorld } from "@tabler/icons-react"
    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="w-full max-w-sm">
      <Select defaultValue="en">
        <SelectTrigger aria-label="Language" leadingIcon={<IconWorld size={16} />}>
          <SelectValue />
        </SelectTrigger>
        <SelectContent>
          <SelectItem value="en">English</SelectItem>
          <SelectItem value="vi">Tiếng Việt</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Popper position

    The list opens below the trigger like a menu instead of over it.

    import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
    
    <div className="w-full max-w-sm">
      <Select>
        <SelectTrigger aria-label="Sort">
          <SelectValue placeholder="Sort by" />
        </SelectTrigger>
        <SelectContent position="popper" side="bottom" align="start" sideOffset={4}>
          <SelectItem value="newest">Newest</SelectItem>
          <SelectItem value="oldest">Oldest</SelectItem>
        </SelectContent>
      </Select>
    </div>

    Do and don't

    Do

    • Use Select to pick one value from a known list of options.
    • Always pair the trigger with a visible label (htmlFor / id).
    • Keep option labels short and in sentence case, and sort them in a way the user expects (by order of use, or alphabetically).
    • Use a placeholder only to hint at the action (Choose a role), never instead of the label.
    • Match the trigger size to the Input or Button next to it.
    • Split a long list into groups with a SelectLabel heading each (Workspace, Billing), and a SelectSeparator between them.

    Don't

    • Don't use Select for a yes or no choice. Use a checkbox.
    • Don't use Select to navigate or to trigger actions. Use links or Button.
    • Don't put icons, descriptions or other controls inside options; an option is one line of text.
    • Don't use size sm on touch-first screens.
    • Don't restyle colors through className. If a state looks wrong, open an issue instead of overriding it.

    Props

    NameTypeValuesDefaultDescription
    sizeenumsm | md | lg | xlmdTrigger height from size-element-*, set on SelectTrigger: sm 28px, md 32px (the default), lg 36px, xl 44px with a mouse; on touch md is 36px, lg 44px and xl 48px. Match the Input or Button next to it: md in forms, sm only in dense mouse-first UI, lg or xl for the main field of a screen.
    disabledboolean-falseSet on Select. The trigger can't be focused or opened and uses the neutral disabled look.
    placeholderstring--Set on SelectValue. Shown in the trigger until a value is picked. Not a label.
    defaultValuestring--Set on Select. The value picked on first render, when you don't control it. Not generated for iOS and Android.
    valuestring--Set on Select. The picked value, when you control it. Pair it with onValueChange.
    onValueChangefunction--Set on Select. Called with the new value when the user picks an option.
    namestring--Set on Select. Submits the value with a form under this name. Only on web. Not generated for iOS and Android.
    requiredboolean-falseSet on Select. A form can't be submitted until a value is picked. Say it in the label too, not only with this prop. Only on web. Not generated for iOS and Android.
    openboolean--Set on Select. Whether the list is open, when you control it. Pair it with onOpenChange.
    defaultOpenboolean-falseSet on Select. Opens the list on first render, when you don't control it.
    onOpenChangefunction--Set on Select. Called with true or false when the list opens or closes.
    direnumltr | rtl-Set on Select. Reading direction of the list and its keyboard. Leave it out to follow the page. Only on web. Not generated for iOS and Android.
    leadingIconnode--Set on SelectTrigger. A decorative Tabler icon before the value, such as a globe for language: 16px in sm, md and lg, 20px in xl. Hidden from screen readers.
    invalidboolean-falseSet on SelectTrigger. Marks the value as wrong: sets aria-invalid, which draws the danger border. Link the error text with aria-describedby.
    positionenumitem-aligned | popperitem-alignedSet on SelectContent. item-aligned opens the list over the trigger with the current option on it. popper opens it below or above the trigger like a menu; then side, align and sideOffset apply. Only on web. Not generated for iOS and Android.
    sideenumtop | right | bottom | leftbottomSet on SelectContent, with position="popper" only. The preferred side; the list flips when there is no room. Only on web. Not generated for iOS and Android.
    alignenumstart | center | endstartSet on SelectContent, with position="popper" only. How the list lines up with the trigger along that side. Only on web. Not generated for iOS and Android.
    options requiredSelectOption[]--The options of the list, in order: each has a value and a label. They open in a bottom Sheet, as rows of a grouped List, with the picked one marked. Native only; the web builds them from SelectItem. Only on iOS, Android.
    sheetTitle requiredstring--The name of the Sheet that holds the options. Shown as its title and read by assistive technology. Native only. Only on iOS, Android.
    sheetSizeenumsm | md | lgsmHow tall the Sheet may grow: sm for a short choice, lg for a long list, which then scrolls inside it. Native only. Only on iOS, Android.

    Slots

    NameRequiredDescription
    triggeryesSelectTrigger with a SelectValue inside.
    contentyesSelectContent with one SelectItem per option. Item labels are short nouns in sentence case. Long lists: SelectGroup with a SelectLabel per group, SelectSeparator between groups.

    Anatomy

    PartDescription
    rootSelect. Holds the value and the open state; renders nothing itself.
    triggerSelectTrigger: the button that shows the value and opens the list. Same fill, border and sizes as Input.
    valueSelectValue: the current option's text, or the placeholder when nothing is picked.
    iconTabler ChevronDownIcon at the end of the trigger. 16px in sm, md and lg, 20px in xl (DESIGN.md 9.1).
    contentSelectContent: the floating list on the raised surface, at least as wide as the trigger. Long lists scroll inside it.
    itemSelectItem: one option. Highlighted on hover and with the arrow keys.
    indicatorTabler CheckIcon (16px) at the end of the selected option.
    optionGroupSelectGroup: options under one heading. Renders no box of its own.
    groupLabelSelectLabel: the heading of a group, smaller than an option, in secondary text. Not selectable.
    separatorSelectSeparator: a line across the full list between two groups.
    scrollButtonSelectContent shows a caret at the top or bottom while more options are out of view; pointing at it scrolls the list. Tabler ChevronUpIcon or CaretDownIcon, 16px.
    hitAreaTransparent ::before centered on the trigger, never smaller than size-target-min (24px on mouse, 44px on touch), so sm stays a 44px touch target.
    leadingIconOptional decorative icon before the value, data-slot select-leading-icon, aria-hidden.

    Accessibility

    Role: combobox

    KeysAction
    TabMoves focus to the trigger and shows the focus ring.
    Enter, Space, ArrowDown, ArrowUpOpens the list with the current value highlighted.
    ArrowDown, ArrowUpMoves the highlight while the list is open.
    Home, EndHighlights the first or last option.
    Enter, SpacePicks the highlighted option, closes the list and returns focus to the trigger.
    EscapeCloses the list without changing the value and returns focus to the trigger.
    A to ZHighlights the next option that starts with the typed letters.
    • Give the trigger a visible label: an id on SelectTrigger and a label with htmlFor. aria-label only where the label is shown another way, such as a table column header.
    • Invalid: aria-invalid on SelectTrigger plus error text linked with aria-describedby. Never color alone.
    • Disabled uses the native disabled attribute on the trigger, so it leaves the tab order.
    • The trigger is a button with role combobox and the list a listbox; options are announced with their selected state.
    • Single value only. For several values use a group of checkboxes.
    • SelectGroup has role group and is labelled by its SelectLabel, so a screen reader announces the heading when the highlight enters the group. SelectLabel is not focusable and the arrow keys skip it.
    • SelectSeparator is decorative (aria-hidden).

    Install

    npx werewolf-ui add select

    Run npx werewolf-ui init once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See Installation for requirements and the alternative registry setup.