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