Get Started
Input
Feedback
Display
Installation
i18n
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.
import { CheckCircle2Icon, InfoIcon } from "lucide-react"
import {Installation#
pnpm dlx shadcn@latest add https://ui.tyap.me/r/styles/base/alert.jsonnpx shadcn@latest add https://ui.tyap.me/r/styles/base/alert.jsonyarn dlx shadcn@latest add https://ui.tyap.me/r/styles/base/alert.jsonbunx --bun shadcn@latest add https://ui.tyap.me/r/styles/base/alert.json
Copy and paste the following code into your project.
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
const alertVariants = cva(
[
"group/alert relative grid w-full gap-y-1.5 rounded-2xl border px-5 py-4 text-left text-sm",
"has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-20",
"has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-3.5",
"*:[svg]:row-span-2 *:[svg]:mt-0.5 *:[svg]:self-start *:[svg]:text-current",
"*:[svg:not([class*='size-'])]:size-[18px]",
],
{
variants: {
variant: {
default: "bg-card text-card-foreground",
destructive: [
"border-destructive/20 bg-destructive/5 dark:bg-destructive/10",
"text-destructive",
"*:data-[slot=alert-description]:text-destructive/80",
"*:[svg]:text-current",
],
},
},
defaultVariants: {
variant: "default",
},
}
)
function Alert({
className,
variant,
...props
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
return (
<div
data-slot="alert"
role="alert"
className={cn(alertVariants({ variant }), className)}
{...props}
/>
)
}
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-title"
className={cn(
"leading-snug font-semibold group-has-[>svg]/alert:col-start-2",
"[&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",
className
)}
{...props}
/>
)
}
function AlertDescription({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-description"
className={cn(
"text-sm text-balance text-muted-foreground md:text-pretty",
"group-has-[>svg]/alert:col-start-2",
"[&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",
"[&_p:not(:last-child)]:mb-4",
"[&_li]:mt-0.5 [&_ul]:mt-1.5",
className
)}
{...props}
/>
)
}
function AlertAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-action"
className={cn("absolute top-4 right-4", className)}
{...props}
/>
)
}
export { Alert, AlertTitle, AlertDescription, AlertAction }
Update the import paths to match your project setup.
Usage#
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>Composition#
Use the following composition to build an Alert:
Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertActionExamples#
Basic#
A basic alert with an icon, title and description.
Account updated successfully
Your profile information has been saved. Changes will be reflected immediately.
import { CheckCircle2Icon } from "lucide-react"
import {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.
import { AlertCircleIcon } from "lucide-react"
import {Action#
Use AlertAction 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.
import {
Alert,
AlertAction,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.
Your subscription will expire in 3 days.
Renew now to avoid service interruption or upgrade to a paid plan to continue using the service.
import { AlertTriangleIcon } from "lucide-react"
import {RTL#
To enable RTL support in shadcn/ui, see the RTL configuration guide.
تم الدفع بنجاح
تمت معالجة دفعتك البالغة 29.99 دولارًا. تم إرسال إيصال إلى عنوان بريدك الإلكتروني.
ميزة جديدة متاحة
لقد أضفنا دعم الوضع الداكن. يمكنك تفعيله في إعدادات حسابك.
"use client"
import * as React from "react"API Reference#
Alert#
The Alert component displays a callout for user attention.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "default" |
AlertTitle#
The AlertTitle component displays the title of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |
AlertDescription#
The AlertDescription component displays the description or content of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |
AlertAction#
The AlertAction component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.
| Prop | Type | Default |
|---|---|---|
className | string | - |