Select

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

Wann zu verwenden

  • Wird verwendet, um einen einzelnen Zustand aus mehreren Optionen auszuwählen.
  • Der Unterschied zu Radio besteht darin, dass Select weniger Platz beansprucht und viele Optionen enthalten kann.

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

Eigenschaft
Beschreibung
Typ
Standard

placeholder

Platzhaltertext, wenn keine Option ausgewählt ist string 'Select...'

name

Namensattribut für das versteckte Eingabefeld string

id

Eindeutiger Bezeichner für die Auswahlkomponente string

label

Beschriftungstext, der über dem Auswahlfeld angezeigt wird string

multiple

Ermöglicht die Auswahl mehrerer Optionen boolean false

iconLeft

Name des Lucide-Symbols, das links angezeigt werden soll IconName

iconRight

Name des Lucide-Symbols, das rechts angezeigt werden soll IconName 'ChevronsUpDown'

searchable

Aktiviert eine eingebettete Suchfunktion zum Filtern von Optionen boolean false

clearable

Zeigt eine Löschen-Schaltfläche an, wenn eine Option ausgewählt ist 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