ZaidanHomeDocsComponentsBlocksChartsTypesetCreate

Command Palette

Search for a command to run...

GitHub
New
Sections
  • Introduction
  • Components
  • Blocks
  • Installation
  • Customization
  • Dark Mode
  • Typeset
  • Zaidan Skills
  • FAQ
  • Roadmap
  • Changelog
Installation
  • Astro
  • Manual
  • Solid Start
  • TanStack Router
  • TanStack Start
  • Vite
Blocks
  • Data Grid
  • Event Calendar
  • Filters
  • Gantt
  • Image Crop
  • Kanban
  • Message Scroller
  • Questionnaire
  • Sortable
Components
  • Accordion
  • Alert
  • Alert Dialog
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Drawer
  • Dropdown Menu
  • Empty
  • Field
  • Hover Card
  • Input
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • Native Select
  • Navigation Menu
  • Pagination
  • Popover
  • Progress
  • Radio Group
  • Resizable
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip

Alert

Displays a callout for user attention.

Kobalte
Kobalte

The Alert component is built on top of Kobalte Alert, which provides accessible callout semantics.

Payment successful
Your payment of $29.99 has been processed. A receipt has been sent to your email address.
New feature available
We've added dark mode support. You can enable it in your account settings.
1
import { CheckCircle2Icon, InfoIcon } from "lucide-solid";
2
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
3
4
export default function AlertDemo() {
5
return (
6
<div class="grid w-full max-w-md items-start gap-4">
7
<Alert>
8
<CheckCircle2Icon />
9
<AlertTitle>Payment successful</AlertTitle>
10
<AlertDescription>
11
Your payment of $29.99 has been processed. A receipt has been sent to your email address.
12
</AlertDescription>
13
</Alert>
14
<Alert>
15
<InfoIcon />
16
<AlertTitle>New feature available</AlertTitle>
17
<AlertDescription>
18
We&apos;ve added dark mode support. You can enable it in your account settings.
19
</AlertDescription>
20
</Alert>
21
</div>
22
);
23
}

Installation

pnpm dlx shadcn@latest add @zaidan/alert
npx shadcn@latest add @zaidan/alert
yarn dlx shadcn@latest add @zaidan/alert
bunx --bun shadcn@latest add @zaidan/alert

Usage

1
import {
2
Alert,
3
AlertAction,
4
AlertDescription,
5
AlertTitle,
6
} from "~/components/ui/alert";
7
import { Button } from "~/components/ui/button";
8
import InfoIcon from "lucide-solid/icons/info";
1
<Alert>
2
<InfoIcon />
3
<AlertTitle>Heads up!</AlertTitle>
4
<AlertDescription>
5
You can add components and dependencies to your app using the CLI.
6
</AlertDescription>
7
<AlertAction>
8
<Button variant="outline">Enable</Button>
9
</AlertAction>
10
</Alert>

Composition

Use the following composition to build an Alert:

Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction

Basic

A basic alert with an icon, title, and description.

Account updated successfully
Your profile information has been saved. Changes will be reflected immediately.
1
import { CheckCircle2Icon } from "lucide-solid";
2
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
3
4
export default function AlertBasic() {
5
return (
6
<Alert class="max-w-md">
7
<CheckCircle2Icon />
8
<AlertTitle>Account updated successfully</AlertTitle>
9
<AlertDescription>
10
Your profile information has been saved. Changes will be reflected immediately.
11
</AlertDescription>
12
</Alert>
13
);
14
}

Destructive

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

Payment failed
Your payment could not be processed. Please check your payment method and try again.
1
import { AlertCircleIcon } from "lucide-solid";
2
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
3
4
export default function AlertDestructive() {
5
return (
6
<Alert variant="destructive" class="max-w-md">
7
<AlertCircleIcon />
8
<AlertTitle>Payment failed</AlertTitle>
9
<AlertDescription>
10
Your payment could not be processed. Please check your payment method and try again.
11
</AlertDescription>
12
</Alert>
13
);
14
}

Action

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

Dark mode is now available
Enable it under your profile settings to get started.
1
import { Alert, AlertAction, AlertDescription, AlertTitle } from "~/components/ui/alert";
2
import { Button } from "~/components/ui/button";
3
4
export default function AlertActionExample() {
5
return (
6
<Alert class="max-w-md">
7
<AlertTitle>Dark mode is now available</AlertTitle>
8
<AlertDescription>Enable it under your profile settings to get started.</AlertDescription>
9
<AlertAction>
10
<Button size="xs">Enable</Button>
11
</AlertAction>
12
</Alert>
13
);
14
}

Custom Colors

Customize alert colors with utility classes such as bg-amber-50 dark:bg-amber-950.

Your subscription will expire in 3 days.
Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.
1
import { AlertTriangleIcon } from "lucide-solid";
2
import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert";
3
4
export default function AlertColors() {
5
return (
6
<Alert class="max-w-md border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-50">
7
<AlertTriangleIcon />
8
<AlertTitle>Your subscription will expire in 3 days.</AlertTitle>
9
<AlertDescription>
10
Renew now to avoid service interruption or upgrade to a paid plan to continue using the
11
service.
12
</AlertDescription>
13
</Alert>
14
);
15
}

API Reference

Alert

Displays a callout for user attention.

PropTypeDefault
variant"default" | "destructive""default"

AlertTitle

Displays the title of an alert.

PropTypeDefault
classstring-

AlertDescription

Displays an alert's description or content.

PropTypeDefault
classstring-

AlertAction

Displays an action element positioned at the alert's top right.

PropTypeDefault
classstring-

For all primitive props and keyboard interactions, see the Kobalte Alert API reference.

On This Page

  • Installation
  • Usage
  • Composition
  • Basic
  • Destructive
  • Action
  • Custom Colors
  • API Reference
    • Alert
    • AlertTitle
    • AlertDescription
    • AlertAction
Built by Kevin Abatan. The source code is available on GitHub.