Select

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

Cuándo usar

  • Se usa para seleccionar un único estado entre múltiples opciones.
  • La diferencia con Radio es que Select ocupa menos espacio y puede contener muchas opciones.

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

Propiedad
Descripción
Tipo
Por defecto

placeholder

Texto de marcador de posición cuando no hay ninguna opción seleccionada string 'Select...'

name

Atributo de nombre para el campo de entrada oculto string

id

Identificador único para el componente select string

label

Texto de etiqueta que se muestra sobre el campo select string

multiple

Permite seleccionar múltiples opciones boolean false

iconLeft

Nombre del icono Lucide para mostrar a la izquierda IconName

iconRight

Nombre del icono Lucide para mostrar a la derecha IconName 'ChevronsUpDown'

searchable

Habilita una entrada de búsqueda incrustada para filtrar opciones boolean false

clearable

Muestra un botón de borrado cuando se selecciona una opción 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