Pick one of a few options, like 7d / 30d / 90d or Chart / Table.
import { SegmentedControl } from "@kivu-ui/react"On this page
import { SegmentedControl } from "@kivu-ui/react";value: 30d
import { useState } from "react";
import { SegmentedControl } from "@kivu-ui/react";
export default function Demo() {
const [range, setRange] = useState("30d");
return (
<div className="grid justify-items-center gap-4">
<SegmentedControl
aria-label="Time range"
options={[
{ value: "7d", label: "7 days" },
{ value: "30d", label: "30 days" },
{ value: "90d", label: "90 days" },
{ value: "12m", label: "12 months" },
]}
value={range}
onValueChange={setRange}
/>
<SegmentedControl aria-label="View" size="sm" options={["Chart", "Table"]} defaultValue="Chart" />
<p className="font-mono text-xs text-fg-muted">value: {range}</p>
</div>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
options | (string | { value, label, disabled? })[] | - | Required. The choices. |
value / defaultValue | string | - | Selected value. |
onValueChange | (value: string) => void | - | Called when the selection changes. |
size | "sm" | "md" | "md" | Controls the size. |
fullWidth | boolean | false | Fill the parent's width. |
disabled | boolean | false | Disable every option. |
aria-label | string | - | Required unless labelled by visible text. |
Every component also accepts className and forwards its ref. Root CSS class: .kivu-segmented