Alert

A React alert for inline info, success, warning, and error messages, with titles, an action button, a dismiss control, and screen reader roles built in.

Loading preview

Examples

Practical examples and common states for the same installable component.

Info

Guidance and background state without warning-level emphasis.

examples/alert-info.tsx
import { Alert } from "@/components/wensity/alert";
export function InfoAlert() {
return (
<Alert
variant="info"
title="Workspace indexing started"
description="Search results will update as components are processed."
/>
);
}

Success

Completion state with confident confirmation.

examples/alert-success.tsx
import { Alert } from "@/components/wensity/alert";
export function SuccessAlert() {
return (
<Alert
variant="success"
title="Payment method verified"
description="Invoices and renewal reminders will use this card."
/>
);
}

Warning

Attention state for recoverable issues and upcoming risk.

examples/alert-warning.tsx
import { Alert } from "@/components/wensity/alert";
export function WarningAlert() {
return (
<Alert
variant="warning"
title="Scheduled maintenance starts soon"
description="Template previews may be briefly unavailable."
/>
);
}

Error

Assertive feedback for failed operations.

examples/alert-error.tsx
import { Alert } from "@/components/wensity/alert";
export function ErrorAlert() {
return (
<Alert
variant="error"
title="Webhook signature rejected"
description="Rotate the shared secret and replay the latest event."
/>
);
}

With Action

Inline recovery path and dismiss affordance.

Requires: button

examples/alert-with-action.tsx
import { Alert } from "@/components/wensity/alert";
import { Button } from "@/components/wensity/button";
export function AlertWithAction() {
return (
<Alert
variant="neutral"
title="Connect production domain"
description="Finish DNS verification before enabling checkout links."
action={<Button size="sm" variant="secondary">Open settings</Button>}
/>
);
}

Overview

Alert is a React and Tailwind CSS alert component, in Next.js or any React app, for inline messages inside a page or form, in neutral, info, success, warning, and error styles with matching icons. Errors and warnings render with role alert so screen readers announce them at once, while the calmer variants use role status. Add a title, a description, or any children, an action slot for a button such as Retry, and onDismiss for a close button with its own label. A compact density fits busy forms. For messages that appear and leave on their own, use Toast instead.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add alert

Usage

Import Alert from @/components/wensity/alert and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import { Alert } from "@/components/wensity/alert";
export function AlertDemo() {
return (
<Alert
variant="success"
title="Production deploy completed"
description="The new pricing page is live in all regions."
/>
);
}

Props

PropTypeDefaultDescription
variant"neutral" | "info" | "success" | "warning" | "error""info"Status colour recipe and the default icon that comes with it.
density"comfortable" | "compact""comfortable"Padding scale. compact suits inline or stacked alerts.
titleReact.ReactNode-Bold heading line. Also settable via the AlertTitle subcomponent.
descriptionReact.ReactNode-Body copy under the title. Also settable via AlertDescription.
iconReact.ReactNode-Overrides the icon the variant supplies. Pass null to drop it.
actionReact.ReactNode-Trailing slot for a button or link.
onDismiss() => void-When set, renders a dismiss button and calls this on press.
dismissLabelstring"Dismiss alert"Accessible label for the dismiss button.
  • Dynamic Island Toast component preview

    Dynamic Island Toast

    A pixel-faithful Apple Dynamic Island that morphs, splits, and breathes while it hosts live activities inside your app.

  • Apple Intelligence Glow component preview

    Apple Intelligence Glow

    A soft Apple Intelligence edge glow that traces the screen with a rotating iridescent gradient you can toggle on.

  • Glowing Border component preview

    Glowing Border

    Glowing border CSS for cards: a cursor glowing effect, or beams, spins and pulses.

  • Physics-Based Confetti Cannon component preview

    Physics-Based Confetti Cannon

    Hand-rolled canvas particles with gravity, drag, terminal velocity, and paper ribbons that flutter on the way down.