Alert
An inline status message with icon, optional title, and dismiss button. Uses role="alert" or role="status" based on severity.
Preview
Changes saved
Your profile has been updated.
Upload failed
Max file size is 5 MB.
Your session expires in 5 minutes.
New feature
Dark mode is now available.
Usage
import { Alert } from "anexui";
<Alert variant="info">Your session expires in 5 minutes.</Alert>
Copy codeVariants
<Alert variant="success">Profile updated successfully.</Alert>
<Alert variant="error">Failed to save changes.</Alert>
<Alert variant="warning">Unsaved changes will be lost.</Alert>
<Alert variant="info">A new version is available.</Alert>
Copy codeWith title
<Alert variant="error" title="Payment failed">
Your card was declined. Please update your billing info.
</Alert>
Copy codeDismissible
<Alert variant="warning" onDismiss={() => setVisible(false)}>
This action cannot be undone.
</Alert>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "success" \| "error" \| "warning" \| "info" | "info" | Colour and icon |
| title | string | — | Bold heading above the message |
| onDismiss | () => void | — | Shows a close button; called on click |
All standard HTML <div> attributes are accepted.
Accessibility
role="alert"onerrorvariant — announces immediatelyrole="status"on all other variants — polite announcement- Dismiss button has
aria-label="Dismiss"for screen readers