Skip to content

Components

Alert

A status or error message with an optional icon, title and description.

Customize
Ombelle · light

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add alert

Adds components/ui/alert.tsx and installs react, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { Alert, AlertTitle, AlertDescription } from '@/components/ui/alert'

export function SaveStatus() {
  return (
    <Alert>
      <AlertTitle>Preset saved</AlertTitle>
      <AlertDescription>New components now install with this preset.</AlertDescription>
    </Alert>
  )
}

export function Intents() {
  return (
    <>
      <Alert variant="success"><AlertTitle>Saved</AlertTitle><AlertDescription>Your changes are ready.</AlertDescription></Alert>
      <Alert variant="warning"><AlertTitle>Review needed</AlertTitle><AlertDescription>Two items need your attention.</AlertDescription></Alert>
      <Alert variant="info"><AlertTitle>New version</AlertTitle><AlertDescription>A component update is available.</AlertDescription></Alert>
    </>
  )
}

API and states

API
variant (default, destructive, success, warning, info), layout (default, compact), onDismiss, dismissLabel, AlertTitle, AlertDescription, AlertActions, AlertDismiss
Minimum states
Default, success, warning and info (role status); destructive (role alert); dismissible; compact
Native basis
<div> with a live-region role
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.