v0.5.1

Alert

Contextual feedback message for user actions or system events, with optional dismiss and action.

Heads up

Something you should know.

Installation

npx paubha@latest add alert

Usage

import { Alert } from "@/components/ui/alert";

<Alert variant="success" title="Saved" description="Your changes have been saved." />

Examples

Variants

Info

A short description of what happened.

Success

A short description of what happened.

With action and dismiss

API reference

PropTypeDefaultDescription
variant"info" | "success" | "warning" | "error""info"Color treatment and icon. Also determines the role: warning/error use role=alert, info/success use role=status.
titleReactNode—Bold heading line.
descriptionReactNode—Body text, always fg-secondary regardless of variant.
actionLabelReactNode—Renders a text-style action button when present.
onAction() => void—Called when the action button is clicked.
dismissiblebooleanfalseShows a dismiss button with aria-label="Dismiss".
onDismiss() => void—Called when the dismiss button is clicked.

Accessibility

Accessibility

  • Role is variant-dependent. warning/error use role="alert" (assertive, interrupting); info/success use role="status" (polite). This is computed automatically from the variant prop, not something you set yourself.

  • Icon. Decorative, aria-hidden.

  • Dismiss button. aria-label="Dismiss".