Skip to content
Storybook

Button group

A row of related toggle buttons for view switchers and filters. 2–5 segments.

Preview

React · live from the Storybook

HTML and CSS

The same component as plain HTML with pixels-ui.css, no framework needed.

Usage

  • Use for switching views of the same content.
  • Keep labels short; 2–5 segments.
  • For a single on/off action, use a Toggle instead.

Installation

Included in the core files. No extra install.

HTML
<link rel="stylesheet" href="/css/pixels-tokens.css">
<link rel="stylesheet" href="/css/pixels-ui.css">
<script src="/js/pixels-ui.js" defer></script>

Examples

Text only

Single choice with data-px-single.

Small

px-btn-group--sm for dense toolbars.

API reference

Class / attributeTypeDescription
px-btn-groupclassContainer. Owns the border, radius and clipping.
px-btn-group__itemclassOne segment.
px-btn-group--smclassSmall size.
aria-pressedattributeSelected state of a segment.
data-px-singleattributepixels-ui.js keeps one segment pressed.

Figma properties

Button group6 variants · page “Buttons”Open

A row of related toggle buttons (view switchers, filters). 2–5 segments. The container owns the border, radius and clipping; RTL variants reverse the order and use the Arabic locale.

PropertyTypeValues
SizeVariantSmall Medium Large
DirectionVariantLTR RTL
Button group / Item54 variants · page “Buttons”Open

One segment of a Button group. The group container draws the outer border and rounded corners; segments only draw the divider on their right edge (none on the last one). Position is physical (Left / M…

PropertyTypeValues
LabelText“Label”
Leading iconBoolean—
Leading icon swapInstance swap—
SizeVariantSmall Medium Large
StateVariantActive Hover Pressed Focused Disabled Selected
PositionVariantLeft Middle Right

Design tokens

Component tokens from the Figma Component collection. Override them to restyle just this component.

TokenAliasLight value
--px-button-group-radiusradius-1212px
--px-button-group-item-padding-xspacing-1616px
--px-button-group-item-heightspacing-3636px

Accessibility

  • Wrap in role="group" with an aria-label.
  • Each segment is a button with aria-pressed.