alert-default
Default Alert
This is a default alert for general information.
import { AlertCircle } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function Component() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<Alert>
<AlertCircle />
<AlertTitle>Default Alert</AlertTitle>
<AlertDescription>
This is a default alert for general information.
</AlertDescription>
</Alert>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-default.json"
alert-error
Error Alert
Something went wrong. Please try again.
import { AlertCircle } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<Alert variant="destructive">
<AlertCircle />
<AlertTitle>Error Alert</AlertTitle>
<AlertDescription>
Something went wrong. Please try again.
</AlertDescription>
</Alert>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-error.json"
alert-info
Info Alert
Here's some helpful information you should know.
import { Info } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<Alert variant="info">
<Info />
<AlertTitle>Info Alert</AlertTitle>
<AlertDescription>
Here's some helpful information you should know.
</AlertDescription>
</Alert>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-info.json"
alert-success
Success Alert
Your action was completed successfully!
import { CheckCircle } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<Alert variant="success">
<CheckCircle />
<AlertTitle>Success Alert</AlertTitle>
<AlertDescription>
Your action was completed successfully!
</AlertDescription>
</Alert>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-success.json"
alert-warning
Warning Alert
Please review this information carefully before proceeding.
import { AlertTriangle } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<Alert variant="warning">
<AlertTriangle />
<AlertTitle>Warning Alert</AlertTitle>
<AlertDescription>
Please review this information carefully before proceeding.
</AlertDescription>
</Alert>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-warning.json"
alert-size
Small Alert
This is a small alert with compact spacing.
Medium Alert (Default)
This is a medium-sized alert with standard spacing.
Large Alert
This is a large alert with generous spacing for important messages.
import { AlertCircle } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function AlertDemo() {
return (
<div className="grid w-full max-w-xl items-start gap-4">
<section className="space-y-4">
<Alert size="sm">
<AlertCircle />
<AlertTitle>Small Alert</AlertTitle>
<AlertDescription>
This is a small alert with compact spacing.
</AlertDescription>
</Alert>
<Alert size="md">
<AlertCircle />
<AlertTitle>Medium Alert (Default)</AlertTitle>
<AlertDescription>
This is a medium-sized alert with standard spacing.
</AlertDescription>
</Alert>
<Alert size="lg">
<AlertCircle />
<AlertTitle>Large Alert</AlertTitle>
<AlertDescription>
This is a large alert with generous spacing for important messages.
</AlertDescription>
</Alert>
</section>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-size.json"
alert-01
New version available
Version 2.1.0 is now available with security improvements.
"use client"
import { useState } from "react"
import { Download } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
export function Component() {
const [dismissed, setDismissed] = useState(false)
if (dismissed) {
return (
<div className="flex w-full justify-center p-6">
<div className="w-full max-w-lg text-center">
<p className="text-muted-foreground mb-4">Alert dismissed</p>
<Button variant="outline" onClick={() => setDismissed(false)}>
Show Alert
</Button>
</div>
</div>
)
}
return (
<div className="flex w-full justify-center p-6">
<div className="w-full max-w-lg">
<Alert>
<Download />
<AlertTitle>New version available</AlertTitle>
<AlertDescription>
<p className="mb-3">
Version 2.1.0 is now available with security improvements.
</p>
<div className="flex gap-2">
<Button size="sm">Download Now</Button>
<Button
size="sm"
variant="outline"
onClick={() => setDismissed(true)}
>
Dismiss
</Button>
</div>
</AlertDescription>
</Alert>
</div>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-01.json"
alert-02
Verify your email to activate your account
We've sent a confirmation link to your inbox. Check your email to complete the sign-up.
"use client"
import { useState } from "react"
import { CircleAlertIcon, XIcon } from "lucide-react"
import {
Alert,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function Component() {
const [isActive, setIsActive] = useState(true)
if (!isActive) return null
return (
<div className="flex w-full justify-center p-6">
<div className="w-full max-w-lg">
<Alert className="flex justify-between">
<CircleAlertIcon />
<div className="flex flex-1 flex-col gap-1">
<AlertTitle>Verify your email to activate your account</AlertTitle>
<AlertDescription>
We've sent a confirmation link to your inbox. Check your
email to complete the sign-up.
</AlertDescription>
</div>
<button className="cursor-pointer" onClick={() => setIsActive(false)}>
<XIcon className="size-5" />
<span className="sr-only">Close</span>
</button>
</Alert>
</div>
</div>
)
}
pnpm dlx shadcn@latest add "https://ui.dalim.in/r/alert-02.json"
Installation
pnpm dlx shadcn@latest add alert
Usage
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert variant="default | destructive">
<Terminal />
<AlertTitle>Heads up!</AlertTitle>
<AlertDescription>
You can add components and dependencies to your app using the cli.
</AlertDescription>
</Alert>
API Reference
Alert
Prop | Type | Default | Description |
---|---|---|---|
variant | "default" | "destructive" | "success" | "warning" | "info" | "default" | Controls the color scheme and intent of the alert. |
size | "sm" | "md" | "lg" | "md" | Adjusts padding, text size, and icon sizing. |
className | string | — | Additional CSS classes to style the alert. |
...props | React.ComponentProps<"div"> | — | All native div element props. |
AlertTitle
Prop | Type | Default | Description |
---|---|---|---|
className | string | — | Additional CSS classes for the title. |
...props | React.ComponentProps<"div"> | — | All native div element props. |
AlertDescription
Prop | Type | Default | Description |
---|---|---|---|
className | string | — | Additional CSS classes for the description. |
...props | React.ComponentProps<"div"> | — | All native div element props. |