NOCTA UI

Alert

A flexible alert component for displaying important messages with multiple variants and dark mode support

Installation

Install the Alert component using the nocta-ui CLI:

Terminal
npx nocta-ui add alert

Then import the components you need:

Import
import {
  Alert,
  AlertTitle,
  AlertDescription,
  AlertIcon,
} from '@/components/ui/alert';

Basic Usage

Default Alert

Simple Alert

Variants

The Alert component supports four variants: default, destructive, warning, and success.

Alert Without Icons

Usage Examples

Form Validation

System Notifications

Customization

Custom Styling

The Alert component accepts a className prop for custom styling:

Custom Styling
<Alert className="border-2 shadow-lg">
  <AlertDescription>
    Custom styled alert with enhanced border and shadow.
  </AlertDescription>
</Alert>

<Alert className="max-w-md mx-auto">
  <AlertTitle>Centered Alert</AlertTitle>
  <AlertDescription>
    This alert has a maximum width and is centered.
  </AlertDescription>
</Alert>

Props

Alert

PropTypeDefaultDescription
variant'default' | 'destructive' | 'warning' | 'success''default'Alert style variant
classNamestring''Additional CSS classes
childrenReact.ReactNodeAlert content

AlertTitle

PropTypeDefaultDescription
asReact.ElementType'h5'HTML element to render
classNamestring''Additional CSS classes
childrenReact.ReactNodeTitle content

AlertDescription

PropTypeDefaultDescription
classNamestring''Additional CSS classes
childrenReact.ReactNodeDescription content

AlertIcon

PropTypeDefaultDescription
classNamestring''Additional CSS classes
childrenReact.ReactNodeIcon content

All components also accept their respective HTML element attributes.