10.4k

Segmented Control

A visual pattern for presenting related choices, navigation destinations, filters, or content views.

About

A segmented control is a visual pattern, not a standalone behavior. COSS uses the same presentation across several components while preserving the semantics, keyboard interactions, and state model of each underlying primitive.

Choose the right primitive

Choose the primitive from the interaction first, then apply the segmented-control styling. Visual similarity alone is not a reason to use Tabs or Toggle Group.

Installation

Segmented controls are provided as particles. Install the implementation and size that match your interaction:

For example, install the default Radio Group version with:

The CLI installs the shared segmented-control styling library and the required primitive automatically.

Shared styling

For a custom composition, install the styling library directly:

The library exports a root class and an item recipe:

Use checked with Radio Group, current with navigation links, and pressed with Toggle Group. Tabs retain their own animated indicator and do not use the shared state recipe.

At the outside edges, the item padding and the surface's p-0.5 inset combine to match the horizontal padding of the corresponding Button size. The outer segmented surface is slightly taller than that Button to optically balance its inset selected item when the controls appear next to each other.

lib/segmented-control.ts

Radio options

Use Radio Group when the selected segment represents a mutually exclusive value, especially in forms.

Small Radio Group

Default Radio Group

Large Radio Group

Use links when each segment points to a different destination. Apply aria-current="page" to the active link.

Small Navigation

Default Navigation

Large Navigation

Use Tabs when each segment controls an associated content panel. Tabs share the visual language of segmented controls but keep their animated indicator, orientation support, and panel semantics.

coss.com ui

Built by and for the team of Cal.com, Inc. — the leading commercial open source company (“coss”).