Displays a segmented control that allows users to switch between multiple views.
Loading demo: contentswitcher-real-world
npx sdaia-ui@latest add contentswitcher
import { ContentSwitcher } from '@/components/ui/ContentSwitcher';1<ContentSwitcher>2<ContentSwitcherItem>Tab</ContentSwitcherItem>3</ContentSwitcher>
Use the `size` prop to change the size of the content switcher.
Loading demo: contentswitcher-size
Use `value={2}` to create a two-item switcher.
Loading demo: contentswitcher-two-items
The default switcher with three equally-spaced items.
Loading demo: contentswitcher-three-items
Use `value={4}` for a four-item segmented control.
Loading demo: contentswitcher-four-items
Use `border={true}` to add a surrounding border to the switcher.
Loading demo: contentswitcher-border
Props for the Content Switcher component.
Prop | Type | Default | Required |
|---|---|---|---|
items | ContentSwitcherItem[] | — | required |
value | string | — | optional |
defaultValue | string | first item | optional |
onValueChange | (value: string) => void | — | optional |
size | "sm" | "md" | "lg" | "sm" | optional |
border | boolean | false | optional |
placement | "start" | "center" | "end" | "start" | optional |
dir | "ltr" | "rtl" | — | optional |
rtl | boolean | false | optional |
How this component behaves at the three system breakpoints. Spacing and type tokens switch automatically at 768px and 1280px.
| Screen | Behavior |
|---|---|
| Desktop (1280px and up) | Sized by its items, never wider than its container. Items share the width equally. |
| Tablet (768–1279px) | Same layout as desktop, with the tablet token values. |
| Phone (under 768px) | When space is short the items get narrower and long labels are truncated. Use two to four short labels on phones. |