Forms

Combobox

Single-select input that filters a fixed option list as the user types, combining free-text search with constrained values.

import { Combobox } from '@lostgradient/cinder';
formautocomplete
01

Overview

Reference usage

Filterable dropdown that combines a text input with a selectable option list.

Option group headings follow Cinder’s group label pattern.

Usage

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

<Combobox
  id="combobox-disabled"
  label="Plan"
  placeholder="Locked plan selection"
  {options}
  value="pro"
  disabled
/>

Grouped options

Give options a group name to render them under headings. Ungrouped options come first without a heading, and groups follow in order of first appearance, even when the groups interleave in options. Each heading shows the group name and how many of its options are listed. Typing filters across every group, keeps the headings of groups that still match, and hides the rest; arrow keys move through the options in the order they are displayed.

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

  const workflows = [
    { value: 'chat', label: 'Chat with an agent', group: 'Built in' },
    { value: 'digest', label: 'Daily digest', group: 'Recent' },
    { value: 'triage', label: 'Triage issues' },
  ];
</script>

<Combobox id="workflow" label="Workflow" options={workflows} />

The default filter matches an option's label and description, not its group name. maxVisibleOptions counts options in display order.

Rows with more to say

Set monospace when every option label is an identifier, such as WorkflowType. The option labels, field value, and placeholder use the code face. Use an option's code to show a separate identifier beside its label.

Option rows are at least 44px tall when a coarse pointer is available.

An option can carry more than a label. description is a second line (add descriptionTone: 'danger' when it is the reason the row is wrong, such as "Can’t load, order-refund.json line 12"; a disabled option stays listed so the reason can be read). code is a raw identifier drawn small and monospaced beside the label, suffix is muted words on the label's own line after a comma ("Chat with an agent, built in"), and meta is short text at the trailing edge ("4 steps", "any workflow"). The optionMeta snippet replaces meta when the trailing content needs more than text. The chosen option is tinted and carries a check, after the text by default or before it with selectedIndicator="start"; groupCountVisible={false} drops the counts from group headings. triggerLabel is what the closed picker shows once the option is chosen when that should be shorter than the row ("Central time" for the row "Central time, Chicago"); the open list always shows label.

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

  const events = [
    {
      value: 'run.error',
      label: 'A run fails',
      code: 'run.error',
      meta: 'any workflow',
      group: 'Runs',
    },
    {
      value: 'goal.failed',
      label: 'A goal fails',
      code: 'goal.failed',
      meta: 'any agent',
      group: 'Goals',
    },
  ];
</script>

<Combobox id="event" label="Event" options={events} selectedIndicator="start" />

Picker presentation

presentation="picker" draws the closed field as a button that shows the chosen option's name (and its code), with its description on a second line, and opens a panel with its own search field (searchPlaceholder) above the options. Use it when rows need room to read; use the default input presentation when typing into the field itself is the point. A picker has no text of its own, so customValueAllowed has no effect on it. matchCountVisible shows "2 of 16" beside the search field while something is typed.

The footer snippet draws content under the options, outside the role="listbox" element, so it stays visible while the list scrolls and when nothing matches. It receives { query, matchCount, totalCount }. A link or button in it is a keyboard stop of its own: Tab from the field lands on it with the list still open.

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

  const workflows = [
    { value: 'chat', label: 'Chat with an agent', description: 'Send a message each run.' },
  ];
</script>

<Combobox
  id="workflow"
  label="Workflow"
  presentation="picker"
  placeholder="Pick a workflow"
  searchPlaceholder="Search workflows"
  options={workflows}
  noMatchLabel={(query) => `No workflows match “${query}”.`}
>
  {#snippet footer()}
    No match? <a href="/workflows/new">Create one</a>
  {/snippet}
</Combobox>

Loading and load errors

loading keeps the field a combobox, with its label, required marker and chevron, and shows loadingLabel where the value goes; it does not open. Set stillLoadingAfter (10000 for the Cinder loading rule) and onCancel and Skeleton’s own "Still loading" status, with a ghost Cancel, appears under the field. It is not a banner.

loadError ({ title, description?, retryLabel? }) shows the failure above the options in the open panel, with a "Try again" button that calls onRetry. The options you do have stay listed and selectable beneath it. A divider appears below the error when visible options or empty-state text follow it. A footer draws its own divider.

The options list stays anchored to the field at every viewport width inside an open modal dialog, including a bottom sheet.

Live preview

Disabled combobox

02

When to use

Use when
  • Choosing one value from a long list where typing is faster than scrolling.
  • Letting users narrow options by substring while still requiring a constrained selection.
  • Use monospace when every option label is an identifier. An option's code adds a separate identifier beside its label.
  • Use loadError to show a failed load. Its divider appears before visible options or empty-state text. A footer draws its own divider.
  • Keep options anchored inside modal dialogs and sheets.
Avoid when
  • Picking from a short fixed list with no need to filter — use select instead.
  • Querying remote data or accepting free-text submissions — use search-field instead.
03

Examples

Basic combobox

Type to filter; the list is filtered with a case-insensitive substring match.

Disabled combobox

Disabled combobox cannot be focused or edited.

Event picker with code and meta

A raw identifier beside the name, what the event narrows by at the trailing edge, a check before the text, and the match count beside the search field.

Grouped options

Give options a group to render them under headings with counts. Typing filters across groups and keeps the headings of groups that still match.

Loading and a failed load

While loading the field stays a combobox and shows its loading label; after the threshold Skeleton's status line offers Cancel. A failed load shows its message and a retry above the options that did load.

Picker with search, footer and descriptions

`presentation="picker"` is a button that opens a panel with its own search field. Rows carry a description, the chosen row is checked, and the footer stays below the list, also when nothing matches.

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 (or the empty-string sentinel) at compile time.

04

Props

Props for combobox
Name
Type
Default
Description
id required text Unique identifier — required for label association and ARIA wiring.
value bindable AllowCustom extends true ? string : NoInfer<T>'' '' Currently selected value. Bindable. '' when nothing is selected.
onValueChange (value: AllowCustom extends true ? string : T) => void Called when an option, or an arbitrary value when enabled, is committed.
name text Native form field name. Renders a hidden input carrying the selected value.
textInputValue bindable text '' Free-text input value (the text the user has typed). Bindable.
options required ComboboxOption<T>[] Full set of options to filter. The sole inference source for T.
label text Visible label rendered in a <label> associated via for.
placeholder text Placeholder when no value is selected.
monospace boolean false Use when every option label is an identifier. Sets labels, field values, and placeholders in the monospace face. An option's code adds a separate identifier beside its label. Option rows have a 44px minimum height under a coarse pointer.
filter (option: ComboboxOption<T>, query: string) => boolean Custom synchronous filter. Receives an option and the current input value; returns true to keep. Defaults to case-insensitive substring match on label.
description text Helper text displayed below the input; wired via aria-describedby.
error text Validation error message; sets aria-invalid="true".
disabled boolean Disables the combobox. Inherited from a wrapping FormField when unset.
required boolean Marks the field required: renders the required marker on the label and sets aria-required on the input. Inherited from a wrapping FormField when unset.
maxVisibleOptions number 200 Hard cap on visible filtered options. Default 200.
customValueAllowed AllowCustom Allow committing typed text that is not present in options.
size 'sm' | 'md' | 'lg' 'md' Height step from the shared --cinder-control-height-* scale: sm 28px, md 32px, lg 40px, the same heights as a Button of that size.
appearance 'outlined' | 'filled' filled draws the control on the inset surface with a 12px radius. Under comfortable density, an unset appearance uses the same filled treatment and a 48px medium control; outlined opts out of that density default.
sheetBelow text Viewport width below which the options panel docks to the bottom edge as a sheet (Popover's sheetBelow, with focus kept in the input), instead of anchoring to the input. A simple CSS length such as '640px', or false to always anchor. Default '640px'.
presentation 'input' | 'picker' 'input' input types into the closed field; picker is a button that opens a panel with its own search field. See ComboboxPresentation. customValueAllowed has no effect on a picker, which has no text of its own to commit.
searchPlaceholder text 'Search' Picker only: placeholder, and accessible name, of the search field in the open panel ("Search workflows").
loading boolean false Draw the loading state: the field keeps its label, required marker and chevron, shows loadingLabel where the value goes, and does not open.
loadingLabel text 'Loading…' Text shown in the field while loading ("Loading workflows…").
stillLoadingAfter number While loading, milliseconds after which Skeleton's own "Still loading" status appears under the field. Use 10000 for the Cinder loading rule. Omit to never show it.
onCancel () => void While loading, called when Cancel in the "Still loading" status is pressed. The button renders only when this is set.
loadError { /** What failed, in plain words ("Couldn’t load workflows."). */ title: string; /** Why, and what still works ("Interborough didn’t answer. Chat with an…
Show full type { /** What failed, in plain words ("Couldn’t load workflows."). */ title: string; /** Why, and what still works ("Interborough didn’t answer. Chat with an agent is built in and still works."). */ description?: string; /** * Label of the retry button, which calls `onRetry`. * @default "Try again" */ retryLabel?: string; }
The option list failed to load; see ComboboxLoadError. The panel shows it above the options.
onRetry () => void Called when the retry button in loadError is pressed. The button renders only when this is set.
noMatchLabel text 'No results' The text of the empty panel when nothing matches, or a function of what was typed.
footer snippet Content drawn below the options, outside the role="listbox" element, so the arrow keys never reach it, and it stays visible while the options scroll and when none match. A link or button in it is a keyboard stop of its own, after the last option, reached with Tab from the field.
optionMeta snippet Content drawn at the trailing edge of each row, replacing the option's meta text. It sits inside the option, so it is part of the option's accessible name.
groupCountVisible boolean true Whether a group heading shows how many of the group's options are listed.
matchCountVisible boolean false Picker only: show "N of M" beside the search field while something is typed in it.
selectedIndicator 'start' | 'end' 'end' Where the check on the chosen option sits: after the text (end) or before it (start).
05

Accessibility

Option rows are at least 44px tall under a coarse pointer.