Alert Component

A component that displays a brief, important message in a way that attracts the user's attention.

  • Various predefined variants for different situations
  • Support for custom icons
  • Ability to include action buttons
  • Accessible with appropriate ARIA roles

Installation

The Alert component is part of our UI library. You can import it directly from the components directory.


Usage

Here is how to use the alert in your project.

React TSX
1import {
2  Alert,
3  AlertTitle,
4  AlertDescription,
5} from "@/components/modern-ui/alert"

React TSX
1<Alert>
2  <AlertTitle>Heads up!</AlertTitle>
3  <AlertDescription>
4    You can add components to your app using the cli.
5  </AlertDescription>
6</Alert>

Examples

Default Alert

Success Alert

Destructive Alert

Info Alert

Alert with Actions

API Reference

Alert

PropTypeDefaultDescription
variant'default' | 'destructive' | 'info''default'The variant of the alert
classNamestring-Additional CSS classes
childrenReactNode-The content of the alert

AlertTitle

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReactNode-The title of the alert

AlertDescription

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReactNode-The description of the alert