Alert

A styled text component for highlighting important information, warnings, or contextual messages within a UI.

Example

Usage

Installation

Install following dependencies:

npm install react-aria-components tw-animate-css tailwindcss-react-aria-components clsx tailwind-merge motion

Add cn helper using clsx and twMerge for conditional class merging in Tailwind components.

lib/utils.ts

Copy and paste the following code into your project.

components/ui/core/alert.tsx
npx libravelui@latest add alert

Anatomy

import { Alert } from "@/components/ui/core/alert";
<div className="space-y-4">
  <Alert
    title="Default Alert"
    message="Alert for default"
    icon={<Bell className="size-5" data-slot="icon" />}
  />
  <Alert
    tone="info"
    title="Info Alert"
    message="Alert for info"
    icon={<Info className="size-5" data-slot="icon" />}
  />
  <Alert
    tone="success"
    title="Success Alert"
    message="Alert for success"
    icon={<CheckCircle className="size-5" data-slot="icon" />}
  />
  <Alert
    tone="warning"
    title="Warning Alert"
    message="Alert for warning"
    icon={<AlertTriangle className="size-5" data-slot="icon" />}
  />
  <Alert
    tone="destructive"
    title="Error Alert"
    message="Alert for destructive"
    icon={<XCircle className="size-5" data-slot="icon" />}
  />
</div>

Another Examples

Tones

The Alert component provides several tones to display different types of important messages: neutral, info, success, warning, and error.

Usage

Custom Build

The Custom Alert is built using low-level primitives like AlertRoot, AlertTitle, and AlertDescription. This setup offers full control over structure and behavior, making it easy to integrate buttons, icons, or custom interactions. It also includes a close action, allowing users to dismiss the alert manually when appropriate.

Usage

Can be Closed

An alert that can be manually dismissed by the user. This pattern improves usability by allowing temporary messages to be closed once they’re no longer needed, keeping the interface clean and focused.

Usage

Controlled State

An alert that can be manually dismissed by the user. This pattern improves usability by allowing temporary messages to be closed once they’re no longer needed, keeping the interface clean and focused.

Usage

Props

Loading types…

Accessible React component library to copy, customize, and own your UI. Built for Next.js, Vite, and Laravel.

Crafted by dervyon. Peep the Source Code on GitHub.

Hosted on Vercel. The source code's got the MIT license.

2025 - 2026 · LibravelUI

Starter Kits

Templates

    Coming Soon

Labs