Examples

Spaced

Preview
Example.tsx
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.

Preview
Example.tsx
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

ButtonGroup props
PropTypeDefault
attached
Join buttons with shared borders.
booleanfalse
orientation
'horizontal' | 'vertical''horizontal'
aria-label
Name 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.

AttributeValues
[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”).
Keyboard interactions
KeyAction
TabMove 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.