Skip to content

Components

Button Group

Joins related buttons and inputs into one control.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add button-group

Adds components/ui/button-group.tsx and installs react, clsx, tailwind-merge with lifecycle scripts disabled.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText } from '@/components/ui/button-group'
import { Button } from '@/components/ui/button'
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu'
import { Input } from '@/components/ui/input'
import { ChevronDownIcon } from 'lucide-react'
// Radix form (asChild). In the Base UI edition use <DropdownMenuTrigger render={<Button size="icon" aria-label="More install options" />}>.
export function Example(){return <div style={{ display: "grid", gap: "1rem" }}><ButtonGroup aria-label="Install" style={{ justifySelf: "start" }}><Button>Install</Button><DropdownMenu><DropdownMenuTrigger asChild><Button size="icon" aria-label="More install options"><ChevronDownIcon aria-hidden="true" /></Button></DropdownMenuTrigger><DropdownMenuContent><DropdownMenuItem>Install with npm</DropdownMenuItem><DropdownMenuItem>Install with pnpm</DropdownMenuItem></DropdownMenuContent></DropdownMenu></ButtonGroup><ButtonGroup aria-label="History" style={{ justifySelf: "start" }}><Button variant="outline">Undo</Button><ButtonGroupSeparator /><Button variant="outline">Redo</Button></ButtonGroup><ButtonGroup aria-label="Website"><ButtonGroupText>https://</ButtonGroupText><Input aria-label="Domain" defaultValue="ombelle.dev" /><Button variant="outline">Copy</Button></ButtonGroup></div>}

API and states

API
ButtonGroup (orientation horizontal or vertical, aria-label), ButtonGroupSeparator, ButtonGroupText
Minimum states
Default, hover, focus, disabled child, single child
Native basis
Native div with role="group"
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.