import { useState } from "react"; import { Badge, Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@godxjp/ui/data-display"; import { Field, FormField, RadioGroup, RadioItem } from "@godxjp/ui/data-entry"; import { Flex, PageContainer } from "@godxjp/ui/layout"; /** 配送時間帯 · 選択肢が2〜4個を超えたときの見え方を確かめるための実データ。 */ const DELIVERY_SLOTS = [ "08:00-10:00", "10:00-12:00", "12:00-14:00", "14:00-16:00", "16:00-18:00", "18:00-20:00", "20:00-21:00", ]; const CLOSING_DAYS = ["5日", "10日", "15日", "20日", "25日", "月末"]; /** * RadioGroup — 2–4 mutually-exclusive choices, all visible at once (use Select * when the list is long or must collapse). Data-driven via an options array. * Composed only from real @godxjp/ui components. */ export default function Demo() { const [controlled, setControlled] = useState("email"); const [plan, setPlan] = useState("business"); return ( Vertical The default stacked layout. 選択肢ごとの説明 · プラン選択 options[].description が各行に付く。料金や条件を選択肢の外に書くと、どの行の 説明なのかが読み手側の推測になる。末尾の Badge は label を ReactNode にして 入れる。Badge は押せないのでラベルのクリック判定を壊さない。 ビジネス 推奨 ), description: "月額 12,000 円 · 30ユーザーまで · 監査ログと権限テンプレート", }, { value: "enterprise", label: "エンタープライズ", description: "個別見積 · SAML SSO · 専任担当とSLA", }, { value: "legacy", label: "ライト (新規受付終了)", disabled: true, description: "既存契約のみ継続。移行先はスタンダードです", }, ]} /> ラベルの長さ · 2文字と3行が同じ群に並ぶ 短いラベルと折り返す長いラベルが同居する。丸は1行目の中心に留まり、2行目以降は ラベル列の中で折り返す。ここが崩れると、長い選択肢だけ丸が沈んで列が波打つ。 optionType="button" · 箱型の選択 箱で選ばせたいときはこれが唯一の描画。カード型ラジオという別コンポーネントは 無い。role は radiogroup / radio のままなので、矢印キーの移動も name での送信も 変わらない。buttonStyle は選択中の塗りだけを決める。 選択肢が多いとき 13件を横並びにした形。全件が見えるので比較はできるが、この量になると走査に時間が かかり、Select のほうが速い。RadioGroup は「全部見せる価値がある2〜4件」が本来の 間合い。限界の見え方を置いておかないと、どこで乗り換えるべきか判断できない。 ({ value: slot, label: slot })), ...CLOSING_DAYS.map((day) => ({ value: day, label: `${day}締め` })), ]} /> 選択肢が1つだけ 一度選ぶと解除できない。選択の取り消しが要るなら Checkbox、即時に効く オン・オフなら Switch が正しい。1件のラジオを置いてしまう事故は、この見え方を 知らないまま起きる。 FormField · 必須とエラー radiogroup は widget なので、aria-invalid / aria-errormessage / aria-required まで含めた検証の配線を FormField がそのまま渡せる。エラー文は role=alert で 読み上げられる。readOnly は RadioGroup に無く、変更させない群は disabled で表す。 ({ value: day, label: day }))} /> Controlled · named · disabled Controlled callback and native form name with disabled options. Disabled group · custom children The children composition remains labelled and non-interactive. Horizontal orientation=“horizontal” for compact rows. ); }