---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Button group

Joined buttons, and a SplitButton: a main action with its menu, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ButtonGroup`.

## Try it

Press the split button or open its menu (pointer or keyboard), switch its look and size, make it busy or disabled; page the week and stack the group of three. The line under them says what ran.

Nothing is saved: each press only says what it would do.

## When to use

- Joined buttons, and a SplitButton: a main action with its menu.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Button group on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-button-group.json --yes
```

```text
Add the Goop Button group to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { ButtonGroup, SplitButton } from '@/components/ui/goop/button-group';
import { IconButton, IconButtonIcon } from '@/components/ui/goop/icon-button';
import { Button } from '@/components/ui/goop/button';
import { DropdownMenuItem } from '@/components/ui/goop/dropdown-menu';

function SaveActions({ save, saving }: { save: () => void; saving: boolean }) {
  return (
    <div className="flex items-center gap-2">
      <ButtonGroup aria-label="Week">
        <IconButton variant="outline" aria-label="Previous week">
          <IconButtonIcon icon="chevron-left" />
        </IconButton>
        <Button variant="outline">Today</Button>
        <IconButton variant="outline" aria-label="Next week">
          <IconButtonIcon icon="chevron-right" />
        </IconButton>
      </ButtonGroup>
      <SplitButton
        onClick={save}
        loading={saving}
        menu={
          <>
            <DropdownMenuItem>Save as draft</DropdownMenuItem>
            <DropdownMenuItem>Save and share with the team</DropdownMenuItem>
          </>
        }
      >
        Save note
      </SplitButton>
    </div>
  );
}
```

- Fits: record, list: header.
- Also known as: ButtonBar, ActionGroup, AttachedButtons, JoinedButtons, DropdownButton, ButtonWithMenu.
- height, width, corner, border: add no class for these.

## API reference

### Options

- `orientation: horizontal | vertical = horizontal`
- `aria-label?: string` — What the group is, said to a reader (`aria-label`); or name it with `aria-labelledby`.

### Parts

- `SplitButton` — A main action with a menu of related ones beside it ("Save", then "Save as draft"); children: ReactNode — The main button's words; onClick?: ComponentProps<typeof Button>['onClick'] — The main action, run by the main half; menu: ReactNode — The menu's rows (`DropdownMenuItem`s), opened by the chevron; menuLabel?: string — What the chevron is called (its `aria-label` and tooltip); variant?: 'primary' | 'outline' = 'primary' — `primary` the accent fill, `outline` the surface on its ring; size?: 'sm' | 'md' | 'lg' = 'md' — The height: sm 24, md 28, lg 32 px; loading?: boolean = false — The main action is running: the spinner on the main half alone; the menu stays usable; loadingLabel?: string — What a reader hears beside the main words while `loading` (default "Loading"); disabled?: boolean = false — Both halves cannot act now; open?: boolean — The menu's open state, when you hold it; with `onOpenChange`; defaultOpen?: boolean — Whether the menu starts open, when it holds its own state; onOpenChange?: (open: boolean) => void — Called with the menu's next open state; modal?: boolean — Whether the open menu holds the page (the default): no pointer outside it, the focus kept in it; container?: ComponentProps<typeof DropdownMenuContent>['container'] — Where the menu is portalled (default the page's body); also takes type?: 'button' | 'submit' | 'reset'

- Class recipes (cva): buttonGroupVariants (ButtonGroup)
- data-slot values (to select a part by): button-group, split-button

## Keyboard

- Tab: move to the next member: each button is its own tab stop
- Enter: run the focused member's action; on the split button's chevron open its menu
- Space: run the focused member's action; on the split button's chevron open its menu
- ArrowDown: on the split button's chevron open its menu with its first row active
- Escape: close the split button's menu and give the focus back to the chevron

## Accessibility

- The part itself answers the keys above.
- hover, focus-visible: the browser's own (:hover, :focus-visible): write nothing

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Icon button](/themes/trail/components/icon-button): A button whose only visible label is one icon, for toolbars, rows and headers.
- [Button](/themes/trail/components/button): A button with words that runs an action, in several looks and sizes.
- [Dropdown menu](/themes/trail/components/dropdown-menu): A menu of actions.
- [Destructive button](/themes/trail/components/destructive-button): The button for an action that deletes or cannot be undone, marked in the danger colour.
