Installation
Usage
Props
Sets the visual style and semantic meaning of the alert. Each variant uses appropriate colors and icons:
neutral: Informational messageswarning: Cautionary messages requiring attentionerror: Critical errors or problems
Content to display inside the alert. Can include text, links, and other components.
Callback function when the dismiss button is clicked. When provided, adds a close button to the alert.
ARIA role for the alert. Defaults to:
statusfor neutral alertsalertfor warning and error alerts
Accessible label for the dismiss button. Only used when
onDismiss is provided.Accessible label for the error icon in error variant alerts.
Accessible label for the info icon in neutral variant alerts.
Accessible label for the warning icon in warning variant alerts.
Overrides the default element name for customization with the Customization Provider.
Examples
Neutral Alert
Warning Alert
Error Alert
Dismissible Alert
Alert with Links
Accessibility
- Alerts use appropriate ARIA roles (
statusfor neutral,alertfor warning/error) to announce content to screen readers - Error and warning icons include descriptive titles for screen readers
- The dismiss button includes a screen reader label
- Color is not the only indicator of alert type - icons provide additional context
- Sufficient color contrast is maintained for all variants
Best Practices
- Use alerts sparingly - too many alerts can overwhelm users
- Place alerts near the top of the page or relevant section
- Keep alert messages concise and actionable
- Use the appropriate variant to match the severity of the message
- Include clear next steps or actions when applicable
- Only make alerts dismissible if they’re not critical
- Don’t use alerts for success messages after form submissions - use Toast instead
- Avoid stacking multiple alerts - combine related messages when possible