Skip to content

Radio

概要

Radio はラジオグループです。Radio.Root 配下に Radio.Item を並べて単一選択を構成し、onValueChange で現在値を受け取ります。

旧来の単体ラジオ API(RadioClassic)はレガシー扱いです。このページでは current API を案内します。

Usage 使用例

API Reference

Radio.Root Props

PropsTypeDefaultDescription
variant"solid" | "outline" | "subtle""outline"インジケーターの見た目です
size"xs" | "sm" | "md" | "lg""md"項目サイズです
colorPalettestringカラー CSS 変数へ反映する色です
valuestring制御モード時の現在値です
defaultValuestring非制御モード時の初期値です
onValueChange(detail: { value: string }) => void値変更時に呼ばれます
namestring自動生成hidden input 用の name 属性です
disabledbooleanfalseすべての項目を無効化します
readOnlybooleanfalse読み取り専用にします
orientation"horizontal" | "vertical""vertical"配置方向です
classstring追加クラスです
styleRecord<string, string>ルート要素のインラインスタイルです

Radio.Item Props

PropsTypeDefaultDescription
valuestring項目の識別値です
disabledbooleanfalse個別に無効化します
invalidbooleanfalseバリデーションエラーの見た目です
classstring追加クラスです
styleRecord<string, string>項目のインラインスタイルです

Subcomponents

ComponentDescription
Radio.Root単一選択グループ全体を管理します
Radio.Item1 件の選択項目です
Radio.ItemHiddenInputフォーム送信用の hidden radio input です
Radio.ItemIndicator丸い選択インジケーターです
Radio.ItemText項目ラベルです

使用例

tsx
<Radio.Root value={value} onValueChange={(details) => { value = details.value; }}>
  <Radio.Item value="a">
    <Radio.ItemHiddenInput />
    <Radio.ItemIndicator />
    <Radio.ItemText>オプション A</Radio.ItemText>
  </Radio.Item>
  <Radio.Item value="b">
    <Radio.ItemHiddenInput />
    <Radio.ItemIndicator />
    <Radio.ItemText>オプション B</Radio.ItemText>
  </Radio.Item>
</Radio.Root>

Mithril UI Kit Documentation