Skip to content

Data Input

Select

Dropdown single-select with an options preset or compound parts for custom rows.

import { Select } from '@var-ui/react';
Fruit
Plum

Select

Dropdown select (single, or multiple). Select with options (or titled sections) is the assembled preset (label, description, errorMessage, placeholder). renderOption customizes each row and renderValue the closed trigger. Compose Select.Root, Select.Trigger, Select.Value, Select.Popover, Select.ListBox, Select.Item, Select.Section, and Select.Header when a row needs more than that.

Custom item rows are React-only. Astro and HTML previews keep using a native <select> — group with <optgroup> there.

Examples

Default

Fruit
Demo.tsxTSX
import { Select } from '@var-ui/react';

<Select
  label="Fruit"
  options={[
    { value: 'apple', label: 'Apple' },
    { value: 'plum', label: 'Plum' },
  ]}
/>

Options list

Pass an options array of { value, label, disabled?, textValue? } objects. Use placeholder when no value is selected. textValue is the plain-text form used for typeahead and the closed trigger — set it when the label is a node or the row shows more than the label.

Fruit
Favorite fruit
Demo.tsxTSX
import { Grid, Select } from '@var-ui/react';

const options = [
  { value: 'apple', label: 'Apple' },
  { value: 'plum', label: 'Plum' },
  { value: 'orange', label: 'Orange' },
  { value: 'grape', label: 'Grape' },
];

<Grid columns={2} gap="lg">
  <Select label="Fruit" options={options} />
  <Select label="Favorite fruit" placeholder="Choose a fruit…" options={options} />
</Grid>

Sections

Pass sections instead of options to group options under headings. Each section is { title, options }. renderOption replaces the row content (the trigger still uses textValue), and renderValue replaces the closed-trigger content — it receives the selected option, or null when nothing is selected. In Astro and plain HTML, group a native <select> with <optgroup>.

Model
Demo.tsxTSX
import { Select } from '@var-ui/react';

const sections = [
  {
    title: 'Anthropic',
    options: [
      { value: 'claude-opus', label: 'claude-opus', textValue: 'claude-opus' },
      { value: 'claude-haiku', label: 'claude-haiku', textValue: 'claude-haiku' },
    ],
  },
  {
    title: 'OpenAI',
    options: [
      { value: 'gpt-5', label: 'gpt-5', textValue: 'gpt-5' },
      { value: 'gpt-5-mini', label: 'gpt-5-mini', textValue: 'gpt-5-mini' },
    ],
  },
];

<Select
  label="Model"
  placeholder="Choose a model…"
  sections={sections}
  renderOption={(option) => (
    <span style={{ display: 'flex', justifyContent: 'space-between' }}>
      {option.label}
      <span style={{ color: 'var(--var-ui-color-text-secondary)' }}>{prices[option.value]}</span>
    </span>
  )}
  renderValue={(option) => option?.label ?? 'Choose a model…'}
/>

Compound parts

Compose parts for full control over item content. textValue is the string used for typeahead and the default closed trigger. Compose Select.Value inside Select.Trigger when the closed value should match custom row chrome. The list renders in place, in the top layer (a native popover), so it inherits the theme of its ancestors and works inside a modal Dialog without any container prop.

Assignee
Demo.tsxTSX
import { Avatar, HStack, Select } from '@var-ui/react';

const PEOPLE = [
  { id: 'ada', name: 'Ada Lovelace' },
  { id: 'grace', name: 'Grace Hopper' },
];

<Select.Root>
  <Select.Label>Assignee</Select.Label>
  <Select.Trigger>
    <Select.Value>
      {({ selectedText, isPlaceholder }) =>
        isPlaceholder ? (
          'Select a person…'
        ) : (
          <HStack gap="sm">
            <Avatar name={selectedText} size="sm" />
            {selectedText}
          </HStack>
        )
      }
    </Select.Value>
  </Select.Trigger>
  <Select.Popover>
    <Select.ListBox>
      {PEOPLE.map((person) => (
        <Select.Item key={person.id} value={person.id} textValue={person.name}>
          <HStack gap="sm">
            <Avatar name={person.name} size="sm" />
            {person.name}
          </HStack>
        </Select.Item>
      ))}
    </Select.ListBox>
  </Select.Popover>
</Select.Root>

Props

Accessibility

Built on React Aria Components where applicable.