Components

Button Group

A container that groups related buttons together with consistent styling.

PreviewSource
Example requirements

Also uses: Button.

bun add --exact lucide-preact@1.55.0

Installation

Complete the project setup first. The init command configures TypeScript, Vite, Tailwind CSS v4, and Preact compatibility.

CLI

Run init once using the installation guide, then add this component. The CLI copies the required source files and installs their exact dependencies with Bun.

bunx --bun github:LiasCode/shadcn-preact#main add button-group button

Add --dry-run to review the changes. Existing modified files are protected; use --overwrite only when you want to replace them.

Manual installation / degit (optional)

1. Install dependencies

bun add --exact class-variance-authority@0.7.1 cn@0.4.0 preact@11.0.1 tw-animate-css@1.4.0

The usage example also needs Button. Follow their installation guides as well.

2. Copy the component with degit

Run this from your project root. It selects button-group.tsx, its local dependencies, and both licenses directly from the repository, then copies them into src/components/ui.

bunx degit@3.10.0 https://github.com/LiasCode/shadcn-preact#main ./.cache/shadcn-preact/button-group --files LICENSE.md,registry/ui/button-group.tsx,registry/ui/lib/utils.ts,registry/ui/primitives/LICENSE,registry/ui/primitives/internals/empty.ts,registry/ui/primitives/internals/getReactElementRef.ts,registry/ui/primitives/internals/getStateAttributesProps.ts,registry/ui/primitives/internals/mergeObjects.ts,registry/ui/primitives/internals/resolveClassName.ts,registry/ui/primitives/internals/resolveStyle.ts,registry/ui/primitives/internals/types.ts,registry/ui/primitives/internals/useMergedRefs.ts,registry/ui/primitives/internals/useRefWithInit.ts,registry/ui/primitives/internals/useRenderElement.ts,registry/ui/primitives/merge-props/index.ts,registry/ui/primitives/separator/Separator.tsx,registry/ui/primitives/separator/index.ts,registry/ui/primitives/use-render/index.ts,registry/ui/separator.tsx --force
mkdir -p ./src/components/ui
cp -R ./.cache/shadcn-preact/button-group/registry/ui/. ./src/components/ui/
cp ./.cache/shadcn-preact/button-group/LICENSE.md ./src/components/ui/LICENSE.md

The temporary copy lives in .cache/shadcn-preact/button-group. Existing components stay in place; shared source files are updated from main.

Selected source files (18)

Usage

import { Button } from "./components/ui/button";
import {
  ButtonGroup,
  ButtonGroupSeparator,
  ButtonGroupText,
} from "./components/ui/button-group"
<ButtonGroup>
  <Button>Button 1</Button>
  <Button>Button 2</Button>
</ButtonGroup>

Examples

Size

Control the size of buttons using the size prop on individual buttons.

Example requirements

Also uses: Button.

bun add --exact lucide-preact@1.55.0

Separator

The ButtonGroupSeparator component visually divides buttons within a group.

SeparatorSource
Example requirements

Also uses: Button.

Split

Create a split button group by adding two buttons separated by a ButtonGroupSeparator.

SplitSource
Example requirements

Also uses: Button.

bun add --exact lucide-preact@1.55.0

Input

Wrap an Input component with buttons.

InputSource
Example requirements

Also uses: Button, Input.

bun add --exact lucide-preact@1.55.0

Reference

See the official Button Group documentation for composition patterns and API details. This page uses the Preact port and examples from the pinned upstream revision.

Component source