Notification
Notifications display to inform the user of changing states on a website or application. Notifications may also be used to highlight notable information.
There are two rules of using notifications.
- Add contextual information about the notification (e.g. success, warning, error, info)
- Use
role="status"
andaria-live="polite"
to inform users of screen readers.
To add visual appeal, you can combine the Notification
component with Astro Icon;
Accessibility features
- Use of color to identify the type of notification (e.g. success, warning, error, info)
- In addition to color, provide contextual feedback by using the notification type as the title
- Identify content for users of screen readers by using
role="status"
andaria-live="polite"
Usage
Accessible Astro exports one notifications-related components:
Notification
: The component which displays content identified by color and title with the given type
Props
Notification
Props
type
- Description: The type of notification to display
- Type:
string
- Accepted values:
"default" | "error" | "info" | "success" | "warning"
- Default:
"default"
role
- Description: The role of the notification
- Type:
string
- Accepted values:
"none" | "alert" | "log" | "marquee" | "region" | "timer"
- Default:
"none"
ariaLive
- Description: The value of the
aria-live
attribute - Type:
string
- Accepted values:
"off" | "polite" | "assertive"
- Default:
"off"
- Description: The value of the
Example
Info: This is the second notification using astro-icon
from the following example.
Style customizations
Customize styles by:
- setting individual properties with a
:global(body .{class)
selector (see Anatomy for class name reference) - setting a global style tag to define styles
Anatomy
Class name | Description |
---|---|
.notification | The container for the notification |
.type-${thisType} | The container for the notification of type thisType . May be info , success , warning , or error . |