Skip to content
Eskais UI

Forms

Segmented Control

UI SDK SegmentedControl: one choice from a row of buttons with a sliding indicator, like a board/table view switch.

Example

Installation

npx shadcn@latest add @eskais/segmented-control
Brings alongnarrowfield

Usage

Import
import {  SegmentedControl,  SegmentedControlIndicator,  SegmentedControlItem,  createSegmentedControlController,} from "@/components/ui/segmented-control"

API reference

SegmentedControl

Takes SegmentedControlProps<T>.

SegmentedControlIndicator

Takes every prop of UI SDK SegmentedControlIndicator.

Other exports

createSegmentedControlControllertype SegmentedControlPropstype SegmentedControlControllertype SegmentedControlItemState

Accessibility

  • One choice from a row, as a radio group: arrow keys move and select.
  • The indicator slides, or fades under reduced motion.
  • activateOnPress (off by default) checks an item on a mouse or pen press instead of on release, like macOS. Touch stays on release, so scrolling past doesn't change it. WCAG 2.5.2 allows it because another press undoes it; actions and menus always activate on release.

Agent actions

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.