Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Button Group examples · Interactive

Segmented Control Button Group for React

Two segmented controls of ghost buttons where the selected section or period gets the solid fill.

Framework
UI library

A segmented control built from ghost buttons. The unselected options have no border or fill, so only the selected one stands out with the default fill. The two groups keep separate values: a section starting at Overview and a period starting at Week.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How is each selection tracked?

Each group has its own value, overview and week. Each button carries its own value, and pressing it stores that value for its group.

Why ghost and not outline?

variant="ghost" shows no edge until hover, so the row reads as one strip with a single filled segment. Use outline if the options should look like separate buttons.

How is the selected segment announced?

It sets aria-pressed, so a screen reader reads it as pressed.

Should Overview, Analytics and Reports be Tabs?

If they switch panels on the page, yes: Tabs link each trigger to its panel and handle Arrow keys. Use buttons when the choice changes a setting rather than which panel is visible.

Does the demo switch any content?

No. It only stores the two values. Render your sections or data from them.

What size are the buttons?

All use size="sm".