Back to Shark UI

Button Group

docs/components/button-group

latest6.8 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Button Group

Copy Markdown

Group button elements together.

PreviewCode

ArchiveReportSnooze

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/button-group

Anatomy#

ButtonGroup
└── Button or Input
├── ButtonGroupText
└── ButtonGroupSeparator

Usage#

import { 
  ButtonGroup,
  ButtonGroupSeparator,
} from "@/components/ui/button-group";
<ButtonGroup> 
  <Button>
    Archive 
  </Button>
  <ButtonGroupSeparator />
  <Button>
    Report
  </Button>
</ButtonGroup>

Accessibility#

  • Use aria-label or aria-labelledby to label the group.
<ButtonGroup aria-label="Media controls">
  <Button>Play</Button>
  <Button>Pause</Button>
</ButtonGroup>

Orientation#

Horizontal#

PreviewCode

Vertical#

PreviewCode

Examples#

Nested#

PreviewCode

Separator#

Buttons with variant outline do not need a separator since they have a border.

PreviewCode

With Input#

PreviewCode

With Menu#

PreviewCode

Subscribe

With Popover#

A popover trigger button can be added to a button group for contextual information or actions.

PreviewCode

Fork42

API Reference#

ButtonGroup#

Groups buttons together. Uses fieldset for accessibility when applicable.

PropTypeDefault
orientation`"horizontal""vertical"`
classNamestring-
asChildbooleanfalse

ButtonGroupSeparator#

Visual divider between buttons. Uses Separator internally.

PropTypeDefault
orientation`"horizontal""vertical"`
classNamestring-
asChildbooleanfalse

[

Previous page

Breadcrumb ](/docs/components/breadcrumb)[

Next page

Button ](/docs/components/button)

On This Page

InstallationAnatomyUsageAccessibilityOrientationHorizontalVerticalExamplesNestedSeparatorWith InputWith MenuWith PopoverAPI ReferenceButtonGroupButtonGroupSeparator