Alert

Displays a callout for user attention.

Installation

pnpm dlx cubix@latest add alert --base radix

Usage

Import
import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/cubix/alert"
Example
<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:

Composition
Alert
├── Icon
├── AlertTitle
├── AlertDescription
└── AlertAction

Basic

A basic alert with an icon, title and description.

Destructive

Use variant="destructive" to create a destructive alert.

Action

Use AlertAction to add a button or other action element to the alert.

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.

RTL

Wrap the alert in dir="rtl" and lang="fa" so layout, action placement, and IRANSans XV follow Persian.

API Reference

Alert

The Alert component displays a callout for user attention.

PropTypeDefaultDescription
variant"default" | "destructive""default"The visual style of the alert.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).
...propsReact.ComponentProps<'div'>-All native div attributes (role, id, aria-*, ...) are forwarded to the rendered element.

AlertTitle

The AlertTitle component displays the title of the alert.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

AlertDescription

The AlertDescription component displays the description or content of the alert.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

AlertAction

The AlertAction component displays an action element (like a button) positioned absolutely in the top-end corner of the alert.

PropTypeDefaultDescription
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).