Components

Alert

Displays a callout for user attention.

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 alert 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 alert.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/alert --files LICENSE.md,registry/ui/alert.tsx,registry/ui/lib/utils.ts,registry/ui/primitives/LICENSE,registry/ui/primitives/internals/types.ts --force
mkdir -p ./src/components/ui
cp -R ./.cache/shadcn-preact/alert/registry/ui/. ./src/components/ui/
cp ./.cache/shadcn-preact/alert/LICENSE.md ./src/components/ui/LICENSE.md

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

Selected source files (4)

Usage

import { Button } from "./components/ui/button";
import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "./components/ui/alert"
<Alert>
  <InfoIcon />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components and dependencies to your app using the cli.
  </AlertDescription>
  <AlertAction>
    <Button variant="outline">Enable</Button>
  </AlertAction>
</Alert>

Examples

Basic

A basic alert with an icon, title and description.

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

Destructive

Use variant="destructive" to create a destructive alert.

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

Action

Use AlertAction to add a button or other action element to the alert.

ActionSource
Example requirements

Also uses: Button.

Custom Colors

You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert component.

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

Reference

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

Component source