Installation
npx logic2b@next add button-groupUsage
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from "@/components/ui/button-group"
<ButtonGroup>
<Button variant="outline">Copy</Button>
<Button variant="outline">Paste</Button>
</ButtonGroup>
<ButtonGroup>
<ButtonGroupText>https://</ButtonGroupText>
<ButtonGroupSeparator />
<Button variant="outline">example.com</Button>
</ButtonGroup>
Usage notes
All three parts also forward the native props of the element they render
(ButtonGroup and ButtonGroupText render a <div>; ButtonGroupSeparator
renders a Separator).
Examples
Vertical
With an input
Live playground
Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.
Generated JSX
<ButtonGroup
orientation="horizontal"
aria-label="Editor actions"
>
<button
type="button"
className="rounded-md border px-3 py-2 text-sm font-medium"
>Undo</button>
<ButtonGroupText>3 changes</ButtonGroupText>
<button
type="button"
className="rounded-md border px-3 py-2 text-sm font-medium"
>Publish</button>
</ButtonGroup>3 changes
API reference
Generated from the public TypeScript exports in src/ui/button-group.tsx.
ButtonGroup
ComponentProps: React.ComponentProps<"div"> & { orientation?: "horizontal" | "vertical" }| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
orientation | "horizontal" | "vertical" | No | "horizontal" | — |
ButtonGroupText
ComponentProps: React.ComponentProps<"div"> & { asChild?: boolean }| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
asChild | boolean | No | false | — |
ButtonGroupSeparator
ComponentProps: React.ComponentProps<typeof Separator>| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
orientation | "horizontal" | "vertical" | No | "vertical" | Either `vertical` or `horizontal`. Defaults to `horizontal`. |
Accessibility contract
Machine-readable behavior and consumer responsibilities for button-group.
- Support
- Composition contract
- Pattern
- group of actions
- HTML div
Built-in semantics
- Groups native buttons visually without replacing their button semantics.
Consumer responsibilities
- Add role=group and an accessible name when the buttons form one conceptual control.