# Banner: site-wide announcements in pure CSS

> iVOLT banner: a full-width announcement strip for launches, maintenance and trials, with an action, a dismiss button, five tones and a sticky variant. CSS only.

Source: https://ivolt.intervolutions.com/components/banner · iVOLT 1.1.2 · English

A full-width strip across the top of a page or a section: one line of news, an optional action and an optional dismiss button. Where an [alert](https://ivolt.intervolutions.com/components/alert) talks about the content next to it (“this form has two errors”), a banner talks about the whole site (“maintenance on Sunday”, “version 1.1 is out”).

**CSS:** `css/components/banner.css` (in `ivolt.css`). **JS:** none. New in 1.1.

Couldn't load the demo. [Open alone](https://ivolt.intervolutions.com/stage/banner/basic.html?id=fx-banner-basic)

```html
<div class="iv-stack iv-u-gap-4">
  <div class="iv-banner iv-banner--brand" role="region" aria-label="Announcement">
    <p class="iv-banner__text"><strong>iVOLT 1.1 “Spark”</strong> — one variable repaints the whole system.</p>
    <a class="iv-banner__action" href="#banner-note">What changed</a>
  </div>

  <div class="iv-banner" role="region" aria-label="Notice">
    <span class="iv-banner__icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><path d="M12 8v5M12 16h.01"/></svg></span>
    <p class="iv-banner__text">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC (sample notice).</p>
    <button class="iv-banner__close" type="button" aria-label="Dismiss"></button>
  </div>

  <div class="iv-banner iv-banner--warning" role="region" aria-label="Warning">
    <p class="iv-banner__text">Your trial ends in 3 days (sample data).</p>
    <a class="iv-banner__action" href="#banner-note">Choose a plan</a>
  </div>

  <div class="iv-banner iv-banner--success" role="region" aria-label="Status">
    <p class="iv-banner__text">All systems operational (sample status).</p>
  </div>

  <p class="iv-u-m-0 iv-u-text-sm iv-u-text-muted" id="banner-note">The links lead back to this note and the dismiss button does nothing here: closing is the page's, a button that sets <code>hidden</code> on the banner.</p>
</div>
```

## When to use it

Use a banner for one message that matters to everyone on the page, for a limited time: a launch, a planned outage, the end of a trial, a cookie-free notice that your analytics changed. Keep it to one sentence and at most one action; if it needs a paragraph, link to the page that has it. Show at most one banner at a time — two stacked strips read as an error state.

A banner is not a [toast](https://ivolt.intervolutions.com/components/toast): it does not appear by itself after an action and it does not time out. It is part of the page from the first paint, which also means it should not push the content down after the page has loaded.

## Tones and variants

- No tone: a quiet raised surface with a brand hairline, for neutral notices.
- `iv-banner--info`, `--success`, `--warning`, `--danger`: a 9 % tint of the tone over the raised surface, with the text colour of the theme (so the contrast is the text contrast, not the tone's).
- `iv-banner--brand`: the strip filled with the primary and its ink — the launch banner. It follows a one-colour theme.
- `iv-banner--sticky`: stays at the top of its scroll container while the page moves.

Parts: `__icon` at the start, `__text` for the sentence, `__action` for a link that reads as a link with an arrow stepping forward under the pointer, and `__close` at the end. An empty close button draws its own cross.

## Accessibility

- The banner is a landmark: `role="region"` with an `aria-label` such as “Announcement”, so it can be found and skipped. Do not make it a live region; it was there when the page loaded and should not interrupt.
- The close button needs a name (`aria-label="Dismiss"`). Dismissing is the page's job: a click handler that sets `hidden` on the banner, which the stylesheet honours. If the choice should persist, store it yourself; the framework keeps no state.
- After dismissing, move focus to the start of the main content, not to the top of the document.
- The tone is never the message: start the sentence with the word that matters (“Scheduled maintenance…”).

## Customising

```
.promo {
  --iv-banner-tone: #7c3aed;
  --iv-banner-bg: color-mix(in oklab, var(--iv-banner-tone) 12%, var(--iv-color-surface-raised));
  --iv-banner-fg: var(--iv-color-text);
}
```

Locals: `--iv-banner-tone` (the hairline, the icon and the action), `--iv-banner-bg` and `--iv-banner-fg`. Check the contrast of your own pair; the shipped tones are measured in both themes.

## Common mistakes

- Using a banner for an error in one form field. That is an alert or an inline message.
- Injecting it after load, which moves everything the reader was about to click.
- A dismiss button that hides the banner but leaves focus on a removed element.
- Two or three banners at once, all brand-filled.

## Class index

Every class of the family. The full list per stylesheet lives in the [reference](https://ivolt.intervolutions.com/reference).

| Class | What it does |
| --- | --- |
| `iv-banner` | The strip, a labelled region. |
| `iv-banner__icon` | Decorative icon at the start. |
| `iv-banner__text` | The sentence. |
| `iv-banner__action` | A link with an arrow. |
| `iv-banner__close` | Dismiss button; empty, it draws a cross. |
| `iv-banner--info` · `--success` · `--warning` · `--danger` | Tinted tones. |
| `iv-banner--brand` | Filled with the primary. |
| `iv-banner--sticky` | Sticks to the top of its scroll container. |
