Banner
One line across the top of a page for news everyone on it should have.
On this page
A banner is one line across the top of a page or a panel, for something everyone on it should know: a release, planned maintenance, an incident. It is a band of the tray tone with a hairline under it, quieter than an alert, which belongs to one task, and longer-lived than a toast, which reports one event.
Banner
<dialog open class="banner banner-dismissible" aria-label="Announcement"> <p class="banner-content"> <span class="banner-title">Atlas 4 is here.</span>Faster builds and a new dashboard. <a class="banner-action" href="#">Read the notes</a> </p> <form method="dialog" class="banner-close"> <button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 6l12 12M18 6 6 18" /> </svg> </button> </form></dialog><div class="p-lg text-sm fg-text-muted">The page continues under the banner.</div>#Dismissing
A banner that can be dismissed is a <dialog open> with banner-dismissible. A non-modal dialog opened by its attribute is part of the page from the first paint, and the button inside a <form method="dialog"> closes it without script. The band then folds away to nothing, where the browser can interpolate to an automatic height; elsewhere it leaves at once.
To remember the dismissal, listen for the dialog's close event and store it; leave the open attribute out when rendering the page next time.
A banner that stays is any element, such as a <div role="region"> with a label.
#Tones
A status tone tints the band and colors its icon. The words stay in ink and say what the hue means.
Tones
<div class="banner banner-info" role="status"> <p class="banner-content"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="12" cy="12" r="9" /> <path d="M12 11v5M12 8h.01" /> </svg>A new version is available. <a class="banner-action" href="#">Reload</a> </p></div><div class="banner banner-success" role="status"> <p class="banner-content"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="12" cy="12" r="9" /> <path d="m8.5 12.5 2.5 2.5 4.5-5.5" /> </svg>All systems are back to normal.</p></div><div class="banner banner-warning" role="status"> <p class="banner-content"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M12 4 3 19h18zM12 10v4M12 17h.01" /> </svg> <span class="banner-title">Scheduled maintenance</span>on Saturday from 02:00 to 04:00 UTC.</p></div><div class="banner banner-danger" role="alert"> <p class="banner-content"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="12" cy="12" r="9" /> <path d="M12 8v5M12 16h.01" /> </svg>Payments are failing for some customers. <a class="banner-action" href="#">Status page</a> </p></div>#Inverse and brand
banner-inverse is a band of ink, for the one announcement of a release. banner-brand wears the brand color, which the system keeps for one moment per view: with a brand banner on the page, no other brand surface belongs on it.
Inverse and brand
<dialog open class="banner banner-dismissible banner-inverse" aria-label="Announcement"> <p class="banner-content"> <span class="banner-title">Atlas 4 is here.</span>Faster builds and a new dashboard. <a class="banner-action" href="#">Read the notes</a> </p> <form method="dialog" class="banner-close"> <button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 6l12 12M18 6 6 18" /> </svg> </button> </form></dialog><dialog open class="banner banner-dismissible banner-brand" aria-label="Offer"> <p class="banner-content"> <span class="banner-title">Two months free</span>on any yearly plan until Friday. <a class="banner-action" href="#">See plans</a> </p> <form method="dialog" class="banner-close"> <button class="btn btn-quiet btn-square btn-sm" aria-label="Dismiss"> <svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M6 6l12 12M18 6 6 18" /> </svg> </button> </form></dialog>#Accessibility
- Give a banner a role that matches its urgency:
role="status"for news that can wait,role="alert"for an incident, a labelledrole="region"or the dialog's own role for an announcement. A banner present at load is not announced; only one added later is. - Write one sentence and at most one link. A banner that wraps to three lines on a phone has become a paragraph; move it into the page.
- The dismiss button has a name. Its target reaches the band's edge.
- Text keeps its contrast on every tone: status tones tint the band by a few percent and leave the words in ink.
#Classes
| Class | Description |
|---|---|
banner | The band: the tray tone with a hairline under it. An icon inside takes the band's tone |
banner-dismissible | On a dialog with open: the band folds away to nothing when the dialog closes. Without open it is not shown. With banner |
banner-info | A faint tint and icon in the info hue. With banner |
banner-success | A faint tint and icon in the success hue. With banner |
banner-warning | A faint tint and icon in the warning hue. With banner |
banner-danger | A faint tint and icon in the danger hue. With banner |
banner-inverse | A band of ink, for the one announcement of a release. With banner |
banner-brand | A band of the brand color; with it on the page, no other brand surface belongs in the view. With banner |
banner-content | The message, centered in the band: an icon, the words and one action, wrapping as a group |
banner-title | The few strong words that carry the news |
banner-action | The one link out, underlined in the band's text color |
banner-close | The form with method="dialog", or the button, that dismisses the banner, at the far end of the band |
#Custom properties
| Property | Default | Description |
|---|---|---|
--banner-tone | var(--color-text-strong) | The icon color, and the hue of a tint |
--banner-color | var(--color-surface-tray) | The band's color |