Actions
ButtonGroup
Groups related buttons under role="group", optionally attached into one segmented control.
import { ButtonGroup } from '@reactloom/ui';Examples
Spaced
import { Button, ButtonGroup } from '@reactloom/ui';
export default function Example() {
return (
<ButtonGroup aria-label="Document actions">
<Button variant="secondary">Duplicate</Button>
<Button variant="secondary">Archive</Button>
<Button>Share</Button>
</ButtonGroup>
);
}Attached
The hovered, focused or pressed segment is lifted so its border and focus ring are never clipped.
import { Button, ButtonGroup, IconButton } from '@reactloom/ui';
import { ChevronLeft, ChevronRight } from 'lucide-react';
export default function Example() {
return (
<ButtonGroup aria-label="Pagination" attached>
<IconButton icon={<ChevronLeft />} label="Previous page" variant="secondary" />
<Button variant="secondary">1</Button>
<Button variant="secondary" aria-current="page">2</Button>
<Button variant="secondary">3</Button>
<IconButton icon={<ChevronRight />} label="Next page" variant="secondary" />
</ButtonGroup>
);
}API reference
| Prop | Type | Default |
|---|---|---|
attachedJoin buttons with shared borders. | boolean | false |
orientation | 'horizontal' | 'vertical' | 'horizontal' |
aria-labelName the group when its purpose is not obvious. | string | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
State attributes
Target these in your CSS to style states without depending on class names.
| Attribute | Values |
|---|---|
[data-attached] | present when on |
[data-orientation] | horizontal · vertical |
Accessibility
- Each button remains its own tab stop.
- Give the group an aria-label (“Pagination”, “Zoom”).
| Key | Action |
|---|---|
| Tab | Move between buttons |
Usage guidelines
Do
- Group buttons that act on the same object.
Don’t
- Don’t mix primary and destructive actions in one attached group.