Skip to content

ButtonGroup

Terminal window
npx bambiui init
npx bambiui add button
npx bambiui add buttongroup

ButtonGroup installs a wrapper component plus buttongroup.css. It expects Button to be installed separately when you use it with bambiui buttons.

import { Button } from './components/ui/button';
import { ButtonGroup } from './components/ui/buttongroup';

Attached groups remove the gap and collapse adjacent borders. Use them for segmented controls and tightly related actions.

<ButtonGroup aria-label="Text alignment">
<Button appearance="outline">Left</Button>
<Button appearance="outline">Center</Button>
<Button appearance="outline">Right</Button>
</ButtonGroup>

Set attached={false} when the actions are related but should keep visual separation.

<ButtonGroup attached={false} aria-label="Dialog actions">
<Button appearance="ghost">Cancel</Button>
<Button>Save</Button>
</ButtonGroup>

In Vue, use :attached="false".

OrientationBehavior
horizontalRow layout, default
verticalColumn layout
<ButtonGroup orientation="vertical" aria-label="Export format">
<Button appearance="outline">PDF</Button>
<Button appearance="outline">CSV</Button>
<Button appearance="outline">JSON</Button>
</ButtonGroup>
PropTypeDefaultDescription
orientation'horizontal' | 'vertical''horizontal'Direction of grouped controls
attachedbooleantrueRemoves gaps and merges button borders
rolestring'group'ARIA grouping role

All other HTML <div> attributes are forwarded to the wrapper. React uses className; Svelte, Vue, and Astro use class.

AttributeSource
data-orientationorientation
data-attachedattached
  • Keep role="group" for related action groups.
  • Provide aria-label or aria-labelledby when the group purpose is not visible in nearby text.
  • ButtonGroup does not manage selection state; use the child buttons’ own attributes for pressed, active, or disabled states.