# Button group

A labelled cluster of native button actions with shared separator geometry, horizontal or vertical orientation, and narrow wrapping.

Access: pro. Category: Essentials. Kind: primitive.

## When to use

- Use it when a product interface needs a labelled cluster of native button actions with shared separator geometry, horizontal or vertical orientation, and narrow wrapping.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose tidal-button instead when press, loading, success and disabled states is the actual interface need, rather than button group.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Button group

```sh
npx shadcn@latest add @tidal-pro/button-group
```

Stylesheets: `components/ui/tidal.css`, `components/ui/button-group.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/button-group.css";
import{TidalButtonGroup}from"./components/ui/button-group";
export default()=><div className="tidal-scope"><TidalButtonGroup actions={[{id:"example",label:"Demo"}]} label={"Demo"}/></div>;
```

## Structured props

- `TidalButtonGroup.actions: ReadonlyArray<TidalButtonGroupAction>`: Required actions value accepted by this exported component.
- `TidalButtonGroup.label: string`: Required label value accepted by this exported component.
- `TidalButtonGroup.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalButtonGroup.orientation?: "horizontal" | "vertical" | undefined` (default "horizontal"): Optional orientation value accepted by this exported component.
- `TidalButtonGroup.wrap?: boolean | undefined` (default false): Optional wrap value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/button-group.tsx) | [Manifest](https://tidalui.com/examples/button-group.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalButtonGroup, type TidalButtonGroupAction } from "./components/ui/button-group";

import "./components/ui/button-group.css";



const tidalExampleStyles = ".tidal-scope .button-group-demo,\n.tidal-scope .button-group-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .button-group-demo {\n  display: grid;\n  width: min(100%, 660px);\n  min-width: 0;\n  gap: 13px;\n  padding: clamp(12px, 3.5cqi, 26px);\n  color: var(--t-ink);\n  container: button-group-demo / inline-size;\n  font-family: Inter, ui-sans-serif, system-ui, sans-serif;\n}\n\n.tidal-scope .button-group-demo-subject {\n  display: flex;\n  min-width: 0;\n  align-items: baseline;\n  justify-content: space-between;\n  gap: 14px;\n  padding-inline: 2px;\n}\n\n.tidal-scope .button-group-demo-subject span {\n  color: var(--t-muted);\n  font-size: 11px;\n  font-weight: 720;\n  letter-spacing: 0.08em;\n  line-height: 1.35;\n  text-transform: uppercase;\n}\n\n.tidal-scope .button-group-demo-subject strong {\n  min-width: 0;\n  font-size: clamp(17px, 3.4cqi, 23px);\n  font-weight: 610;\n  letter-spacing: -0.03em;\n  line-height: 1.2;\n  text-align: end;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .button-group-demo .tidal-button-group {\n  width: 100%;\n}\n\n.tidal-scope .button-group-demo-status,\n.tidal-scope .button-group-demo-note {\n  margin: 0;\n  overflow-wrap: anywhere;\n}\n\n.tidal-scope .button-group-demo-status {\n  min-height: 18px;\n  padding-inline: 2px;\n  color: var(--t-ink);\n  font-size: 12px;\n  font-weight: 590;\n  line-height: 1.5;\n}\n\n.tidal-scope .button-group-demo-note {\n  padding-top: 10px;\n  border-top: 1px solid var(--t-border);\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.45;\n}\n\n@container button-group-demo (max-width: 360px) {\n  .tidal-scope .button-group-demo {\n    padding-inline: 8px;\n  }\n\n  .tidal-scope .button-group-demo-subject {\n    align-items: flex-start;\n    flex-direction: column;\n    gap: 3px;\n  }\n\n  .tidal-scope .button-group-demo-subject strong {\n    text-align: start;\n  }\n\n  .tidal-scope .button-group-demo .tidal-button-group-action {\n    flex-basis: 100%;\n  }\n}";

function SaveIcon() {
  return (
    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path d="M3 2.5h8.5L13.5 5v8.5H3v-11Z" stroke="currentColor" />
      <path d="M5.2 2.5v3.2h5.2V2.5M5.3 13.5V9h5.4v4.5" stroke="currentColor" />
    </svg>
  );
}

function DuplicateIcon() {
  return (
    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <rect
        x="5"
        y="4.5"
        width="7.5"
        height="8"
        rx="1.5"
        stroke="currentColor"
      />
      <path
        d="M10 4.5V3.2A1.7 1.7 0 0 0 8.3 1.5H3.2A1.7 1.7 0 0 0 1.5 3.2v5.1A1.7 1.7 0 0 0 3.2 10H5"
        stroke="currentColor"
      />
    </svg>
  );
}

function ArchiveIcon() {
  return (
    <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
      <path
        d="M2.5 4.5h11v9h-11v-9ZM1.5 2h13v2.5h-13V2Z"
        stroke="currentColor"
      />
      <path d="M6 7.5h4" stroke="currentColor" />
    </svg>
  );
}

export function ButtonGroupDemo({ theme }: { theme?: "light" | "dark" }) {
  const [copies, setCopies] = useState(0);
  const [archived, setArchived] = useState(false);
  const [status, setStatus] = useState(
    "Choose an action for the sample brief.",
  );

  const actions: readonly TidalButtonGroupAction[] = [
    {
      id: "save",
      label: "Save draft",
      icon: <SaveIcon />,
      emphasis: "strong",
      buttonProps: {
        onClick: () => setStatus("Sample draft saved locally."),
      },
    },
    {
      id: "duplicate",
      label: copies ? `Duplicate ${copies + 1}` : "Duplicate",
      icon: <DuplicateIcon />,
      buttonProps: {
        onClick: () => {
          const next = copies + 1;
          setCopies(next);
          setStatus(`${next} local ${next === 1 ? "copy" : "copies"} created.`);
        },
      },
    },
    {
      id: "archive",
      label: archived ? "Restore" : "Archive",
      icon: <ArchiveIcon />,
      buttonProps: {
        onClick: () => {
          const next = !archived;
          setArchived(next);
          setStatus(
            next
              ? "Sample brief archived locally."
              : "Sample brief restored locally.",
          );
        },
      },
    },
  ];

  return (
    <section
      className="button-group-demo"
      aria-label="Button group preview"
      data-theme={theme}
    >
      <div className="button-group-demo-subject">
        <span>Sample document</span>
        <strong>Project brief</strong>
      </div>

      <TidalButtonGroup label="Project brief actions" actions={actions} wrap />

      <p className="button-group-demo-status" role="status">
        {status}
      </p>
      <p className="button-group-demo-note">
        Sample data. Changes stay in this preview.
      </p>
    </section>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <ButtonGroupDemo />
    </div>
  );
}

```

## Gotchas

- Install the declared registry dependencies and render inside a tidal-scope with the foundation stylesheet loaded.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

label names the native group. actions is an ordered list with unique IDs, ReactNode labels, optional decorative icons, default/strong emphasis, disabled state, native button props and individual button refs. Enabled actions use ordinary native Tab behavior unless a consumer explicitly supplies native tabIndex. The native action type defaults to button; form/type/id/data/ARIA attributes and enabled aria-disabled=false are preserved, while action, native, ARIA or group disabled resolves to actual disabled behavior. orientation controls horizontal or vertical geometry. wrap allows narrow layout reflow; a non-wrapping horizontal group uses native inline scrolling so trailing actions remain reachable and focused buttons reveal normally. The forwarded ref and remaining native div attributes target the labelled root; role and accessible label are component-owned. Consumers own every action result, form submission, visibility, navigation, data and focus after an accepted action. Roving arrow navigation belongs to the separate Toolbar component and is intentionally absent here.
