Skip to content

ButtonGroup

Navigation

A labeled cluster of related actions in either orientation.

Horizontal actionsVertical icon actionsDisabled action
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Place related Button components inside ButtonGroup. The wrapper groups actions visually and semantically; each child remains an independent button. Use ToggleGroup when the items form a selection.

Import
import { ButtonGroup } from "@/components/ui/button-group";

Shipped as editable source in src/components/ui/button-group.tsx in both apps. Copy the implementation below when moving it to another project. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

Component source

The complete implementation is included in both apps. It uses the React, Radix, Lucide, and shared-core dependencies already installed in Apex. Keep your project’s semantic theme tokens when reusing it.

src/components/ui/button-group.tsx
import type { ComponentProps } from "react";
import { cn } from "@dashboardpack/core/lib/utils";
export function ButtonGroup({
  className,
  orientation = "horizontal",
  ...props
}: ComponentProps<"div"> & { orientation?: "horizontal" | "vertical" }) {
  return (
    <div
      role="group"
      className={cn(
        "inline-flex gap-1 rounded-lg border bg-background p-1",
        orientation === "vertical" && "flex-col",
        className,
      )}
      {...props}
    />
  );
}

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

ButtonGroup props
PropType / DefaultDescription
orientationhorizontal | vertical

Default: horizontal

Direction of the action group.
aria-labelstring

Default: —

Accessible group name.
childrenReactNode

Default: —

Buttons or other appropriate related controls.
classNamestring

Default: —

Extend wrapper styles.

Build with these too