ButtonGroup

ButtonGroup joins related actions with the same visual emphasis into one compact, attached control.

Overview and decision boundary

Use ButtonGroup when adjacent actions form one compact, related set with the same visual variant.

Do not mix Button variants, group unrelated actions, or use it as a toolbar substitute.

import { ChevronDown } from "@nerio-ui/adapters/icons";import { Badge, ButtonGroup } from "@nerio-ui/ui";import { Button } from "@nerio-ui/ui/client";<ButtonGroup aria-label="Repository actions">  <Button badge={<Badge size="sm" tone="info">24</Badge>} variant="secondary">    Fork  </Button>  <Button icon={ChevronDown} aria-label="More fork actions" variant="secondary" /></ButtonGroup>

Installation and imports

Install the editable registry source, or use the matching package entrypoint when the product keeps Nerio as a workspace dependency.

pnpm dlx nerio add button-groupimport { ButtonGroup } from '@nerio-ui/ui';import { Button } from '@nerio-ui/ui/client';

Usage

import { ButtonGroup } from '@nerio-ui/ui';import { Button } from '@nerio-ui/ui/client';<ButtonGroup aria-label="Document actions">  <Button variant="secondary">Cancel</Button>  <Button variant="secondary">Save</Button></ButtonGroup>

Variants

VariantPurpose
orientation: horizontal | verticalOrientation: horizontal | vertical is part of the public component contract.

Anatomy

button-groupfirst buttonlast button
SlotPurpose
button-groupNative group wrapper that owns one attached horizontal or vertical layout.
buttonChild Buttons retain their individual semantics, labels, and states.
button-badgeAn optional count or status remains inside its child Button.
first / last buttonKeep the group radius only on the outside corners.
shared borderAdjacent borders overlap so the controls read as one compact set.

States

StateBehavior
DefaultAdjacent Buttons share a single compact visual boundary.
Hover and focusThe active child rises above neighbouring borders without losing its focus ring.
DisabledEach child Button remains independently disabled when needed.
LoadingEach child Button can announce its own loading state without changing the group.

Motion

ButtonGroup adds no motion of its own; every child uses the shared Button motion and reduced-motion behavior.

  • inherits Button motion

Accessibility

Give the group a concise aria-label; every Button keeps its own visible name and independent Tab stop. ButtonGroup does not add arrow-key navigation, so use a keyboard-managed toolbar or selection control when that interaction is required.

  • Renders a group landmark by default; provide aria-label or aria-labelledby for its shared purpose.
  • Preserves the native semantics and independent Tab order of every child Button; it does not add roving focus or arrow-key navigation.
  • Use direct Nerio Button children with the same Button variant so the actions remain visually equal.

API

PropValuesPurpose
childrenReactNodeRelated Buttons that share one compact context and visual variant.
orientation"horizontal" | "vertical"Horizontal is the default; vertical stacks direct Button children.
aria-labelstringNames the group for assistive technology.
aria-labelledbystringUses an existing visible label as the group name.
rolestringDefaults to group; keep group semantics for related actions.
classNamestringExtends the group root without changing child Button contracts.

Implementation contract

ContractValue
Registry itembutton-group installs 4 Tailwind-first source files into the configured components directory.
Base UINo interactive primitive required.
Registry dependenciesbutton
Package dependenciesclsx, react, tailwind-merge, tailwindcss

Styling contract

ContractValue
AuthoringComplete, statically detectable Tailwind CSS v4 recipes own component visuals.
ValuesSemantic and component --n-* variables remain the canonical customization layer.
OverridesCustomizable slots merge consumer className values with tailwindCn so conflicting utilities resolve deterministically.
Residual CSSOnly shared keyframes and scoped no-Preflight compatibility rules remain; there is no parallel visual selector layer.

Design notes

  • Use ButtonGroup when adjacent actions form one compact, related set with the same visual variant.

Do / do not

Do

Group direct Button children that share one local context and the same Button variant.

Do not

Mix Button variants, wrap children in layout elements, use ButtonGroup as a generic toolbar, or collect unrelated page actions.

Tokens

GroupTokensControls
Shape--n-button-radiusRounds only the outside corners of the group.
Attachment--n-button-border-widthOverlaps adjacent Button borders by one shared width.
Divider--n-button-group-dividerDraws a short, neutral separator between adjacent Buttons.
Focus--n-focus-ringKeeps each child Button visibly focusable above adjacent borders.