Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Alert

Displays a callout for user attention.

Installation

npx logic2b@next add alert

Usage

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

<Alert variant="destructive">
  <AlertTitle>Error</AlertTitle>
  <AlertDescription>Something went wrong.</AlertDescription>
</Alert>

Usage notes

An optional leading svg icon is placed in its own column automatically. AlertTitle and AlertDescription accept the standard div props.

Examples

With icon

Drop a Lucide icon as the first child to render it alongside the title.

Destructive

Use variant="destructive" to signal an error state.

Live playground

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<Alert
  variant="default"
  className="grid-cols-1"
>Your changes have been saved.</Alert>

API reference

Generated from the public TypeScript exports in src/ui/alert.tsx.

View JSON

Alert

Component
Props: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>
PropTypeRequiredDefaultDescription
variantnull | "default" | "destructive"No——

AlertTitle

Component
Props: React.ComponentProps<"div">

AlertDescription

Component
Props: React.ComponentProps<"div">

Accessibility contract

Machine-readable behavior and consumer responsibilities for alert.

View JSON
Support
Native semantics
Pattern
alert
HTML role=alert

Built-in semantics

  • Uses role=alert so newly mounted urgent messages are announced.

Consumer responsibilities

  • Reserve it for important dynamic messages; avoid mounting routine static content as an alert.