Select

The Select component allows users to choose one option from a list. It includes built-in styling for consistent design across browsers.

When To Use

  • Used to select a single state in multiple options.
  • The difference from Radio is that Select takes less space and can contain many options.

Example Usage

How to Use

To use the Select component, import it along with its subcomponents (SelectOption, SelectOptionGroup) and compose them.

example.astro
---
import Select from '@/components/data-entry/Select.astro';
import SelectOption from '@/components/data-entry/SelectOption.astro';
import SelectOptionGroup from '@/components/data-entry/SelectOptionGroup.astro';

---
<Select id="my-select" label="Choose an option">
  <SelectOptionGroup label="Group 1">
    <SelectOption value="1" label="Option 1" />
    <SelectOption value="2" label="Option 2" />
  </SelectOptionGroup>
</Select>

Multiple Selection

Searchable

Add the searchable prop to allow filtering options by typing.

Clearable & Custom Icons

Add the clearable prop to let users clear their selection. You can also customize the left and right icons using iconLeft and iconRight.

States

Selects can display success and error messages, or be disabled to prevent interaction.

This is available

This field is required

API

Property
Description
Type
Default

placeholder

Placeholder text when no option is selected string 'Select...'

name

Name attribute for the hidden input field string

id

Unique identifier for the select component string

label

Label text displayed above the select field string

multiple

Allows selecting multiple options boolean false

iconLeft

Name of the Lucide icon to display on the left IconName

iconRight

Name of the Lucide icon to display on the right IconName 'ChevronsUpDown'

searchable

Enables an embedded search input to filter options boolean false

clearable

Displays a clear button when an option is selected boolean false

error

Indicates an error state or displays an error message string | boolean

success

Indicates a success state or displays a success message string | boolean

disabled

Disables the component boolean false