Alert Component - Ontada Design System

A comprehensive alert component with full WCAG 2.2 accessibility support, using Ontada Design System tokens.

Alert Variants

Info Alert

Success Alert

Warning Alert

Error Alert

Dismissible Alerts

These alerts can be dismissed by clicking the close button or pressing the Escape key when focused.

Without Icons

Alerts can be displayed without icons for a cleaner, more minimal appearance.

Accessibility Features (WCAG 2.2)

Semantic HTML: Uses proper heading hierarchy and semantic elements
ARIA Roles: role="alert" for immediate user attention
Live Regions: aria-live="polite" (info/success) or "assertive" (warning/error)
Atomic Announcements: aria-atomic="true" ensures full alert is read
Keyboard Support: Dismissible alerts can be closed with Escape key
Focus Management: Dismiss button is keyboard accessible with visible focus ring
Color Contrast: All text meets WCAG AA standards (4.5:1 minimum)
Design Tokens: Uses Ontada Design System CSS custom properties
Typography: Nunito font family with design system font sizes and weights

Design System Tokens Used

Colors

--primary (Info)

--chart-4 (Success)

--accent (Warning)

--destructive-foreground (Error)

Typography

--font-family-nunito

--text-base (Title)

--text-sm (Description)

--font-weight-semibold (Title)

--font-weight-regular (Description)

Border Radius

--radius-button (Alert container)

--radius (Dismiss button)

Interactive States

--ring (Focus ring)

--border (Border color)

Usage Example (React)

<!-- Basic info alert -->
<Alert variant="info">
  <AlertTitle>Information</AlertTitle>
  <AlertDescription>
    Your session will expire soon.
  </AlertDescription>
</Alert>

<!-- Dismissible warning alert -->
<Alert 
  variant="warning" 
  dismissible 
  onDismiss={() => console.log("Dismissed")}
>
  <AlertTitle>Warning</AlertTitle>
  <AlertDescription>
    Please review before continuing.
  </AlertDescription>
</Alert>

<!-- Success alert without icon -->
<Alert variant="success" hideIcon>
  <AlertDescription>
    Operation completed successfully.
  </AlertDescription>
</Alert>