Content Switcher

Segmented single select for filters and view modes. Does not own tab panels.

Also known as: segmented control, segment control, segmented switcher, view switcher, mode switcher

Installation

Install with the CLI, or copy the component source into your project.

Add content-switcher (npm)

npx --yes -p @default-file/ui df-ui add content-switcher

Default

Joined bordered segments for single-select options.

Sizes

T-shirt sizes: xs, sm, and default.

xs
sm
default

De-selectable

Click the active item again to clear selection (value becomes empty).

Click the active item again to clear selection (current: silk).

Orientation

Horizontal (default) or vertical segment layout.

Properties

Segmented single-select for filters and view modes. Supports t-shirt sizes and optional deselect. Label ink is optically centered to cap height with text-box when available, and a 1cap line box otherwise. Compose ContentSwitcher and ContentSwitcherItem.

ContentSwitcher

PropTypeDefaultNotes
valuestring-Controlled selected value.
defaultValuestring-Uncontrolled initial value.
onValueChange(value: string) => void-Called when selection changes.
orientation"horizontal" | "vertical""horizontal"Layout direction.
fullWidthbooleanfalseStretch items to fill the available width.
size"default" | "sm" | "xs""default"T-shirt size for segment height and type.
deselectablebooleanfalseClick the active item again to clear selection (value becomes "").
classNamestring-Additional styles on the root.

ContentSwitcherItem

PropTypeDefaultNotes
valuestring-Item value (required).
disabledboolean-Non-interactive item.
childrenReactNode-Item label.

Tokens

Theme defaults live on :root. Override these globally or on a local host.

TokenTypeDefaultNotes
--mutedCSS colorvar(--df-neutral-50)Track fill.
--backgroundCSS colorvar(--df-neutral-0)Active item fill.
--foregroundCSS colorvar(--df-neutral-900)Active item label.
--borderCSS colorvar(--df-neutral-100)Track border.
--spacing-unitCSS length0.25remBase unit for padding and gap.
--df-label-line-heightCSS line-heightvar(--df-leading-none)Line box for label flex centering. Defaults to --df-leading-none. When text-box is unavailable and the cap unit is supported, the kit sets this to 1cap so flex centering matches cap-height ink.