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.

Preview

No preview output yet.

live.tsxReady

Split button

Primary action with a dropdown for secondary actions.

Preview

No preview output yet.

live.tsxReady

With input

Circular control beside a pill input — common chat composer layout.

Preview

No preview output yet.

live.tsxReady

Pagination style

Dense grouped controls for page numbers and prev/next.

Preview

No preview output yet.

live.tsxReady

Vertical

Stacked icon groups and a standalone control.

Preview

No preview output yet.

live.tsxReady

Anatomy

tsx
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".

PropTypeDefault
asChild
booleanfalse
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.

PropTypeDefault
asChild
booleanfalse
type
"button" | "submit" | "reset""button"
disabled
booleanfalse
AttributeValues
[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.

Previous
Button