SegmentedControl
単一選択のセグメント。ToggleGroup の配列を隠す。
2〜4 個の選択肢を横一列で切り替えます。中身は ToggleGroup ですが、
単一選択なので value は文字列 1 つです — Base UI の配列 API を扱う手間はここで吸収されて
います。
export const client = "only";
import { useState } from "react";
import { SegmentedControl } from "@squadbase/vantage/components";
import { CalendarDays, CalendarRange, Calendar } from "lucide-react";
const options = [
{ label: "日次", value: "day", icon: CalendarDays },
{ label: "週次", value: "week", icon: CalendarRange },
{ label: "月次", value: "month", icon: Calendar },
];
export default function Example() {
const [grain, setGrain] = useState("week");
return (
<div className="flex w-[24rem] flex-col gap-4">
<SegmentedControl
options={options}
value={grain}
onChange={setGrain}
ariaLabel="集計の粒度"
/>
<SegmentedControl
options={options}
value={grain}
onChange={setGrain}
size="sm"
fullWidth
ariaLabel="集計の粒度(幅いっぱい)"
/>
</div>
);
}
import { SegmentedControl } from "@squadbase/vantage/components";
import type { SegmentOption } from "@squadbase/vantage/components";
PropType
options?SegmentOption[]
`{ label, value, icon?, disabled? }` の配列。
Type
SegmentOption[]value?string
選択中の値(**文字列 1 つ**)。
Type
stringonChange?(value: string) => void
変更時。
Type
(value: string) => voidsize?"sm" | "default" | "lg"
アイコンの大きさ。
Type
"sm" | "default" | "lg"Default
"default"fullWidth?boolean
親の幅いっぱいに広げる。
Type
booleanariaLabel?string
グループ全体の説明。
Type
stringicon には lucide-react のコンポーネントをそのまま渡せます。