Components
Feedback
Alert

Alert

Alert is used to communicate status, feedback, and important contextual information.

Use it for inline success/error notices, warnings, and informational callouts.

Installation

1. Install dependencies:

npm install class-variance-authority

2. Copy the source code:

3. Update the import paths to match your project structure.


Usage

import {
  Alert,
  AlertDescription,
  AlertIcon,
  AlertTitle,
} from "@hoag/ui/components/alert";
 
export default function Demo() {
  return (
    <Alert>
      <AlertIcon />
      <AlertTitle>Profile updated</AlertTitle>
      <AlertDescription>Your changes were saved successfully.</AlertDescription>
    </Alert>
  );
}

Default

<Alert>
  <AlertIcon />
  <AlertTitle>Profile updated</AlertTitle>
  <AlertDescription>Your changes were saved successfully.</AlertDescription>
</Alert>

Semantic Variants

<Alert variant="success">...</Alert>
<Alert variant="warning">...</Alert>
<Alert variant="destructive">...</Alert>

Primary, Light, Outline

<Alert variant="heavy-success">...</Alert>
<Alert variant="light-info">...</Alert>
<Alert variant="outline-error">...</Alert>

Without Border

Set outlined={false} to remove border while keeping variant colors.

<Alert variant="light-warning" outlined={false}>
  <AlertIcon>!</AlertIcon>
  <AlertTitle>Maintenance window</AlertTitle>
  <AlertDescription>Scheduled on Sunday, 01:00-03:00 UTC.</AlertDescription>
</Alert>

Custom Icon Content

AlertIcon is a generic slot. You can pass any icon/text node.

<Alert variant="destructive">
  <AlertIcon className="font-semibold">!!</AlertIcon>
  <AlertTitle>Action required</AlertTitle>
  <AlertDescription>
    Verify your billing email before continuing.
  </AlertDescription>
</Alert>

Tips

  • Keep alert copy short and action-oriented.
  • Use AlertTitle for the main message and AlertDescription for supporting context.
  • Prefer light-* variants in dense UIs to reduce visual noise.
  • Reserve destructive or heavy-error for blocking or high-risk feedback.

API Reference

<Alert> Props

PropTypeDefaultDescription
variant"default" | "destructive" | "success" | "warning" | "primary-success" | "primary-warning" | "primary-info" | "primary-error" | "soft-success" | "soft-warning" | "soft-info" | "soft-error" | "heavy-success" | "heavy-warning" | "heavy-info" | "heavy-error" | "light-success" | "light-warning" | "light-info" | "light-error" | "outline-success" | "outline-warning" | "outline-info" | "outline-error""default"Visual style variant
outlinedbooleantrueToggle border rendering
classNamestringCustom class for alert container
childrenReactNodeAlert content

<AlertIcon> Props

PropTypeDescription
classNamestringCustom icon wrapper class
childrenReactNodeIcon/text content

<AlertTitle> and <AlertDescription>

Both accept standard HTML attributes and className for typography/layout overrides.


MIT 2026 © @hoag/ui