# Button Group

A spaced group of frequently performed, related actions.

A button group displays multiple related actions together while each button keeps its own shape, size, state, and native keyboard behavior.

```tsx
import { Button, ButtonGroup } from "@zentara-co/zenos-ui";

function ButtonGroupExample() {
  return (
    <ButtonGroup label="Form actions">
      <Button variant="primary">Submit</Button>
      <Button>Cancel</Button>
    </ButtonGroup>
  );
}
```

## Shared and custom variants

Set `variant` once on the group to pass it to buttons and icon buttons that do not choose their own variant. Add `variantClassName` for a consumer-owned appearance; an explicitly styled child still overrides the group.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { Button, ButtonGroup, IconButton } from "@zentara-co/zenos-ui";

const campaignButtonVariant =
  "rounded-full bg-background-accent-purple-bolder-default text-text-contrary hover:bg-background-accent-purple-bolder-hover active:bg-background-accent-purple-bolder-pressed";

function ButtonGroupCustomVariantExample() {
  return (
    <ButtonGroup
      label="Campaign actions"
      variant="campaign"
      variantClassName={campaignButtonVariant}
    >
      <Button>Launch</Button>
      <Button>Preview</Button>
      <IconButton aria-label="Campaign options">
        <PlusIcon />
      </IconButton>
    </ButtonGroup>
  );
}
```

## Import

```tsx
import { ButtonGroup } from "@zentara-co/zenos-ui";
```

## Anatomy

```text
ButtonGroup.Root
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| variant | ButtonVariant \| custom string | default | Visual treatment inherited by buttons without an override. |
| variantClassName | string | — | Variant classes inherited by buttons using the group variant. |
| label | string | — | Accessible group name used when aria-label is omitted. |
| aria-label | string | — | Accessible group name. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

`ButtonGroup` renders an accessible group but does not replace the keyboard behavior of its children. Each enabled button remains in the native tab order. Give the group a concise `label` or `aria-label`, keep button labels specific, and provide an accessible name for every icon-only control.

Use [SplitButton](/components/split-button/) when one primary action and its secondary menu action should appear as one connected control.

Source: https://zenos-ui.pages.dev/components/button-group/