Button Group
Button groups allow you to group multiple related buttons together into a single cohesive unit.
Features
- Grouped layout
- Automatic position tracking
- Native Tab navigation
- Headless styling
Installation
npm install @ariaui/button-group
Examples
Each playground is a real layout: standard toolbars, a split button with DropdownMenu, an input companion, pagination-style rows, and vertical icon stacks. Style joined edges with Tailwind; items receive data-position from ButtonGroup.Root.
Snippets list the matching @heroicons/react/24/outline imports per variant.
Standard
Basic horizontal groups with shared borders, plus a standalone icon control.
No preview output yet.
Split button
Primary action with a dropdown for secondary actions.
No preview output yet.
With input
Circular control beside a pill input — common chat composer layout.
No preview output yet.
Pagination style
Dense grouped controls for page numbers and prev/next.
No preview output yet.
Vertical
Stacked icon groups and a standalone control.
No preview output yet.
Anatomy
import * as ButtonGroup from "@ariaui/button-group";
export default function Example() {
return (
<ButtonGroup.Root>
<ButtonGroup.Item />
</ButtonGroup.Root>
);
}
API Reference
Root
Independent structural container for related actions. Provides context for descendant ButtonGroup.Item registration. Renders a `<div>` with role="group".
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
role | string | "group" |
aria-label | string | — |
Item
Independent action button for use inside ButtonGroup.Root. Defaults to a native button and reflects its connected DOM position through data-position. Each action follows normal Tab navigation, without selection or pressed state.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
type | "button" | "submit" | "reset" | "button" |
disabled | boolean | false |
| Attribute | Values |
|---|---|
| [data-position] | "only" | "first" | "middle" | "last" — derived automatically from connected DOM order |
| [data-disabled] | Present when disabled |
Accessibility
Button groups combine multiple ButtonGroup.Item elements within a ButtonGroup.Root. Root provides context for connected DOM position tracking; individual items own their keyboard and interaction behavior. Both parts are exported by the independent @ariaui/button-group package. Actions use ordinary Tab navigation rather than roving focus, selection, or pressed state.
Each item in a button group can be disabled independently. Use the default native button for actions, or pass asChild with a real anchor/router link for navigation so ARIA and keyboard behavior follow the underlying element — refer to the Button accessibility guide for details.