Skip to content

Select

A dropdown with optional groups and a search field, driven by the keyboard, for choices a native select cannot style or filter.

  • <aparte-select> + 2 parts
On this page
Open

<aparte-select> is the dropdown the model selector and the approval mode switch are built on. Its options are <aparte-option> children, optionally grouped in <aparte-optgroup>. The value is an attribute; a change fires aparte-select-change with the new value, its label and the previous value.

Open

searchable adds a field that filters the options as you type. A group has a label; it can be collapsible, and loading adds a spinner row while its options arrive.

html
<aparte-select disabled=""></aparte-select>
js
el.addEventListener('aparte-select-change', (e) => use(e.detail));

Installation and the framework-specific traps: React · Vue · Svelte · Angular.

<aparte-select> · class AparteSelect

Attributes

AttributeDescription
valueThe selected option’s value.
placeholderShown while nothing is selected.
disabledBlocks opening the dropdown.
searchableAdds a filter field above the options. Read on the first render only.
openReflects (and controls) whether the dropdown is open.

Properties

PropertyTypeDescription
valuestring
openboolean

Events

EventTypeDescription
aparte-select-openCustomEventThe dropdown opened. No detail.
aparte-select-closeCustomEventThe dropdown closed. No detail.
aparte-select-changeCustomEvent<AparteSelectChangeDetail>The selection changed; carries the new value, its label and the previous value.

CSS variables

VariableDefaultDescription
--aparte-select-bgvar(--aparte-surface-1)Trigger background. (The dropdown panel has its own token, --aparte-select-dropdown-bg, in both themes.)
--aparte-select-bordervar(--aparte-border-control)Border of the trigger and of the dropdown.
--aparte-select-border-hovervar(--aparte-border-control)Trigger border on hover.
--aparte-radius-selectvar(--aparte-radius-md)Corner radius of the trigger and the dropdown — the theme’s knob, beside --aparte-radius-input and the others. (It used to exist twice, as this and a private --aparte-select-radius with a different value.)
--aparte-select-textvar(--aparte-text)Colour of the trigger label (and of the options).
--aparte-select-chevronvar(--aparte-text-muted)Colour of the chevron, which rotates 180° while open.
--aparte-select-dropdown-bgvar(--aparte-surface-1)Dropdown panel background, in both themes (--aparte-surface-1 is dark-aware). It used to be read in the light theme only, the dark rule taking the TRIGGER’s background instead — so a transparent trigger made the panel see-through in the dark.
--aparte-select-shadow0 1px 3px rgba(0, 0, 0, 0.08), 0 10px 28px rgba(0, 0, 0, 0.16)Dropdown panel shadow.
--aparte-select-zvar(--aparte-z-dropdown)z-index of the dropdown. It is position: fixed, so this is the one knob that decides whether it lands above the rest of your page.

<aparte-option> · class AparteOption

Attributes

AttributeDescription
valueOption value
disabledDisabled state
selectedSelected state
data-statusFree-form status the host sets; styled, never read by core.

Properties

PropertyTypeDescription
valuestring
label (readonly)string
disabledboolean
selectedboolean

CSS variables

VariableDefaultDescription
--aparte-select-textvar(--aparte-text)Option text colour.
--aparte-select-option-hovervar(--aparte-surface-2)Background on hover, and for the keyboard-active row ([data-active]), which adds an inset --aparte-primary ring on top so the two are distinguishable.
--aparte-select-option-selectedcolor-mix(in srgb, var(--aparte-primary) var(--aparte-mark-tint), transparent)Background of the selected row. A tint by default: a solid accent fill with white text failed WCAG AA in both themes.
--aparte-select-option-selected-textvar(--aparte-select-text, var(--aparte-text))Text colour of the selected row. Set both this and the background to go back to a solid fill.

<aparte-optgroup> · class AparteOptgroup

Attributes

AttributeDescription
labelGroup label
collapsibleAdds the chevron and the click handler to the header — so it needs a label, and it is read only when that header is first built.
collapsedCollapsed state
loadingAppends a spinner row to the group; the options stay visible.

Properties

PropertyTypeDescription
labelstring
collapsibleboolean
collapsedboolean
loadingboolean

Events

EventTypeDescription
aparte-optgroup-toggleCustomEvent<AparteOptgroupToggleEventDetail>The group was collapsed or expanded.

CSS variables

VariableDefaultDescription
--aparte-text-muted—Colour of the group header label and of the loading row. The shared theme token: there is no optgroup-specific override, so restyling one group’s header means setting this on that element.
  • The trigger is a combobox (a button when the list is searchable) that opens a list box; the arrow keys move through the options, Enter picks one, Escape closes.
  • A group is a labelled group, so a screen reader names it with each option.
  • Give the select an aria-label, or a placeholder that says what it chooses.
  • Model selector — a select over providers and models.
  • Field — the native <select> with the field recipe.
  • Menu — a list of commands rather than a value.