Components

Button

Displays a button or a component that looks like a button.

PreviewSource
Example requirements
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

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

2. Copy the component with degit

Run this from your project root. It selects button.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 --files LICENSE.md,registry/ui/button.tsx,registry/ui/lib/utils.ts,registry/ui/primitives/LICENSE,registry/ui/primitives/button/Button.tsx,registry/ui/primitives/button/index.ts,registry/ui/primitives/internals/composite/root/CompositeRootContext.ts,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/useButton.ts,registry/ui/primitives/internals/useFocusableWhenDisabled.ts,registry/ui/primitives/internals/useIsoLayoutEffect.ts,registry/ui/primitives/internals/useMergedRefs.ts,registry/ui/primitives/internals/useRefWithInit.ts,registry/ui/primitives/internals/useRenderElement.ts,registry/ui/primitives/internals/useStableCallback.ts,registry/ui/primitives/merge-props/index.ts --force
mkdir -p ./src/components/ui
cp -R ./.cache/shadcn-preact/button/registry/ui/. ./src/components/ui/
cp ./.cache/shadcn-preact/button/LICENSE.md ./src/components/ui/LICENSE.md

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

Selected source files (21)

Usage

import { Button } from "./components/ui/button"
<Button variant="outline">Button</Button>

Examples

Size

Use the size prop to change the size of the button.

Example requirements
bun add --exact lucide-preact@1.55.0

Default

DefaultSource

Outline

OutlineSource

Secondary

SecondarySource

Ghost

GhostSource

Destructive

DestructiveSource

Icon

Example requirements
bun add --exact lucide-preact@1.55.0

With Icon

Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the icon for the correct spacing.

With IconSource
Example requirements
bun add --exact lucide-preact@1.55.0

Rounded

Use the rounded-full class to make the button rounded.

RoundedSource
Example requirements
bun add --exact lucide-preact@1.55.0

Spinner

Render a <Spinner /> component inside the button to show a loading state. Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the spinner for the correct spacing.

SpinnerSource
Example requirements

Also uses: Spinner.

As Link

You can use the buttonVariants helper to make a link look like a button.

As LinkSource

Reference

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

Component source