Payment successful
Your payment of $29.99 has been processed. A receipt has been sent to your email address.
import { CheckCircle2Icon } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export function AlertDemo() {Installation
pnpm slabui add alert
Usage
import {
Alert,
AlertAction,
AlertButton,
AlertButtonIcon,
AlertContent,
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>Composition
Use the following composition to build an Alert:
Alert
โโโ Icon
โโโ AlertContent
โโโโโ AlertTitle
โโโโโ AlertDescription
โโโ AlertAction
โโโโโ ButtonExamples
Basic
A basic alert with an icon, title and description.
Success! Your changes have been saved.
Success! Your changes have been saved.
This is an alert with title and description.
This is an alert with title and description.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export function AlertBasic() {
return (
<div className="grid w-full max-w-md items-start gap-4 scr">Variants
Use variant to change the appearance of the alert.
Success! Your changes have been saved.
This is an alert with title and description.
Success! Your changes have been saved.
This is an alert with title and description.
Success! Your changes have been saved.
This is an alert with title and description.
Success! Your changes have been saved.
This is an alert with title and description.
Success! Your changes have been saved.
This is an alert with title and description.
Success! Your changes have been saved.
This is an alert with title and description.
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export function AlertVariants() {
return (
<>Action
Use AlertAction and Button to add a button or other action element to the alert.
Dark mode is now available
Enable it under your profile settings to get started.
Dark mode is now available
Enable it under your profile settings to get started.
Dark mode is now available
Enable it under your profile settings to get started.
Dark mode is now available
Enable it under your profile settings to get started.
import { InfoIcon, X } from "lucide-react"
import {
Alert,
AlertAction,With Icons
Use svg Icon to add an icon to the alert button.
Let's try one with icon, title and a link
This one has an icon and a description only. No title. But it has a link and a second link.
Success! Your changes have been saved
This is an alert with icon, title and description.
import { InfoIcon } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export function AlertBasic() {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.
Plot Twist: This Alert is Actually Amber!
This one has custom colors for light and dark mode.
Plot Twist: This Alert is Actually Amber!
This one has custom colors for light and dark mode.
import { CheckCircle2 } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
export function AlertCustom() {API Reference
Alert
The Alert component displays a callout for user attention.
| Prop | Default | Type |
|---|---|---|
variant | default | default | primary | danger | success | warning | inverted |
AlertTitle
The AlertTitle component displays the title of the alert.
| Prop | Default | type |
|---|---|---|
className | - | string |
AlertDescription
The AlertDescription component displays the description or content of the alert.
| Prop | Default | Type |
|---|---|---|
className | - | string |
AlertAction
The AlertAction component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.
| Prop | Default | Type |
|---|---|---|
className | - | string |