import { useState } from "react"; import { SegmentedControl, SegmentedControlItem } from "@ai-ui/ui"; import type { Meta, StoryObj } from "@storybook/react"; type RevenueLens = "revenue" | "support" | "forecast"; type RevenueLensControlProps = { includeDisabled?: boolean; orientation?: "horizontal" | "vertical"; }; const lensContent: Record< RevenueLens, { body: string; eyebrow: string; title: string; } > = { revenue: { body: "Lead scoring, sequence timing, and route suggestions are lifting close quality without making the top-line motion feel synthetic.", eyebrow: "Revenue lens", title: "Commercial coverage stays compact while the active segment changes the read." }, support: { body: "Classification, summaries, and next-step hints are reducing queue drag while still keeping team-lead review visible at the handoff edge.", eyebrow: "Support lens", title: "Use the segmented switch when the layout already owns the content panel." }, forecast: { body: "A lighter control works well for near-peer views, especially when the panel chrome and surrounding card structure already exist outside the switcher.", eyebrow: "Forecast lens", title: "Choose Tabs instead when the control needs to own a tabpanel relationship." } }; function RevenueLensControl({ includeDisabled = false, orientation = "horizontal" }: RevenueLensControlProps) { const [value, setValue] = useState("revenue"); const activeContent = lensContent[value]; return (
setValue(nextValue as RevenueLens)} value={value} > Revenue Support Forecast {includeDisabled ? ( Handoff ) : null}

{activeContent.eyebrow}

{activeContent.title}

{activeContent.body}

); } const meta = { title: "Components/SegmentedControl", component: SegmentedControl, parameters: { docs: { description: { component: "SegmentedControl is the compact single-select switch for lightweight dashboard lenses, filters, and mode changes when the surrounding layout already owns the content surface. Use Tabs instead when the control needs to own tab panels and the full in-place content relationship. The checked state now rides on a shared pill so the control reads as one moving slab rather than separate button fills." } }, layout: "centered" }, tags: ["autodocs"] } satisfies Meta; export default meta; type Story = StoryObj; export const Playground: Story = { render: () => }; export const States: Story = { render: () => }; export const Anatomy: Story = { render: () => (

SegmentedControl anatomy

data-slot="root" carries{" "} data-orientation so the segment stack can switch between horizontal and vertical layouts without changing the item API.

data-slot="control" exposes each segment, while data-state="checked"{" "} and data-disabled stay stable for styling and tests.

) }; export const Motion: Story = { parameters: { docs: { description: { story: "The checked segment now carries a shared indicator that glides between items with the same calm timing as the rest of the system. The control should feel tactile and cohesive, not snappy or game-like." } } }, render: () => }; export const Accessibility: Story = { parameters: { docs: { description: { story: "Keep labels brief, use segmented controls for single-select peer views, and avoid using them as page navigation. If the control needs a persistent tabpanel relationship, choose Tabs instead." } } }, render: () => (

Accessibility notes

Use it for one active choice, not for multi-select filters.

Keep labels short so the active segment remains easy to scan at a glance.

Do not use it as a substitute for top-level page navigation.

) };