Alert
A component for displaying important messages to users.
New Message
You've got a new message.
"use client";
import { Mail } from "lucide-react";
import { Alert, AlertAction, AlertDescription, AlertTitle } from "@/components/ui/alert/alert";
import { Button } from "@/components/ui/button/button";
import styles from "./alert-demo.module.css";
export default function AlertDemo() {
return (
<div className={styles.container}>
<Alert>
<Mail size={14} stroke="var(--muted-foreground)" />
<AlertTitle>New Message</AlertTitle>
<AlertDescription> You've got a new message.</AlertDescription>
<AlertAction>
<Button size="sm" variant="secondary">
View Inbox
</Button>
</AlertAction>
</Alert>
</div>
);
}
npx shadcn@latest add @roiui/alertnpx shadcn@latest add @roiui/alert-tailwindanatomy
<Alert>
<AlertTitle />
<AlertDescription />
</Alert>
Error
Your session has expired. Please log in again.
"use client";
import { Ban } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert/alert";
import styles from "./alert-destructive.module.css";
export default function AlertDestructive() {
return (
<div className={styles.container}>
<Alert variant="destructive">
<Ban size={16} />
<AlertTitle>Error</AlertTitle>
<AlertDescription>Your session has expired. Please log in again.</AlertDescription>
</Alert>
</div>
);
}
Warning
Something went wrong.
"use client";
import { AlertTriangle } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert/alert";
import styles from "./alert-warning.module.css";
export default function AlertWarning() {
return (
<div className={styles.container}>
<Alert variant="warning">
<AlertTriangle size={16} />
<AlertTitle>Warning</AlertTitle>
<AlertDescription>Something went wrong.</AlertDescription>
</Alert>
</div>
);
}
Success
Your account has been created successfully.
"use client";
import { CheckCircle } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert/alert";
import styles from "./alert-success.module.css";
export default function AlertSuccess() {
return (
<div className={styles.container}>
<Alert variant="success">
<CheckCircle size={16} />
<AlertTitle>Success</AlertTitle>
<AlertDescription>Your account has been created successfully.</AlertDescription>
</Alert>
</div>
);
}
Info
New features are available! Check out the latest updates.
"use client";
import { Info } from "lucide-react";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert/alert";
import styles from "./alert-info.module.css";
export default function AlertInfo() {
return (
<div className={styles.container}>
<Alert variant="info">
<Info size={16} />
<AlertTitle>Info</AlertTitle>
<AlertDescription>New features are available! Check out the latest updates.</AlertDescription>
</Alert>
</div>
);
}
Component props
Prop
Type
Default
Name
variantDescription
The visual style variant of the alert
Type
"default" | "destructive" | "warning" | "success" | "info"Default
"default"Name
sizeDescription
The size of the alert
Type
"default" | "sm"Default
"default"Name
classNameDescription
Additional CSS classes to apply to the alert
Type
stringDefault
-
Name
childrenDescription
The content to display inside the alert
Type
ReactNodeDefault
-
Component props
Prop
Type
Default
Name
classNameDescription
Additional CSS classes to apply to the alert title
Type
stringDefault
-
Name
childrenDescription
The title content
Type
ReactNodeDefault
-
Component props
Prop
Type
Default
Name
classNameDescription
Additional CSS classes to apply to the alert description
Type
stringDefault
-
Name
childrenDescription
The description content
Type
ReactNodeDefault
-