Forms

Select

Native select control with label, description, and error wiring for picking one value from a short fixed option list.

import { Select } from '@lostgradient/cinder';
formselection
01

Overview

Reference usage

Dropdown select for choosing a single option from a predefined list: the platform <select> by default, or a drawn listbox (presentation="listbox") when the options need descriptions, group headings, a check on the current one or a footer.

Option group headings follow Cinder’s group label pattern.

Usage

svelte
<script lang="ts">
  import { Select } from '@lostgradient/cinder';
  const options = [
    { value: 'free', label: 'Free' },
    { value: 'pro', label: 'Pro' },
    { value: 'enterprise', label: 'Enterprise (contact sales)', disabled: true },
  ];

  let plan = $state(options[0]?.value ?? 'free');
</script>

<Select id="plan" bind:value={plan} {options} label="Plan" />

Ghost variant

Inside a bordered container (a composer, an inline toolbar) use variant="ghost": no border or fill at rest, a neutral tint on hover and while open, the focus ring around the whole control, the chevron kept. Set flush on a ghost select that leads its row under text: it is pulled back by its own padding and border, so its text starts at the field edge, on the text above it; only its hover tint and ring reach past. Bordered selects remain for forms and filter bars. valuePrefix draws a muted word before the value.

svelte
<script lang="ts">
  import { Select } from '@lostgradient/cinder';

  let model = $state('sonnet');
</script>

<Select
  id="model"
  label="Model"
  labelVisible={false}
  valuePrefix="Model"
  variant="ghost"
  presentation="listbox"
  bind:value={model}
  options={[
    { value: 'opus', label: 'Claude Opus 5.5', description: 'Most capable, tools, images' },
    { value: 'sonnet', label: 'Claude Sonnet 5.5', description: 'Balanced, tools, images' },
  ]}
/>

Listbox presentation

presentation="listbox" draws a button that opens a listbox. Options can carry a description, a note and a group; groups names the headings, divides them and can add a non-selectable message; leading draws a mark before each option; footer renders outside the listbox with its own keyboard stop; placeholder shows while no option is selected; readonly keeps the value focusable but not changeable. See select.a11y.md for the keyboard model. An option's suffix adds muted words on the label's own line ("Nightly archiver, no description"), and triggerSuffix adds muted words after the value in the trigger only ("Claude Sonnet 5.5, Anthropic"). An option marked code is an identifier, such as a secret's key: its label is drawn in monospace, in the list and in the trigger once chosen, and, when it does not fit, cut in its middle (Text truncate="middle") with the whole label in a tooltip. Its accessible name is the whole label followed by its note, so the cut never splits it; the field's label, help and placeholder keep the field's own face. onValueChangeRequest can refuse or replace a pick before it is written, and the control shows what it returned, never the refused pick.

Width

A default select stretches to fill its container. Set width="auto" to size it to its content instead, no wider than the container, keeping the bordered look and the height size names, so a bordered select can sit in a toolbar without a width of its own. The ghost and inline variants already size to their content and draw the same with either value. The root carries data-cinder-width with either value. With presentation="listbox" the list is no longer held to the trigger's width, as for ghost and inline: it is as wide as its content, and never narrower than 16rem.

svelte
<script lang="ts">
  import { Select } from '@lostgradient/cinder';

  let sort = $state('newest');
</script>

<Select
  id="sort"
  label="Sort"
  labelVisible={false}
  width="auto"
  options={[
    { value: 'newest', label: 'Newest' },
    { value: 'oldest', label: 'Oldest' },
  ]}
  bind:value={sort}
/>

Appearance and the inline variant

The native select never shows the browser's caret: it uses appearance: none and Cinder's masked chevron (18px, 12px from the end, with 40px of end padding), in every appearance. appearance="filled" draws an inset fill inside the 1px --cinder-control-border edge with a 12px radius, and under data-density="comfortable" a select with no appearance is filled and 48px tall; appearance="outlined" opts out. The ghost variant has no fill and ignores appearance; the inline variant is outlined unless appearance="filled".

variant="inline" is for a select inside a sentence. It takes the surrounding text size and weight, the sm height and an auto width, whatever size says. The field is an inline-level box, but it holds block-level children, so put it in a div or a flex row rather than a p:

svelte
<script lang="ts">
  import { Select } from '@lostgradient/cinder';

  let sender = $state('anyone');
</script>

<div>
  Archive messages from
  <Select
    id="sender"
    label="Sender"
    labelVisible={false}
    variant="inline"
    options={[
      { value: 'anyone', label: 'anyone' },
      { value: 'contacts', label: 'my contacts' },
    ]}
    bind:value={sender}
  />
  after a week.
</div>

Inside an open modal dialog, including a bottom sheet, the drawn listbox stays anchored to the field at every viewport width.

Live preview

Accent tone for the select that names the target

Message Assistant…

02

When to use

Use when
  • Picking one value from a short list where the native control's mobile behavior is desirable.
  • Composing inside a form with built-in label and aria-describedby plumbing.
  • Keeping a drawn listbox anchored to the field inside an open modal dialog, including a bottom sheet.
Avoid when
  • Filtering a long list by typing — use combobox instead.
  • Building a custom-styled menu trigger — use dropdown instead.
03

Examples

Accent tone for the select that names the target

tone="accent" draws the value in the accent colour and weight, for the one select that says what its container is about to do, such as the agent a new chat is with. The Permissions select below it only sets an option and keeps the default tone.

Agent picker: descriptions, notes, an unavailable group and a footer

A ghost listbox select. Each agent has a name and a one-sentence description; model agents show "Needs a provider" while none is connected; agents held back by a disabled plugin sit under "Unavailable" with the reason and cannot be picked; the one link is a footer outside the listbox with its own focus stop.

Basic select

Native select with label and bound string value.

Select with disabled option

Individual options can be marked disabled.

Ghost variant in a bordered row

variant="ghost" has no border or fill at rest, a neutral tint on hover and while open, the quiet focus ring around the whole control, and keeps its chevron. Inside a bordered container the controls read as one surface, and the first, marked flush, starts its text on the composer’s text edge. At phone width the row wraps, and a control that still does not fit shortens its value with an ellipsis instead of running past the border.

Model select grouped by provider

One select grouped by provider. Anthropic lists its models with abilities under each name and a check on the chosen one; providers that are not connected keep a heading with non-selectable text and a link. Closed, the trigger reads the model and its provider.

Model select: loading and error

While models load the trigger shows its placeholder ("Loading models") and does not open. A listbox select takes the same error prop as the native one: red message, aria-invalid and aria-describedby.

Permissions select with help under each option

A ghost listbox select. The current option carries a check, its help sits under it, and the control keeps its tint and quiet ring while open.

Typed options with as const

Use `as const` on the options array to infer a precise literal-union type for `T`. TypeScript then rejects any `value` that is not a member of the union at compile time.

Select with an error

A required Select whose placeholder is still selected is invalid: pass a non-empty `error` string to mark it. The control gets `aria-invalid="true"`, the message is wired via `aria-describedby`, and a danger ring replaces the focus ring when the invalid control is focused.

04

Props

Props for select
Name
Type
Default
Description
id required text Unique identifier — required for label association and ARIA wiring.
value bindable NoInfer<T> Bound selected value. undefined when nothing is selected.
options SelectOption<T>[] [] Options to render as <option> children. The sole inference source for T.
label text Visible label rendered in a <label> associated via for.
labelVisible boolean true Whether the label is visibly rendered. Set false to visually hide it while keeping it available to assistive technology.
description text Helper text rendered below the control; wired via aria-describedby.
error text Validation error message; sets aria-invalid="true" and is wired via aria-describedby.
required boolean Marks the control required and sets the native required attribute.
disabled boolean Disables the control.
size 'sm' | 'md' | 'lg' 'md' Height step from the shared --cinder-control-height-* scale: sm 28px, md 32px, lg 40px. Replaces the native list-box size attribute, which Cinder does not forward.
variant 'default' | 'ghost' | 'inline' 'default' Visual style. ghost has no border or fill at rest, a neutral tint on hover and while open, the focus ring wrapping the whole control, and keeps its chevron: use it for a select inside a bordered container (a composer, an inline toolbar) so the row of controls reads as one surface. inline sits inside a sentence ("Archive messages from [sender]"): it takes the surrounding text size and weight, the sm height and an auto width, whatever size says. default is the bordered select for forms and filter bars.
width 'fill' | 'auto' 'fill' How wide the default variant is. fill stretches to the container, as every select does unless told otherwise. auto sizes to the content (inline-size: fit-content, no wider than the container) and keeps the size height and the bordered look, so a bordered select can sit in a toolbar without a width of its own. The ghost and inline variants already size to their content and draw the same with either value.
appearance 'outlined' | 'filled' | undefined How the bordered select is drawn. "outlined" is the control fill inside a 1px edge. "filled" is an inset fill inside the same 1px --cinder-control-border edge, which keeps the 3:1 boundary the fill alone would lose, with a 12px radius, a 48px height in the comfortable density and the 2px focus ring. Left unset, the select follows its density: filled under data-density="comfortable", outlined otherwise. The ghost variant has no fill and ignores it; inline is outlined unless "filled" is set. The native caret never shows: the Cinder chevron is the only one.
quietBorder boolean false Uses Cinder's opt-in quiet resting boundary for an outlined control in a dense settings surface. Hover, focus, invalid, disabled, and high-contrast states keep their standard treatments.
tone 'default' | 'accent' 'default' Colour of the value. accent draws it in the accent colour and weight, for the one select that names what the container it sits in is about to do (the agent a new chat is with), beside default controls that only set options.
flush boolean false The ghost select leads a row under text, so its words line up with that text: it is pulled back by its inline padding and its 1px transparent border, so its text starts at the field edge, and only its hover tint and ring reach past it. Only the ghost variant reads it; set it on the select that starts its row, never on one after another control.
presentation 'native' | 'listbox' 'native' Native <select> or a drawn listbox; see SelectPresentation. The listbox-only props below (placeholder, valuePrefix, leading, footer, groups, and the rich option fields) do nothing in the native presentation.
placeholder text Listbox only: text shown in the trigger while no option is selected, such as Loading models.
valuePrefix text Listbox only: muted text drawn before the value in the trigger ("Model" before "Claude Sonnet 5.5"). It is decorative and hidden from assistive technology; the name comes from label.
leading snippet Listbox only: a mark drawn before each option's label and before the selected value in the trigger, such as an avatar. Decorative.
groups SelectGroup[] Listbox only: headings, dividers and messages for the option groups.
footer snippet Listbox only: content drawn below the options, outside the role="listbox" element, so the arrow keys never reach it. A link or button in it is a keyboard stop of its own, after the last option, reached with Tab from the trigger.
readonly boolean false The control shows its value and can be focused, but does not open and does not change. Exposed as aria-readonly on the listbox presentation; the native presentation also blocks the picker.
mutating boolean false Marks a select that changes something. Inside a stale <StaleRegion> it goes inert: it can be focused but not opened or changed, carries aria-disabled, and the region's reason describes it. It returns by itself when the region stops being stale.
onValueChange (value: T) => void Called with the new value when the person picks an option.
onValueChangeRequest (next: T) => T | void Intercepts the option the person picked before the bindable value is written. Return a replacement value to use instead, including the current value to refuse the pick; return nothing to accept it. The control shows what the hook returned, never the refused pick.
sheetBelow text '640px' Listbox only: viewport width below which the options dock to the bottom edge as a sheet. A simple CSS length such as '640px', or false to always anchor.
name text
onchange ChangeEventHandler<HTMLSelectElement>undefinednull
onmousedown MouseEventHandler<T> | undefined | null
onkeydown KeyboardEventHandler<T>undefinednull