Select

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

사용 시기

  • 여러 옵션에서 단일 상태를 선택하는 데 사용됩니다.
  • Radio와의 차이점은 Select가 공간을 덜 차지하며 많은 옵션을 포함할 수 있다는 것입니다.

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

속성
설명
타입
기본값

placeholder

옵션이 선택되지 않았을 때의 자리 표시자 텍스트 string 'Select...'

name

숨겨진 입력 필드의 이름 속성 string

id

선택 구성 요소의 고유 식별자 string

label

선택 필드 위에 표시되는 레이블 텍스트 string

multiple

여러 옵션 선택 허용 boolean false

iconLeft

왼쪽에 표시할 Lucide 아이콘 이름 IconName

iconRight

오른쪽에 표시할 Lucide 아이콘 이름 IconName 'ChevronsUpDown'

searchable

옵션을 필터링하기 위한 내장 검색 입력을 활성화합니다 boolean false

clearable

옵션이 선택되었을 때 지우기 버튼을 표시합니다 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