Skip to main content
PROYECTOVIVIANA

Select

Select allows users to choose a single option from a dropdown list. It's ideal for forms where space is limited.

Import

import {
  Select,
  SelectTrigger,
  SelectValue,
  SelectListBox,
  SelectOption
} from '@proyecto-viviana/solid-spectrum';

Basic Usage

A simple select with static options.

Favorite fruit

Selected: None

<Select items={items} selectedKey={selected()} onSelectionChange={setSelected}>
  <SelectTrigger>
    <SelectValue placeholder="Select a fruit" />
  </SelectTrigger>
  <SelectListBox>
    {(item) => <SelectOption id={item.id}>{item.name}</SelectOption>}
  </SelectListBox>
</Select>

With Description

Add a description to provide additional context.

CountrySelect your country of residence
<Select label="Country" description="Select your country of residence" items={items}>...</Select>

Disabled Options

Individual options can be disabled.

Plan
<Select items={items} getDisabled={(item) => item.isDisabled ?? false}>...</Select>

Disabled State

The entire select can be disabled.

Disabled select
<Select label="Disabled select" isDisabled items={items}>...</Select>

Required Field

Mark the select as required for form validation.

Required field
<Select label="Required field" isRequired items={items}>...</Select>

Select Props

Props

PropTypeDefaultDescription
itemsT[]Collection of selectable items
labelstringLabel for the select field
descriptionstringHelp text below the select
errorMessagestringError message to display
selectedKeystring | nullCurrently selected key (controlled)
defaultSelectedKeystringDefault selected key (uncontrolled)
onSelectionChange(key: string | null) => voidHandler called when selection changes
isDisabledbooleanfalseWhether the select is disabled
isRequiredbooleanfalseWhether a selection is required
childrenJSX.ElementSelectTrigger and SelectListBox

SelectOption Props

Props

PropTypeDefaultDescription
idstringUnique identifier for the option
textValuestringText value for typeahead (defaults to children text)
isDisabledbooleanfalseWhether the option is disabled
childrenJSX.ElementOption content

Accessibility

  • Uses listbox pattern with proper ARIA roles
  • Full keyboard navigation: Arrow keys, Home, End, Page Up/Down
  • Type-ahead search to quickly find options
  • Announces selection changes to screen readers
  • Focus trapped within popover when open