# Select

Choose a predefined value from an accessible anchored list.

Choose a predefined value from an accessible anchored list.

After selection, `Select.Value` displays the selected item's label while `value`,
`onValueChange`, and native form submission continue to use its underlying value.

<p className="zenos-base-ui-source">
  Backed by <a href="https://base-ui.com/react/components/select">Base UI Select</a> for upstream
  behavior and configuration. Zenos owns the public API, styling, and composition shown on this
  page.
</p>

```tsx
import { Field, Select } from "@zentara-co/zenos-ui";

function SelectExample() {
  return (
    <Field.Root className="w-full max-w-sm">
      <Field.Label>Environment</Field.Label>
      <Select.Root defaultValue="production">
        <Select.Trigger>
          <Select.Value />
        </Select.Trigger>
        <Select.Content>
          <Select.Item value="production">Production</Select.Item>
          <Select.Item value="staging">Staging</Select.Item>
          <Select.Item value="development">Development</Select.Item>
        </Select.Content>
      </Select.Root>
    </Field.Root>
  );
}
```

## Variants

`default` uses the bordered input surface, `filled` uses the gray subtlest fill, and `none` is borderless. Set `variant` on `Select.Root`; the trigger inherits it unless overridden.

```tsx
import { Select, Stack } from "@zentara-co/zenos-ui";

function SelectSurfaceVariantsExample() {
  return (
    <Stack gap="3" className="w-full max-w-xs">
      {(["default", "filled", "none"] as const).map((variant) => (
        <Select.Root key={variant} variant={variant}>
          <Select.Trigger aria-label={`${variant} select`}>
            <Select.Value placeholder="Value" />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="one">One</Select.Item>
            <Select.Item value="two">Two</Select.Item>
          </Select.Content>
        </Select.Root>
      ))}
    </Stack>
  );
}
```

```tsx
import { Select, Stack } from "@zentara-co/zenos-ui";

type CatalogVariantProps = { limit?: number };

const limited = <T,>(items: readonly T[], limit?: number) =>
  limit === undefined ? items : items.slice(0, limit);

const formControlSurfaceVariants = ["default", "filled", "none"] as const;

function SelectVariantsExample({ limit }: CatalogVariantProps = {}) {
  if (limit !== undefined) {
    return (
      <Stack gap="3" className="w-full max-w-sm">
        {limited(formControlSurfaceVariants, limit).map((variant) => (
          <Select.Root key={variant} variant={variant}>
            <Select.Trigger aria-label={`${variant} select`}>
              <Select.Value placeholder="Value" />
            </Select.Trigger>
            <Select.Content>
              <Select.Item value="one">One</Select.Item>
            </Select.Content>
          </Select.Root>
        ))}
      </Stack>
    );
  }

  return (
    <Stack gap="3" className="w-full max-w-sm">
      {formControlSurfaceVariants.map((variant) => (
        <Select.Root key={variant} variant={variant}>
          <Select.Trigger aria-label={`${variant} select`}>
            <Select.Value placeholder="Value" />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="one">One</Select.Item>
            <Select.Item value="two">Two</Select.Item>
          </Select.Content>
        </Select.Root>
      ))}
    </Stack>
  );
}
```

## Custom styling

Every Select part accepts `className`. Style the trigger directly, then style `Select.Content` and its `listClassName` separately because the popup is rendered in a portal. Stable `data-slot` and Base UI state attributes can target highlighted and selected options without replacing the component's behavior.

```tsx
import { Field, Select } from "@zentara-co/zenos-ui";

function SelectCustomStylingExample() {
  return (
    <Field.Root className="w-full max-w-sm">
      <Field.Label>Workspace accent</Field.Label>
      <Select.Root defaultValue="teal">
        <Select.Trigger className="rounded-full border-border-accent-teal-default bg-background-accent-teal-subtlest-default px-4 text-text-accent-teal-bolder hover:bg-background-accent-teal-subtlest-hover focus-visible:bg-background-accent-teal-subtlest-pressed">
          <Select.Value />
        </Select.Trigger>
        <Select.Content
          className="rounded-xl border border-border-accent-teal-default bg-background-accent-teal-subtlest-default shadow-overlay [&_[data-slot=select-item-indicator]]:text-text-accent-teal-bolder [&_[data-slot=select-item][data-highlighted]]:bg-background-accent-teal-subtlest-hover [&_[data-slot=select-item][data-selected]]:bg-background-accent-teal-subtlest-pressed [&_[data-slot=select-item]]:rounded-lg [&_[data-slot=select-item]]:text-text-accent-teal-bolder"
          listClassName="p-1.5"
        >
          <Select.Item value="teal">Teal</Select.Item>
          <Select.Item value="blue">Blue</Select.Item>
          <Select.Item value="purple">Purple</Select.Item>
        </Select.Content>
      </Select.Root>
      <Field.Description>A branded treatment built from semantic color tokens.</Field.Description>
    </Field.Root>
  );
}
```

## Sizes

Set `size` on `Select.Root` to keep the trigger consistent with neighboring form controls. A trigger-level size can override the root when needed.

```tsx
import { Select, Stack } from "@zentara-co/zenos-ui";

function SelectSizesExample() {
  return (
    <Stack gap="3" className="w-full max-w-sm">
      {(["sm", "md", "lg"] as const).map((size) => (
        <Select.Root key={size} size={size} defaultValue="production">
          <Select.Trigger aria-label={`${size} environment`}>
            <Select.Value />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="production">Production</Select.Item>
            <Select.Item value="staging">Staging</Select.Item>
            <Select.Item value="development">Development</Select.Item>
          </Select.Content>
        </Select.Root>
      ))}
    </Stack>
  );
}
```

## Disabled and invalid

Disable the root or wrap the field in `Field.Root` with `disabled` when the entire selection is unavailable. For validation, set `Field.Root` to `invalid`; the trigger inherits `aria-invalid` and matches Input invalid styling.

```tsx
import { Field, Grid, Select } from "@zentara-co/zenos-ui";

function SelectStatesExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full max-w-2xl">
      <Field.Root>
        <Field.Label>Workspace</Field.Label>
        <Select.Root defaultValue="engineering" disabled>
          <Select.Trigger>
            <Select.Value />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="engineering">Engineering</Select.Item>
          </Select.Content>
        </Select.Root>
        <Field.Description>This selection is managed by your organization.</Field.Description>
      </Field.Root>

      <Field.Root invalid>
        <Field.Label>Region</Field.Label>
        <Select.Root>
          <Select.Trigger aria-invalid="true">
            <Select.Value placeholder="Select a region" />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="apac">Asia Pacific</Select.Item>
            <Select.Item value="emea">Europe, Middle East, and Africa</Select.Item>
          </Select.Content>
        </Select.Root>
        <Field.Error>A region is required.</Field.Error>
      </Field.Root>
    </Grid>
  );
}
```

## Scrollable lists

`Select.Content` scrolls by default when options exceed the popup height (up to `16rem` or the available viewport space). The list is the scroll container; wheel, touch, and keyboard navigation keep working, and hover scroll arrows appear on pointer devices for long lists. Set `scrollable={false}` to render a static list (same padding as Autocomplete) or pass `listClassName` to adjust max height.

```tsx
import { Field, Select } from "@zentara-co/zenos-ui";

const timeZones = [
  "Pacific/Honolulu",
  "America/Anchorage",
  "America/Los_Angeles",
  "America/Denver",
  "America/Chicago",
  "America/New_York",
  "America/Sao_Paulo",
  "Atlantic/Reykjavik",
  "Europe/London",
  "Europe/Berlin",
  "Europe/Helsinki",
  "Africa/Cairo",
  "Asia/Dubai",
  "Asia/Kolkata",
  "Asia/Bangkok",
  "Asia/Singapore",
  "Asia/Tokyo",
  "Australia/Sydney",
  "Pacific/Auckland",
];

function SelectScrollableExample() {
  return (
    <Field.Root className="w-full max-w-sm">
      <Field.Label>Time zone</Field.Label>
      <Select.Root defaultValue="America/Chicago">
        <Select.Trigger>
          <Select.Value placeholder="Select a time zone" />
        </Select.Trigger>
        <Select.Content>
          {timeZones.map((zone) => (
            <Select.Item key={zone} value={zone}>
              {zone.replaceAll("_", " ")}
            </Select.Item>
          ))}
        </Select.Content>
      </Select.Root>
      <Field.Description>
        Long lists scroll inside the popup. Hover the top or bottom edge to step through options
        with the scroll arrows.
      </Field.Description>
    </Field.Root>
  );
}
```

## Groups and separators

Use groups to divide a longer option list into meaningful sections. Individual items can be disabled without disabling the rest of the Select.

```tsx
import { Field, Select } from "@zentara-co/zenos-ui";

function SelectGroupsExample() {
  return (
    <Field.Root className="w-full max-w-sm">
      <Field.Label>Deployment region</Field.Label>
      <Select.Root defaultValue="singapore">
        <Select.Trigger>
          <Select.Value />
        </Select.Trigger>
        <Select.Content>
          <Select.Group>
            <Select.GroupLabel>Asia Pacific</Select.GroupLabel>
            <Select.Item value="singapore">Singapore</Select.Item>
            <Select.Item value="sydney">Sydney</Select.Item>
            <Select.Item value="tokyo">Tokyo</Select.Item>
          </Select.Group>
          <Select.Separator />
          <Select.Group>
            <Select.GroupLabel>Europe</Select.GroupLabel>
            <Select.Item value="frankfurt">Frankfurt</Select.Item>
            <Select.Item value="london">London</Select.Item>
            <Select.Item value="restricted" disabled>
              Private region (unavailable)
            </Select.Item>
          </Select.Group>
        </Select.Content>
      </Select.Root>
    </Field.Root>
  );
}
```

## Controlled selection and positioning

Pair `value` with `onValueChange` when application state owns the selection. `Select.Content` accepts `side`, `align`, and collision options and handles the portal, positioner, popup, scroll arrows, and list internally.

```tsx
import { Field, Select, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function SelectControlledExample() {
  const [value, setValue] = useState("review");

  return (
    <Stack gap="3" className="w-full max-w-sm">
      <Field.Root>
        <Field.Label>Publication status</Field.Label>
        <Select.Root value={value} onValueChange={(next) => setValue(next ?? "review")}>
          <Select.Trigger>
            <Select.Value />
          </Select.Trigger>
          <Select.Content align="end" side="bottom">
            <Select.Item value="draft">Draft</Select.Item>
            <Select.Item value="review">In review</Select.Item>
            <Select.Item value="published">Published</Select.Item>
          </Select.Content>
        </Select.Root>
      </Field.Root>
      <Text size="s" color="subtle" aria-live="polite">
        Current value: {value}
      </Text>
    </Stack>
  );
}
```

## Motion

The option list fades, scales, and moves from its resolved side when opening, then reverses that movement when closing. Reduced-motion preferences remove the animation automatically.

Open each select. The first list animates in and out. `disableMotion` makes the second appear and disappear immediately.

```tsx
import { Field, Grid, Select } from "@zentara-co/zenos-ui";

function SelectMotionExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      <Field.Root>
        <Field.Label>With motion</Field.Label>
        <Select.Root>
          <Select.Trigger aria-label="Status with motion">
            <Select.Value placeholder="Choose status" />
          </Select.Trigger>
          <Select.Content>
            <Select.Item value="draft">Draft</Select.Item>
            <Select.Item value="published">Published</Select.Item>
          </Select.Content>
        </Select.Root>
      </Field.Root>
      <Field.Root>
        <Field.Label>Without motion</Field.Label>
        <Select.Root>
          <Select.Trigger aria-label="Status without motion">
            <Select.Value placeholder="Choose status" />
          </Select.Trigger>
          <Select.Content disableMotion>
            <Select.Item value="draft">Draft</Select.Item>
            <Select.Item value="published">Published</Select.Item>
          </Select.Content>
        </Select.Root>
      </Field.Root>
    </Grid>
  );
}
```

## Variants

default, filled, none

## Sizes

sm, md, lg

## Anatomy

```text
Select.Root
Select.Trigger
Select.Value
Select.Content
Select.Group
Select.GroupLabel
Select.Item
Select.Separator
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| value | string | — | Controlled selected value. |
| defaultValue | string | — | Initial uncontrolled value. |
| onValueChange | (value: string \| null, eventDetails) => void | — | Runs when the selected value changes. |
| open / defaultOpen | boolean | — | Controlled or initial popup visibility. |
| onOpenChange | (open: boolean, eventDetails) => void | — | Runs when popup visibility changes. |
| size | sm \| md \| lg | md | Control height inherited by the trigger. |
| variant | default \| filled \| none | default | Trigger surface style (`filled` uses the subtle neutral fill). |
| Trigger.variant | default \| filled \| none | — | Overrides the visual treatment inherited from Select.Root. |
| disabled / required / name | boolean / boolean / string | — | Native form-control semantics forwarded through Base UI. |
| Content.side / align | top \| right \| bottom \| left / start \| center \| end | bottom / start | Preferred popup placement relative to the trigger. |
| Content.sideOffset | number | 4 | Space between the trigger and popup. |
| Content.alignItemWithTrigger | boolean | false | Overlaps the trigger and aligns the selected item with it. |
| Content.scrollable | boolean | true | Caps popup height and enables list scrolling with optional hover scroll arrows. |
| Content.disableMotion | boolean | false | Disables the popup enter and exit animation for this instance. |
| Content.listClassName | string | — | Extra classes on the list inside Content (for example a custom max height). |
| native props | React.Base UI Select props | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

Select exposes a combobox trigger and listbox popup through Base UI. Arrow keys open and move through options, Enter or Space selects, and Escape closes the popup and returns focus to the trigger. `Home` and `End` move to the first and last available options. Associate the trigger with a visible `Field.Label`, and preserve disabled and invalid semantics rather than representing them through color alone.

Source: https://zenos-ui.pages.dev/components/select/