セグメント切替SegmentedControlExperimental

The small inline single-select toggle: 2–4 equal-width segments on a recessed track, the active one raised (the iOS/Android segmented look). For the compact either/or choices a B2C form is full of — 旅客区分 (大人/小児), 支払い (現金/IC/QR), 片道/往復, 出発/到着, 個人/法人, 日/週/月. A real role=radiogroup with role=radio segments, roving tabindex + arrow-key nav (WAI-ARIA), and a colour-safe selected state (raised surface, not colour alone); onValueChange is always a single string. Distinct from ToggleGroup (the general, content-fit, single-OR-multi toggle for desktop filters/formatting) and RadioCard (the large, priced choice CARD) — this is the small equal-width mode/segment switch. options[] of {value,label,icon?,disabled?}; controlled (value) or uncontrolled (defaultValue).

プレビュー

選択: 旅客=adult / 支払=ic / 期間=week。←→ キーで移動・選択。onValueChange は常に単一の string。

Props

表は横にスクロールできます
プロパティ初期値説明
optionsSegmentedControlOption[]-セグメント(2〜4が適量)。各 { value, label, icon?, disabled? }。
valuestring-制御された選択値。
defaultValuestring-非制御の初期値。
onValueChange(value: string) => void-選択値で発火=常に単一の string(配列にならない)。
size"sm" | "default" | "lg""default"セグメント高さ(default=h-9 / lg=h-11≥44px タッチ)。
fullWidthbooleantrue等幅セグメントで横幅いっぱい(セグメント表示)。
disabledbooleanfalseコントロール全体を無効化。
aria-labelstring-グループのアクセシブル名。
SegmentedControlOption.value / labelstring / ReactNode-選択時の値・セグメントのラベル。
SegmentedControlOption.icon / disabledReactNode / boolean-先頭アイコン・この1セグメントのみ無効化。

Usage

import { SegmentedControl } from "@gunjo/ui"

const [passenger, setPassenger] = React.useState("adult")

<SegmentedControl
  aria-label="旅客区分"
  value={passenger}
  onValueChange={setPassenger}     // always a single string
  options={[
    { value: "adult", label: "大人" },
    { value: "child", label: "小児" },
    { value: "disabled", label: "障がい者" },
  ]}
/>

使用コンポーネント