Components
Banner
Banners identify official websites of government organizations in the United States. They also help visitors understand whether a website is official and secure.
Passed WCAG 2.1 AA
About the banner component
Note: Banners and identifiers are core components. We recommend using both core components on most sites. Together, they are the most recognizable and standardized design elements of a government site.
You should use the banner to identify your site as an official government site.
The banner explains how to identify an official .gov
or .mil
domain and that these sites have secure HTTPS connections. Using the banner component is the best way to assure visitors that they’re connected to an official site.
Most government sites should use the banner, but some should not use the banner. Do NOT use the banner on non-government domains such as a .com or .org.
If you are unable to update to USWDS 2.8.0 (described on GitHub) or higher but still want to include the new language in your banner, we recommend editing your content to the language outlined in the component preview.
Default banner
This is the default banner. USWDS 3.0.0 through 3.12.0 only provide this version.
Guidance
About
This default banner was the only variant available until USWDS 13.3.0. The primary difference is that the default is more customizable but can add steps when updating USWDS versions.
When to use the default banner
- To identify as an official government site. Most government sites should use the banner, though non-federal government sites will need to change the text to be more accurate.
When to consider something else
- If you don’t use a .gov/.mil domain and HTTPS. The Design System’s banner text identifies
.gov
and.mil
domains and HTTPS as indicators that a website is an official government website. Use this banner only if your site uses both the proper top-level domain (TLD) and HTTPS. - Any time it would be misleading. The banner should be used to reduce confusion. Avoid using the banner on any site meant only for testing or otherwise not meant to be identified as an official government website.
Usability guidance
- Use the provided text without customization. The banner is most effective as an identifier and a learning tool when its message is consistent across government sites. With only a few exceptions (described in our Implementation guidance), sites should use the top-level domain (TLD)-appropriate text provided, unaltered. Use the Spanish version of the banner for Spanish-language websites.
- Use the version appropriate to your website’s top-level domain (TLD). If your project uses a
.mil
top-level domain, use the.mil
banner text. - Show the banner on every page. Use the banner at the top of every page of a site. It can be confusing or misleading if it appears on some pages and not others.
- Avoid distraction. The banner should appear on every page of your site. Choose background colors that fit with your site theme, and avoid color combinations that draw excessive attention to the banner.
- Keep the text up to date. Use the most current version of the banner.
Accessibility guidance
- Use
aria-label
to give the banner a useful name. Our default markup usesaria-label="Official website of the United States government"
oraria-label="Un sitio oficial del Gobierno de Estados Unidos"
to distinguish the bannerheader
from the mainheader
. - The banner’s accordion uses JavaScript to set the
aria-hidden
value of its content area. To ensure your content remains accessible in the event the JavaScript does not load or is disabled, you should not setaria-hidden="true"
onusa-banner__content
.
Using the default banner
- Some
.gov
websites don’t represent the federal level of the U.S. government. These sites should adapt the An official website of the United States government and Official websites use .gov sections to use more accurate language specific to the site. - Some
.mil
websites don’t belong to an official U.S. Department of Defense organization. These sites should adapt the Official websites use .mil section to use more technically accurate language: “A .mil website operates under the approval of the U.S. Department of Defense.” - The banner should directly follow the
skipnav
component. - Set the banner background color with
$theme-banner-background-color
. Banner text color will update automatically.
Note: We recommend loading uswds-init.js
when using banner, header, or modal components to assist in preventing flashes of unstyled content (FOUC) as well as cumulative layout shift (CLS). This small JavaScript file (less than 1 KB minified) helps the browser know if the USWDS JavaScript library is loading properly.
To add uswds-init
to your site, simply copy uswds-init.js
into your site assets from either the uswds-core/src/js
package or the dist/js
directory in the downloadable package. Then, reference the file in the <head>
of your HTML files. Alternatively, you can inline its contents directly into a <script>
tag in your HTML files.
Package
-
Package usage:
@forward "usa-banner";
- Dependencies:
uswds-fonts
,usa-media-block
Banner Web Component
A banner variant that may be easier for some teams to implement and keep up to date.
Guidance
About
USWDS 3.13.0 introduces an HTML Web Component variant of banner.
Both options exist in components/banner
, as well as in dist/components/usa-banner
. We recommend most implementations use the compiled version in dist
at this point, though this version is less customizable.
When to use the banner web component
- Use the Web Component variant of the banner anywhere you would use the default banner. The Web Component variant may be easier to add to your site, but it is also less customizable than the default banner.
When to consider something else
If you need more customizability than the Web Component variant of the banner offers.
Using the banner web component
- Some
.gov
websites don’t represent the federal level of the U.S. government. These sites should adapt the An official website of the United States government and Official websites use .gov sections to use more accurate language specific to the site. - Some
.mil
websites don’t belong to an official U.S. Department of Defense organization. These sites should adapt the Official websites use .mil section to use more technically accurate language: “A .mil website operates under the approval of the U.S. Department of Defense.” - The banner should directly follow the
skipnav
component. - We realize this documentation won’t cover all use cases, build environments, or tooling. If you have questions, you can ask USWDS community members in our GitHub discussions or Slack channel, or contact us directly at uswds@gsa.gov. We’ll be expanding this documentation in the future and your questions and feedback will help us understand what you need to get started with this variant and its implementation.
Web Component Settings
Attributes
Attribute | Description |
---|---|
lang
|
The element's language. Defaults to |
label
|
The custom aria label users can override. |
tld
|
The top level domain for the site. Defaults to |
Slots
Slot | Description |
---|---|
banner-text
|
The text for official government website text. |
banner-action
|
Action text label "Here's how you know." |
domain-heading
|
Heading text for the domain section. |
domain-text
|
Body text for domain section. |
https-heading
|
Heading for HTTPs section. |
https-text
|
Body text for HTTPs section. |
Custom Properties
Custom Property | Description |
---|---|
--theme-banner-text-color
|
Sets banner text color. |
--theme-banner-background-color
|
Sets banner background color. |
--theme-banner-font-family
|
Sets banner font family |
--theme-banner-link-color
|
Sets the default link/button color. |
--theme-banner-link-hover-color
|
Sets the default link/banner hover color. |
--theme-banner-chevron-color
|
Sets the default chevron color. |
Note: As this is the first Web Component shipping in USWDS, we are still working on the best way to document its usage. We want to hear from users about challenges with adding this component to your projects. Please let us know what works, what doesn’t, and what additional documentation might be helpful in this discussion thread.
Guidance
Using the banner component
Banner settings
Variable | Description |
---|---|
$theme-banner-background-color
|
Background color of the banner and its content. |
$theme-banner-font-family
|
The font family of the banner. |
$theme-banner-link-color
|
The color of banner link. Add the link color and the system will generate the hover state. |
$theme-banner-max-width
|
Maximum width of the banner content. |
Banner variants
Variant | Description |
---|---|
|
An HTML Web Component version of Banner. Easier to implement and update but potentially harder to customize. See above for details. |
Accessibility test status
The USWDS team did 14 tests based on WCAG 2.1 AA success criteria.
Total tests |
Passed
|
Passed with exceptions
|
Conditional
|
Failed
|
---|---|---|---|---|
14 | 12 | 0 | 2 | 0 |
Overview of recent accessibility test results:
Learn more on the banner accessibility tests page.
Package
-
Package usage:
@forward "usa-banner";
- Dependencies:
uswds-fonts
,usa-media-block
Latest updates
Meaningful code and guidance updates are listed in the following table:
Date | USWDS version | Affects | Description |
---|---|---|---|
2025-05-23 | 3.13.0 |
|
Added a new HTML Web Component-based variant of the banner. More information: uswds#6460 |
2024-06-07 | N/A |
|
Added WCAG compliance tag and accessibility test status section. More information: uswds-site#2687 |
2023-11-30 | N/A |
|
Breaking Fixed a bug causing component code example ID’s and relevant aria attributes to display incorrectly. Now, example ID’s match what’s found in the USWDS repo and are more succinct. More information: uswds-site#2312 |
2023-11-20 | N/A |
|
Updated the text in the |
2023-11-20 | N/A |
|
Removed |
2023-11-09 | 3.7.0 |
|
Updated the banner component so that it initializes without requiring import of the |
2023-11-09 | 3.7.0 |
|
Optimized the |
2023-09-29 | 3.6.1 |
|
Improved horizontal alignment in |
2023-03-09 | 3.4.0 |
|
Improved display of focus outline on mobile. Now the focus outline is visible all around the banner on mobile devices. More information: uswds#5013 |
2023-03-09 | 3.4.0 |
|
Updated padding settings to accept any valid spacing token. More information: uswds#5076 |
2023-03-09 | 3.4.0 |
|
Removed grid dependency from Banner.
Banner no longer needs the |
2022-10-09 | 3.2.0 |
|
Updated the aria-label in English versions of banner.
When read out on a screen reader, the statement “An official website of the United States government” can sound like “Unofficial website of the United States government”. To minimize confusion, we updated the component’s |
2022-10-09 | 3.2.0 |
|
Added aria-hidden attribute to the flag icon. The flag icon in the banner component is purely decorative and we can safely remove it from the screen reader readout. More information: uswds#4925 |
2022-10-09 | 3.2.0 |
|
Simplified ARIA label in the lock SVG.
We simplified the way we’re using |
2022-08-05 | 3.1.0 |
|
Breaking
Added |
2022-06-17 | 3.0.2 |
|
Updated uswds-init.js to better suppress flashing content.
We updated the |
2022-06-17 | 3.0.2 |
|
Updated flag icon to be high resolution. More information: uswds#4792 |
2022-04-28 | 3.0.0 |
|
Breaking Updated to Sass module syntax and new package structure. More information: uswds#4656 |
2022-04-11 | 2.13.3 |
|
Added support for forced colors mode. All our components now support proper display when users have a forced colors mode set in their operating system. More information: uswds#4610 |
2021-03-02 | N/A |
|
Updated guidance to identify banner as a core component. More information: uswds-site#1136 |
2020-12-17 | 2.10.0 |
|
Introduced uswds-init.js to prevent banner flash.
When added to the |
2020-12-17 | 2.10.0 |
|
Improved the accessibility of decorative images in the banner. We modified the banner to properly mark up SVG files used as decorative images. Now all decorative images are hidden from screen readers, and all SVGs are more resilient to browser bugs. See the banner page for the complete, correct markup, and see the pull request for more context on the changes. More information: uswds#3892 |
2020-07-09 | 2.8.0 |
|
Updated banner copy. Updated the expanded text in the banner to emphasize that trustworthiness is a combination of an official TLD and a secure HTTPS connection. More information: uswds#3524 |
2020-07-09 | 2.8.0 |
|
Added Spanish versions. Included approved Spanish versions of the banner text. More information: uswds#3524 |
2020-07-09 | 2.8.0 |
|
Breaking Updated banner settings. Allowed users to change background color, link color, and link reverse colors. This update requires the use of Autoprefixer. More information: uswds#3531 |
2020-06-17 | 2.7.1 |
|
Added |
2020-05-11 | 2.7.0 |
|
Improved display of the “Here’s how you know” link in the gov banner. Now there’s no distracting change to the length of the underline on hover. More information: uswds#3427 |