Skip to content

Segmented

A set of mutually exclusive options with a sliding background indicator. Useful for view switching or filtering.

Basic Usage

tsx
import { Segmented } from '@airo-ui/react'
import { useState } from 'react'

const options = [
  { label: 'Auto', value: 'auto' },
  { label: 'Article', value: 'article' },
  { label: 'Outline', value: 'outline' },
  { label: 'Title', value: 'title' },
  { label: 'Summary', value: 'summary' },
  { label: 'Rewrite', value: 'rewrite' },
  { label: 'Research', value: 'research' },
]

function Demo() {
  const [value, setValue] = useState('article')

  return <Segmented value={value} onChange={setValue} options={options} />
}

Size

tsx
<Segmented value={value} onChange={setValue} options={options} size="sm" />
<Segmented value={value} onChange={setValue} options={options} size="md" />

Disabled

tsx
<Segmented value={value} onChange={setValue} options={options} disabled />

API

Props

NameTypeDefaultDescription
valuestring | number--Controlled selected value
defaultValuestring | number''Default value (uncontrolled)
optionsSegmentedOption[][]Options list
disabledbooleanfalseDisable entire component
size'sm' | 'md''md'Size
onChange(value: string | number) => void--Value change handler

SegmentedOption

NameTypeDefaultDescription
labelstring--Display text
valuestring | number--Option value
disabledbooleanfalseDisable this option

Interaction

  • White indicator block transitions left + width using --ease-spring spring curve
  • Keyboard: left/right arrows to switch, Home / End to jump to first/last
  • Selected item text is --color-neutral-950, unselected is --color-neutral-500

MIT License