Government Banner
A government banner is an <aside> placed at the very top of a page that identifies the website as belonging to a government, with an expandable details panel typically explaining the .gov domain and HTTPS lock icon.
Use it on government and public-sector sites that need to clearly signal official status to visitors and provide trust context on demand.
Implementation Notes
- Uses an
<aside>element so it is announced as a complementary landmark labelprop is required — setsaria-labelon the<aside>headerTextprop is required — the always-visible top headlineexpandLabelprop is required — text on the toggle buttonexpandedprop controls whether the details panel is visible- The toggle
<button>hasaria-expandedandaria-controlslinking to the panel - The panel has a stable id and
hiddenattribute when collapsed onToggle/ontogglecallback fires when the user activates the toggle- Children render inside the details panel (typically two columns explaining .gov and HTTPS)
Props
label: string (required) -- aria-label for the bannerheaderText: string (required) -- the always-visible top headlineexpanded: boolean (default: false) -- whether the details panel is openexpandLabel: string (required) -- toggle button textonToggle/ontoggle: callback (optional) -- toggle handlerchildren: slot -- details panel content...restProps: any additional HTML attributes
Usage
Default collapsed banner:
<GovernmentBanner
label="Official government website"
headerText="An official website of the United States government"
expandLabel="Here's how you know"
>
<div>
<h3>Official websites use .gov</h3>
<p>A .gov website belongs to an official government organization.</p>
</div>
<div>
<h3>Secure .gov websites use HTTPS</h3>
<p>A lock icon means you have securely connected to the .gov website.</p>
</div>
</GovernmentBanner>
Keyboard Interactions
- Tab: focus the toggle button
- Enter: activate the toggle button
- Space: activate the toggle button
- (All handled natively by the
<button>element)
ARIA
<aside>provides the implicitcomplementarylandmark rolearia-labelon the<aside>names the landmark- Toggle button has
aria-expandedreflecting the panel state - Toggle button has
aria-controlsreferencing the panel id - Panel uses the
hiddenattribute when collapsed
When to Use
- Use at the top of every page on a government website to identify it as official.
- Use to provide on-demand explanations of government domains and HTTPS.
When Not to Use
- Do not use on non-government sites.
- Do not use as a generic alert or notification — use
BannerorAlertinstead.
Headless
Renders the structural skeleton — <aside> with <header>, toggle <button>, and panel <div> — wired with the correct ARIA. Visual treatment, icons, columns, and animation are entirely the consumer's responsibility.
Styles
Consumer CSS targets the government-banner class plus the inner government-banner-header, government-banner-toggle, and government-banner-details classes for fine-grained control.
Testing
- Verify the component renders an
<aside>element with classgovernment-banner - Verify
aria-labelis present and equals thelabelprop - Verify the headline text equals
headerText - Verify the toggle button exists with the
expandLabeltext - Verify
aria-expandedreflects theexpandedprop - Verify
aria-controlsreferences the panel id - Verify the panel is hidden when
expandedis false - Verify the panel is visible when
expandedis true - Verify the toggle handler fires on click
Advice
- Designers: Keep the headline short and treat the toggle as a passive disclosure. Use a flag or shield glyph next to the headline for fast recognition.
- Developers: Generate a stable id for the panel (use
useIdin React,crypto.randomUUID()server-side, or a deterministic helper). Always wire the toggle handler to flipexpanded.
Related components
announcement-banner— a banner highlighting important messages for all usersbanner— a prominent message bar across the top of a pagebanner-box— a banner box that is inside a banner component, using flexbox horizontalmedical-banner— a prominent message bar across the top of a page, with medical informationmedical-banner-box— a medical banner box that is inside a medical-banner component, using flexbox horizontal, with medical informationmedical-banner-box-for-advice— a medical record banner box for advice information e.g. contacts, contexts, plans, etc.
References
- US Web Design System Banner: https://designsystem.digital.gov/components/banner/
- WAI-ARIA Disclosure Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/
- WCAG 4.1.2 Name, Role, Value: https://www.w3.org/WAI/WCAG22/Understanding/name-role-value