3.1 KiB
3.1 KiB
Segmented Control
- Status:
completed - Owner:
codex - Date:
2026-03-25
Goal
Add a compact SegmentedControl component to @ai-ui/ui for lightweight dashboard-style view
switching so consumers do not need to stretch Tabs into every small top-of-panel toggle.
Scope
- In scope:
- add a new
SegmentedControlcomponent topackages/ui - expose the component from the package entrypoint
- add unit coverage for controlled/uncontrolled behavior and stable contract hooks
- add Storybook docs that explain when to choose
SegmentedControlinstead ofTabs - update the revenue dashboard story to use the new control for its contribution switcher
- refresh
registry/index.jsonso source-copy consumers can install the new component
- add a new
- Out of scope:
- redesigning the existing
TabsAPI - replacing every current
Tabsusage across docs - adding icon-only, multi-select, or overflow handling variants in the first pass
- redesigning the existing
Constraints
- Keep the API narrower than
Tabs; this should solve lightweight switching, not become another generic navigation primitive. - Reuse the current token and motion language from
DESIGN.mdinstead of introducing a new visual style. - Preserve stable
data-slotanddata-*hooks for docs and tests. - Do not add a new dependency if the existing Radix stack is sufficient.
Affected Surfaces
docs/exec-plans/2026-03-25-segmented-control.mdpackages/ui/src/components/segmented-control.tsxpackages/ui/src/components/segmented-control.variants.tspackages/ui/src/components/segmented-control.test.tsxpackages/ui/src/index.tsapps/docs/src/components/segmented-control.stories.tsxapps/docs/src/revenue-dashboard.stories.tsxregistry/index.json
Plan
- Add the execution plan and confirm the public contract for a compact single-select control.
- Implement
SegmentedControlinpackages/uiwith stable slots, disabled state, and controlled or uncontrolled value support. - Add Storybook docs that explain the intended usage boundary against
Tabs. - Replace the revenue dashboard contribution switcher with
SegmentedControlto prove the dashboard-friendly use case. - Run targeted validation and refresh registry metadata.
Validation
pnpm test -- --runInBand segmented-control tabspnpm harness:validate:docspnpm registry:build
Orchestration Task Sketch
T1: implementSegmentedControlsource, variants, and exportsT2 -> T1: add docs stories and migrate the revenue dashboard exampleT3 -> T1: add tests and refresh registry metadata
Status Log
2026-03-25 20:07Read the system-of-record files and confirmed thatTabsis currently the only compact peer-switching primitive in the public surface.2026-03-25 20:18Started the segmented-control slice to cover lightweight dashboard toggles without expanding theTabsAPI.2026-03-25 23:32Shipped the newSegmentedControl, migrated the revenue dashboard contribution switcher, refreshedregistry/index.json, and cleared the existingInputGrouptype blocker so build and docs validation could pass again.