Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Button Group for React and Tailwind

Visually connected buttons and related controls.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/button-group.json

Usage

import { ArrowLeftIcon, MoreHorizontalIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { ButtonGroup } from "@/components/ui/button-group";
<ButtonGroup aria-label="Message actions">
  <ButtonGroup className="hidden sm:flex">
    <Button aria-label="Go back" size="icon-md" variant="outline">
      <ArrowLeftIcon aria-hidden="true" />
    </Button>
  </ButtonGroup>
  <ButtonGroup>
    <Button variant="outline">Archive</Button>
    <Button variant="outline">Report</Button>
  </ButtonGroup>
  <ButtonGroup>
    <Button variant="outline">Snooze</Button>
    <Button aria-label="More options" size="icon-md" variant="outline">
      <MoreHorizontalIcon aria-hidden="true" />
    </Button>
  </ButtonGroup>
</ButtonGroup>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Nested

Orientation Horizontal

Orientation Vertical

Separator

With Input

With Menu

With Popover

With Text

API Reference

ButtonGroup

fieldset

PropType
AttributeType

ButtonGroupText

div

PropType
AttributeType

ButtonGroupSeparator

PropType
AttributeType