Button Group

Free

Groups related buttons into a single, cohesive control. Supports horizontal/vertical layouts, attached (segmented) or spaced styles, and size/variant propagation to child buttons.

Installation

Install via CLI

npx @moontra/moonui-cli add button-group

Usage

Examples

Horizontal Group

The default orientation. Attached buttons share borders and merge their outer corners into a single segmented control.

Vertical Group

Set orientation="vertical" to stack buttons. The corner-merging logic adapts to the vertical axis automatically.

Detached (Spaced) Group

Set attached={false} to keep buttons visually separate with consistent spacing while preserving each button's own rounded corners.

Size & Variant Propagation

Set size and/or variant once on the group and it flows down to every child Button. A child's own explicit prop always wins over the group value.

View Switcher

A common real-world pattern: an attached, icon-driven segmented control for toggling between layout modes.