Components
Site alert
A site alert communicates urgent sitewide information.
About the site alert component
When your agency has urgent information to share with the public, it’s essential that it stands out from other content on the site. A site alert prominently displays critical, time-sensitive warnings or directions across every page so that users see it whenever they visit the site. Using the same site alert treatment across agencies helps create a consistent and predictable way for users to find urgent information across all government websites.
Standard informational site alert
Short alert message
Additional context and followup information including a link.
Standard emergency site alert
Emergency alert message
Additional context and followup information including a link.
Site alert with no header
Short alert message. Additional context and followup information including a link.
Site alert with list
Emergency alert message
- The primary emergency message and a link for supporting context.
- Another message, and another link.
- A final emergency message.
Slim site alert
Short alert message. Additional context and followup information including a link.
Site alert with no icon
Guidance
When to use the site alert component
- Critical system notifications. Use a site alert to deliver a static system status update, such as notices about unavailable services or content. Site alerts should appear by default and not in response to an action.
- Messages that should be displayed on every page. A site alert makes critical information obvious and findable on every page.
When to consider something else
- Responding to user actions. Use the alert component for page-level validation messages (like error messages on a form) or to inform a user that a task was completed successfully.
- Validating form input. On most forms, especially longer forms, validation messages should appear inline with error messages at the top of the form.
Usability guidance
- Place prominently. Use a full-width site alert positioned near the top of the page so it’s one of the first things users see.
- Avoid stacking multiple site alerts. If you need to convey more than one message, provide a list of links within a single site alert instead of multiple, stacked alerts.
- Avoid overwhelming use of color. It may be tempting to make heavy use of bright red or orange to draw attention to an emergency-related site alert. However, these colors can produce strong negative emotional reactions such as fear or panic. Positioning the banner at the top of the screen provides enough weight that such strong colors may not be necessary.
Accessibility guidance
- Don’t visually hide alert messages and then make them visible when they are needed. Users of older assistive technologies may still be able to perceive hidden alert messages. Fully remove alert messages when they’re not needed.
- Include a descriptive ARIA label. Add an
aria-label
oraria-labelledby
attribute to the.usa-site-alert
element to ensure that your site alert appears in the landmarks menu. A well-written label can help assistive technology users easily find and understand the top-level information of your site alert. - Add an ARIA role to dynamically-updated site alerts. For important, time-sensitive site alerts that will receive new content mid-session, for example if your site pushes out an updated emergency alert, add an ARIA
role
attribute that will notify users of changes. To do this, choose the appropriaterole
from the ARIA roles table and add it to the.usa-site-alert
element.
Site alert ARIA roles
Attribute | Use Case |
---|---|
role="alert"
|
Important messages that demand the user's immediate attention. Use this role sparingly because it interrupts the user's workflow. |
role="status"
|
Messages that provide advisory information but do not have the same urgency as alerts. |
Reference: WAI-ARIA
Using the site alert component
Site alert settings
Variable | Description |
---|---|
$theme-site-alert-max-width
|
Maximum width of the site alert content. |
Site alert variants
Variant | Description |
---|---|
|
Displays an information site alert. |
|
Displays an emergency site alert. |
|
Display a slimmer version of the site alert. |
|
Display an site alert without an icon. |
Package
-
Package usage:
@forward "usa-site-alert";
- Dependencies:
usa-alert
Latest updates
Meaningful code and guidance updates are listed in the following table:
Date | USWDS version | Affects | Description |
---|---|---|---|
2024-10-04 | 3.9.0 |
|
Breaking
Fixed a bug that caused |
2023-11-09 | 3.7.0 |
|
Removed the component’s top margin. More information: uswds#5550 |
2023-03-09 | 3.4.0 |
|
Updated padding settings to accept any valid spacing token. More information: uswds#5076 |
2022-09-26 | N/A |
|
Added guidance for using ARIA roles and ARIA labels. More information: uswds-site#1774 |
2022-10-19 | 3.2.0 |
|
Updated the alignment of site alert content to visually match banner content. The alert component was also updated. More information: uswds#4922 |
2022-04-28 | 3.0.0 |
|
Breaking Updated to Sass module syntax and new package structure. More information: uswds#4656 |
2021-03-17 | 2.11.1 |
|
Restored missing white icons.
Restored |
2021-03-17 | N/A |
|
Updated and improved guidance for site alert. More information: uswds-site#1180 |
2021-03-17 | 2.11.0 |
|
Provided better support for color icons that adapt to theme settings. Now the color of the alert icon will update automatically to adapt to the alert background, or to the color of the alert text. More information: uswds#4079 |
2021-03-17 | 2.11.0 |
|
Added the |