121
GitHub
Forms

Select

Provides an enhanced single-choice list when text search is not needed.

FrameworksAstro · React · Elements

Registry commandlumen add Select

InteractionEnhanced runtime

01

See it in context

Preview

02

Copy a working example

Usage

Astro examples assume UIPrimitives is mounted once in your root layout. Do not add the runtime next to each component instance.

astro
---
import { Select } from '@santi020k/lumen-astro'
---

<div style="display: grid; gap: 0.75rem; max-width: 20rem;">
  <label for="ex-select-framework">Framework</label>
  <Select id="ex-select-framework" name="framework" placeholder="Pick a framework">
    <option value="astro">Astro</option>
    <option value="react">React</option>
    <option value="elements">Web Components</option>
  </Select>
  <label for="ex-select-region">Region</label>
  <Select
    id="ex-select-region"
    name="region"
    options={[
      { label: 'US East', value: 'us-east' },
      { label: 'EU West', value: 'eu-west' },
      { disabled: true, label: 'APAC (soon)', value: 'apac' }
    ]}
    placeholder="Options via prop"
    size="sm"
  />
  <label for="ex-select-density">Density</label>
  <Select id="ex-select-density" name="density" placeholder="Large select" size="lg">
    <option value="compact">Compact</option>
    <option value="comfortable">Comfortable</option>
  </Select>
  <label for="ex-select-surface">Surface</label>
  <Select
    glass="subtle"
    id="ex-select-surface"
    name="surface"
    options={['Canvas', 'Surface', 'Glass']}
    placeholder="Glass enhanced select"
  />
</div>
---
import { Select } from '@santi020k/lumen-astro'
---

<div style="display: grid; gap: 0.75rem; max-width: 20rem;">
  <label for="ex-select-framework">Framework</label>
  <Select id="ex-select-framework" name="framework" placeholder="Pick a framework">
    <option value="astro">Astro</option>
    <option value="react">React</option>
    <option value="elements">Web Components</option>
  </Select>
  <label for="ex-select-region">Region</label>
  <Select
    id="ex-select-region"
    name="region"
    options={[
      { label: 'US East', value: 'us-east' },
      { label: 'EU West', value: 'eu-west' },
      { disabled: true, label: 'APAC (soon)', value: 'apac' }
    ]}
    placeholder="Options via prop"
    size="sm"
  />
  <label for="ex-select-density">Density</label>
  <Select id="ex-select-density" name="density" placeholder="Large select" size="lg">
    <option value="compact">Compact</option>
    <option value="comfortable">Comfortable</option>
  </Select>
  <label for="ex-select-surface">Surface</label>
  <Select
    glass="subtle"
    id="ex-select-surface"
    name="surface"
    options={['Canvas', 'Surface', 'Glass']}
    placeholder="Glass enhanced select"
  />
</div>
03

Choose your target

Add this component

Choose the package for your runtime. All adapters share the Lumen stylesheet. Use the matching registry command when you want a local wrapper for that framework.

bash@santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
pnpm add @santi020k/lumen-astro
bashAstro wrapper
lumen add Select
lumen add Select

API reference

Lumen-specific props and runtime attributes for the Astro primitive. React props follow the same names; Elements use equivalent kebab-case attributes where custom elements expose them.

AttributeValuesDefaultDescription
glassboolean | "subtle" | "strong"falseApplies the tokenized liquid-glass surface treatment with backdrop-filter fallbacks; "subtle" and "strong" adjust the fill intensity.
optionsArray<string | { label, value, disabled? }>[]Creates native option elements.
placeholderstring-Adds a disabled placeholder option and trigger placeholder text.
size"default" | "sm" | "md" | "lg""default"Controls select height and font size. The md value maps to the default size.
disabledbooleanfalseDisables the native select and enhanced trigger.
requiredbooleanfalseForwards required validation to the native select.
valuestring | number-Selects the matching option value.
class, classNamestring""Merges custom classes with the generated ui-* root classes.
...native attributesHTML attributes-Forwards standard attributes to the root element unless the component consumes them.

Keyboard interactions

Keyboard behavior provided by the Astro UIPrimitives runtime for this component.

KeyAction
Printable key on trigger or optionOpen the listbox and focus the next enabled option whose text starts with the typed buffer.
Escape on trigger or optionClose the listbox. Escape on an option also returns focus to the trigger.
ArrowDown, ArrowUp on triggerOpen the listbox and focus the next or previous enabled option.
Home, End on triggerOpen the listbox and focus the first or last enabled option.
Enter, Space on triggerOpen the listbox and focus the selected option, or the first enabled option.
Enter, Space on an optionSelect the focused option, sync the native select, and dispatch native input and change events from the select.
ArrowDown, ArrowUp on an optionMove focus through enabled options, wrapping at the ends.
Home, End on an optionMove focus to the first or last enabled option.