Skip to main content

Select

Opens a list and returns the single option the user picks.

import { Select } from "@/fragments/ui";Source

Preview

<Select label="Team" placeholder="Choose a team">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="design">Design</Select.Item>
    <Select.Item value="engineering">Engineering</Select.Item>
    <Select.Item value="product">Product</Select.Item>

Installation

npx @usefragments/cli add select

Writes src/fragments/ui/components/Select plus what it imports, the globals stylesheet, and .fragments/registry-lock.json, then prints the packages to add. No account, no key.

Your own registry: publish from Fragments Cloud and add --registry org/name. Connect a workspace.

Anatomy

Select is a compound: import the root and reach its parts through dot notation.

  • Select.Trigger
  • Select.Content
  • Select.Item
  • Select.Group
  • Select.GroupLabel

Label, placeholder, three options.

<Select label="Team" placeholder="Choose a team">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="design">Design</Select.Item>
    <Select.Item value="engineering">Engineering</Select.Item>
    <Select.Item value="product">Product</Select.Item>
  </Select.Content>
</Select>

Examples

With Groups

Headed sections separate related options.

<Select placeholder="Choose a country">
  <Select.Trigger />
  <Select.Content>
    <Select.Group>
      <Select.GroupLabel>Americas</Select.GroupLabel>
      <Select.Item value="us">United States</Select.Item>

With Label and Helper Text

Helper text explains what the choice affects.

<Select label="Timezone" helperText="Used for reminders and calendar notifications.">
  <Select.Trigger placeholder="Select a timezone" />
  <Select.Content>
    <Select.Item value="pt">Pacific Time</Select.Item>
    <Select.Item value="mt">Mountain Time</Select.Item>
    <Select.Item value="ct">Central Time</Select.Item>

Error State

Red border, and the message replaces helper text.

<Select label="Team" placeholder="Choose a team" error="Choose a team before continuing">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="design">Design</Select.Item>
    <Select.Item value="engineering">Engineering</Select.Item>
  </Select.Content>

With Disabled Options

Unavailable options stay visible but cannot be picked.

<Select placeholder="Select a plan">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="free">Free</Select.Item>
    <Select.Item value="pro">Pro</Select.Item>
    <Select.Item value="enterprise" disabled>

Scrollable List

Caps at four rows and half-shows the fifth as a scroll hint.

<Select placeholder="Select a timezone">
  <Select.Trigger />
  <Select.Content maxVisibleItems={4}>
    <Select.Item value="utc-8">Pacific Time (UTC-8)</Select.Item>
    <Select.Item value="utc-7">Mountain Time (UTC-7)</Select.Item>
    <Select.Item value="utc-6">Central Time (UTC-6)</Select.Item>

Custom Max Visible Items

maxVisibleItems raises the cap to six rows.

<Select placeholder="Select a color">
  <Select.Trigger />
  <Select.Content maxVisibleItems={6}>
    <Select.Item value="red">Red</Select.Item>
    <Select.Item value="orange">Orange</Select.Item>
    <Select.Item value="yellow">Yellow</Select.Item>

Disabled

Dimmed and cannot be opened.

<Select disabled placeholder="Select an option">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="one">Option 1</Select.Item>
  </Select.Content>
</Select>

Options Prop

The options array replaces hand-written Select.Item children.

<Select
  placeholder="Select a team"
  options={[
    { value: "engineering", label: "Engineering" },
    { value: "design", label: "Design" },
    { value: "product", label: "Product" },

Long Localized Option

The trigger grows to fit a long label instead of clipping it.

<Select label="Workspace region" placeholder="Choose a workspace region">
  <Select.Trigger />
  <Select.Content>
    <Select.Item value="eu-central">
      Central European workspace with localized administrator recovery requirements
    </Select.Item>

API

Component props
Prop
Type
Default
Description
autoCompletestringNot setBrowser autofill hint for the hidden input
childrennodeNot set
classNamestringNot setWrapper class name
defaultOpenbooleanNot setDefault open state
defaultValuestringNot setDefault value for uncontrolled usage
disabledbooleanNot setWhether the field is disabled
errorunionNot setShow error styling. When a string is provided, it is displayed as an error message.
formstringNot setID of the form that owns the hidden input
helperTextstringNot setHelper text shown below the field
inputRefunionNot setRef to the hidden input element
labelstringNot setVisible label text
namestringNot setForm field name
onChangefunctionNot setAlias for onValueChange
onOpenChangefunctionNot setCalled when open state changes
onValueChangefunctionNot setCalled when selection changes
openbooleanNot setControlled open state
optionsarrayNot setConvenience API for simple selects (renders Select.Item entries when children are omitted)
placeholderstringNot setPlaceholder text when no value is selected
readOnlybooleanNot setWhether the user cannot choose a different option
requiredbooleanNot setWhether a selection is required
sizeenumsmmdlg"md"Size variant.
valuestringNot setControlled selected value
variantenumoutlineghostoutlineChrome. `outline` is the bordered field shell; `ghost` drops it for a compact, borderless control — for toolbars and dense rows, where a bordered field reads as a form. Pair with `size="sm"`.

Accessibility

  • Full keyboard navigation
  • Type-ahead jumps to matching options
  • Trigger and list carry the right ARIA roles

Guidance

Use when

  • Picking one value from a known list
  • More than 4-5 options — radios would crowd the form
  • Tight forms where the list should stay collapsed

Avoid when

  • Two or three options (use RadioGroup)
  • Users may type their own value (use Combobox)
  • Multiple selections (use a Checkbox group)
  • Actions rather than values (use Menu)

Do not use Select for a list of actions.

Don’t

<Select>Delete</Select>

Do

<Select label="Choose a value" options={[{ value: "design", label: "Design" }]} />
  • MenualternativeUse Menu for action-based dropdowns
  • InputsiblingUse Input for free-form text entry
  • CheckboxalternativeUse Checkbox group for multiple selections

Next steps