Segmented Control

Tab-like selector with animated sliding indicator for switching between options.

Need content panels? Use Tabs when you need to switch between different content areas (e.g., Settings with Account, Profile, Security panels).

Basic Usage

Simple segmented control with smooth animated indicator transition.

Selected View: list

Two Options

Perfect for binary choices like Monthly/Yearly billing toggles.

Selected billing cycle: monthly

Multiple Options

Works with 4+ options for content filtering and categorization.

Showing: all items

Filled Variant

Filled style with stronger visual emphasis on the selected option.

Outline Variant

Outline style with border emphasis on the selected option.

Sizes

Available in small, medium (default), and large sizes.

Small
Medium (Default)
Large

Features

  • Smooth animated indicator sliding between options
  • Automatic width calculation for even spacing
  • Three style variants: default, filled, outline
  • Three size options: sm, md, lg
  • Keyboard navigation support
  • Works with 2 to 6+ options
  • Controlled component pattern

API Reference

SegmentedControlProps

PropTypeDefaultDescription
optionsSegmentedOption[][]Array of selectable options
valuestring-Selected option value
onChange(value: string) => void-Callback when selection changes
variant'default' | 'filled' | 'outline''default'Visual style variant
size'sm' | 'md' | 'lg''md'Control size
disabledbooleanfalseDisable all options
classNamestring-Additional CSS classes

SegmentedOption

PropertyTypeDescription
valuestringUnique value for the option
labelstringDisplay label for the option
disabledbooleanDisable this specific option

Usage

import { SegmentedControl, type SegmentedOption } from '@/components/ui/segmented-control'

const options: SegmentedOption[] = [
  { value: 'list', label: 'List' },
  { value: 'grid', label: 'Grid' },
  { value: 'kanban', label: 'Kanban' },
]

function MyComponent() {
  const [view, setView] = useState('list')

  return (
    <SegmentedControl
      options={options}
      value={view}
      onChange={setView}
    />
  )
}