Alertv1.1.5Ready for Production
Display contextual dismissible feedback messages with semantic variants for informational, success, warning, and error states.
Prefer AI-assisted development?
Catalyst Alert is a compound primitive built from scratch with no upstream dependency. Alert goes with built-in design tokens, CVA variants, and accessibility defaults — giving you a production-ready component with zero configuration.
Installation
npm install @pmi/catalyst-alertimport { AlertRoot, AlertTitle, AlertDescription, AlertDismiss } from "@pmi/catalyst-alert";Variants
Info
The default variant for general informational messages that do not require immediate attention.
Success
This variant is ideal for confirming successful actions or positive outcomes, such as form submissions or completed tasks.
Warning
Cautionary messages that alert users to potential issues or important considerations but are not critical errors.
Danger
Critical messages that indicate errors, failures, or urgent issues requiring immediate attention.
Common Patterns
Patterns using Icon and action Button are already described in the Variants section.
Controlling Width
The Alert primitive does not expose a size variant. Width is controlled by the w-[700px] base class on AlertRoot. Override this with className to fit your layout.
API
AlertRoot
Extends all standard HTML div element props. The container part. Renders the Alert background, border, and layout.
Prop
Type
AlertTitle
Extends all standard HTML div element props. The heading part. Renders a styled title inside the Alert.
Prop
Type
AlertDescription
Extends all standard HTML div element props. The body text part. Renders supporting detail below the title.
Prop
Type
AlertDismiss
Extends all standard HTML div element props. The dismiss control part. Positioned absolutely at the top-right corner of the alert. Renders with tabIndex={0} for keyboard focus.
Prop
Type
Accessibility
Keyboard Interactions
| Key | Action |
|---|---|
Tab | Moves focus to the next focusable child. AlertDismiss receives focus via tabIndex={0}. |
Enter / Space | Activates the focused AlertDismiss control. Ensure both keys perform the same action as selecting the dismiss control with a mouse. |
ARIA
- The primitive does not apply ARIA roles or live-region attributes by default. Add them based on the urgency of the alert
- Use
role="alert"onAlertRootfor important notifications that should interrupt immediately (equivalent toaria-live="assertive")- Avoid using
role="alert"for non-critical updates, as frequent interruptions can disrupt screen reader users
- Avoid using
- Use
aria-live="polite"onAlertRootfor informational updates that can wait for a pause in screen reader output - Use
role="alert" + aria-atomic="true"onAlertRootfor urgent system errors or alerts whose content may change after being announced- Use
aria-atomic="true"when the entire alert message should be re-announced whenever any portion of its content changes
- Use
- Always provide an accessible name using
aria-labelfor AlertDismiss so screen readers announce its purpose- Always provide context on what is being dismissed in your
aria-labelstring. For example: "Dismiss payment error alert", "Dismiss account settings alert"
- Always provide context on what is being dismissed in your
Choosing the Right Component
Use Alert to surface contextual, dismissible feedback tied to a user action or system event — form validation results, save confirmations, permission warnings. Use Alert for inline messaging that appears within the page flow near the relevant content, not as a page-level overlay.
Reach for a different primitive when:
| If you need… | Use instead |
|---|---|
| A page-wide or site-wide announcement that persist across navigation | Banner |
| A transient notification that auto-dismiss after a timeout (e.g., toast messages) | Toast |
| To draw attention to important information without interaction | Callout |