Button Group

Groups related controls with connected edges and consistent focus behavior.

Installation

npx shadcn@latest add @fulldev/button-group

Usage

---
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
---

<ButtonGroup aria-label="Document actions">
  <Button variant="outline">Save</Button>
  <Button variant="outline">Publish</Button>
</ButtonGroup>

Give each group an accessible name with aria-label or aria-labelledby.

Examples

Sizes

Button sizes continue to work inside a group.

Vertical

With Text

ButtonGroupText is polymorphic. Render it as a label when it describes a form control.

Nested Groups

Nested groups keep a gap between related sets while preserving connected controls inside each set.

API Reference

ButtonGroup

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Controls the layout and connected edges.
asHTMLTag"div"Changes the rendered element.

ButtonGroupText

Accepts as and the attributes for that HTML element.

ButtonGroupSeparator

Uses the Separator API. Its orientation defaults to "vertical".

See the GitHub source code for the component source.