Alert
Alerts communicate important status messages and actions directly within a page.
Component variations
Color Variants
Contains: Primary, Success, Error, Warning, Info, Neutral. Primary is default
Primary Alert
This is a primary alert message
Success Alert
This is a success alert message
Error Alert
This is an error alert message
Warning Alert
This is a warning alert message
Info Alert
This is an info alert message
Neutral Alert
This is a neutral alert message
With Action Button
Alert with an action button
Alert with Action
This alert has an action button you can interact with
This alert has an action button displayed inline
Without Close Button
Alert without a close button
No Close Button
This alert does not have a close button
Minimal Alert
Alert with only title, no action or close button
Minimal Alert
Simple alert message
Custom Icon
Alert with a custom icon instead of default color-based icons
Custom Icon Alert
This alert uses a custom icon provided via the icon input
Usage Guidelines
Import
Import the alert component in your module or component:
import-alert.ts
Copy code
Basic Implementation
Here is a basic example of using the alert component:
alert-example.html
Copy code
Implementation with all available APIs
Here is an example of using the alert component with all available APIs:
alert-example.html
Copy code
API Reference
Inputs
Property | Type | Default | Required | Description |
|---|---|---|---|---|
string | - | No | The title text displayed in the alert (optional) | |
string | - | Yes | The description or content text displayed in the alert (required) | |
'primary' | 'success' | 'error' | 'warning' | 'info' | 'neutral' | 'primary' | No | The color variant of the alert | |
boolean | true | No | Whether to show the action button | |
boolean | true | No | Whether to show the close button | |
string | 'Alert Action' | No | The text label for the action button | |
boolean | false | No | Display action button inline with text container on the same line | |
string | - | No | Custom icon name. If not provided, defaults to color-based icons |
Outputs
Event | Type | Description |
|---|---|---|
() => void | Callback function called when the close button is clicked | |
() => void | Callback function called when the action button is clicked |
Best Practices
When to Use
- Use Alert when this pattern clearly supports the user task.
- Use it to keep similar interactions consistent across the product.
When Not to Use
- Avoid using Alert when a simpler component communicates the same intent.
- Avoid using it when the pattern introduces unnecessary interaction steps.
Design Guidelines
- Use appropriate color variants to convey the message type (error, success, etc.)
- Keep titles and descriptions concise and actionable
- Use action buttons for alerts that require user interaction
- Provide a close button for dismissible alerts
- Place alerts prominently where users will see them
- Use semantic colors: success for positive outcomes, error for failures, warning for caution, and info for informational messages
- Keep labels, helper text, and actions concise and easy to scan.
- Use VD variants and states consistently for predictable behavior.
- Ensure keyboard access and clear focus order for accessibility.
Component playground
Title for the alert goes here
Nothing more exciting happening here in terms of content, but just filling up the space to make it look, at least at first glance, a bit more representative of how this would look in a real-world application.
alert-usage.html
Copy code