Radio

The Radio component is used for selecting a single option from a list. It supports dynamic label and error slots, and can be grouped using RadioGroup.

いつ使うか

  • 複数のオプションから単一のステータスを選択するために使用されます。
  • Selectとの違いは、Radioがユーザーに見えるため、選択肢の比較が容易になることです。つまり、選択肢が多すぎないようにする必要があります。

Example Usage

Radio Groups & Deselection

Use the RadioGroup component to manage layouts and grouping. You can enable canDeselect to allow users to uncheck a selected radio option.

States

Horizontal Layout

Slots

You can fully customize the label and error messages using the default slot and error slot.

How to Use

astro
---
import Radio from '@/components/data-entry/Radio.astro';
import RadioGroup from '@/components/data-entry/RadioGroup.astro';

---
<RadioGroup name="options">
  <Radio id="opt1" label="Option 1" name="options" />
  <Radio id="opt2" label="Option 2" name="options" />
</RadioGroup>

API

プロパティ
説明
タイプ
デフォルト

label

ラジオボタンのラベルテキスト string

name

ラジオボタンをグループ化するための名前属性 string

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