Skip to main content

alert

Displays a callout for user attention.

Philosophy

Alerts exist to break the user's flow - intentionally. When something demands attention, a subtle inline message beats a disruptive modal every time. We keep the API to just variant because an alert's job is simple: show a message with visual weight. Anything more complex belongs in a dialog.

How It's Built

Loading diagram...

Installation


npx @gentleduck/cli add alert

npx @gentleduck/cli add alert

Usage

import { Terminal } from "lucide-react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
<Alert>
  <Terminal className="h-4 w-4" />
  <AlertTitle>Heads up!</AlertTitle>
  <AlertDescription>
    You can add components and dependencies to your app using the cli.
  </AlertDescription>
</Alert>

Examples

Variants

RTL Support

Set the direction once with DirectionProvider (or <html dir="rtl">) and the alert follows it: the icon moves to the start side. No dir prop or rtl: classes needed.

Motion

Use MotionAlert for a staggered entrance animation powered by motion. The alert, title, and description each use a scaleIn entrance (fade, scale, and blur) with a bouncy spring transition, staggered by delay.

API Reference

Alert

PropTypeDefaultDescription
variant'default' | 'destructive''default'Visual style variant for the alert
dir'ltr' | 'rtl'-Text direction override. Resolved via useDirection (dir prop -> DirectionProvider -> <html dir>).
classNamestring-Additional CSS classes applied to the alert container
childrenReact.ReactNode-Alert content, typically an icon, AlertTitle, and AlertDescription
...propsReact.ComponentProps<'div'>-Additional standard component props.

AlertTitle

PropTypeDefaultDescription
classNamestring-Additional CSS classes applied to the title element
childrenReact.ReactNode-Title text content
...propsReact.ComponentProps<'div'>-Additional standard component props.

AlertDescription

PropTypeDefaultDescription
classNamestring-Additional CSS classes applied to the description element
childrenReact.ReactNode-Description text content
...propsReact.ComponentProps<'div'>-Additional standard component props.

MotionAlert

scaleIn entrance (fade, scale, and blur) with a springBouncy transition on mount. Requires the motion package.

PropTypeDefaultDescription
...propsAlertProps-All props from Alert are supported

MotionAlertTitle

scaleIn entrance (fade, scale, and blur) with a springBouncy transition, delayed 100ms after the container. Requires the motion package.

PropTypeDefaultDescription
...propsAlertTitleProps-All props from AlertTitle are supported

MotionAlertDescription

scaleIn entrance (fade, scale, and blur) with a springBouncy transition, delayed 180ms after the title. Requires the motion package.

PropTypeDefaultDescription
...propsAlertDescriptionProps-All props from AlertDescription are supported