Button Group
A row or column of connected buttons that reads as one toolbar, where each button runs its own action. With a glass variant, the buttons share one Liquid Glass background, as iOS groups toolbar items.
Installation
This also adds Glass, which draws the glass variants, and Icon. Button Group imports class-variance-authority (see Installation).
Usage
- The group sets the look of every item. Each item emits its own
pressed. - Nothing stays selected. For buttons that stay on, use a toggle group from Toggle.
- The group hugs its items. Add
class="w-full"to stretch it.
Variants
default fills the items with the secondary color. outline uses the background color inside a border.
Glass
One glass background for a group of actions that floats over your content, like a toolbar on iOS 26:
glassis regular glass.glass-clearis clear glass for over photos and video, on a dark dimming layer so its white icons stay legible.- The group is one glass shape and its items are plain. iOS draws grouped toolbar items this way. Glass circles merged in a glass group would join with pinched waists instead, and glass shouldn't sit on glass.
- A pressed item lights up in corners concentric with the group's. On iOS 26 the glass also swells under the finger.
- A row is a capsule. A column is too when its items are icons, and otherwise has round corners.
What each platform draws:
Sizes
icon makes square items for one <ui-icon> each. Give each an accessibility-label, which a screen reader says instead. In the other sizes, an icon sits before the label.
Vertical
Disabled
Disable the whole group, or one item. A disabled item dims and doesn't emit pressed.
API
UiButtonGroup
No outputs.
UiButtonGroupItem
The file also exports buttonGroupItemVariants and the ButtonGroupVariant, SolidButtonGroupVariant, GlassButtonGroupVariant, ButtonGroupLook, ButtonGroupSize and ButtonGroupOrientation types.
Accessibility
- A screen reader reads each item's label as a button, or its
accessibility-label. - Reduce Motion: solid items dim while pressed instead of shrinking. Glass and Material items only light up, which isn't motion, and the web preview's glass stops swelling.
- Reduce Transparency and Increase Contrast: the glass follows them as Glass does. Under Increase Contrast, Android's Material items get an outline.
