Announcement bar
One line at the very top of a website for news: a launch, a sale, a new version. It goes above the navbar and scrolls away with the page. A close button hides it, and with data-momo-dismiss it stays hidden on later visits.
Announcement bar
New Momo 1.0 is out, with a site sidebar and mega menus. Read the post
Spring sale: 30% off every plan until Friday.
Get the dealHeads up: the dashboard will be down for upkeep on Sunday, 2:00 to 3:00. Status page
We're hiring designers and developers. See open roles
<div class="stack gap-3">
<div class="announce">
<p><span class="badge badge-yellow">New</span> Momo 1.0 is out, with a site sidebar and mega menus. <a href="#">Read the post</a></p>
<button class="announce-close" type="button" aria-label="Dismiss"><i class="mi mi-x" aria-hidden="true"></i></button>
</div>
<div class="announce announce-yellow">
<p><i class="mi mi-tag" aria-hidden="true"></i> Spring sale: 30% off every plan until Friday.</p>
<a class="btn btn-ink" href="#">Get the deal</a>
<button class="announce-close" type="button" aria-label="Dismiss"><i class="mi mi-x" aria-hidden="true"></i></button>
</div>
<div class="announce announce-violet-soft announce-start">
<p><b>Heads up:</b> the dashboard will be down for upkeep on Sunday, 2:00 to 3:00. <a href="#">Status page</a></p>
<button class="announce-close" type="button" aria-label="Dismiss"><i class="mi mi-x" aria-hidden="true"></i></button>
</div>
<div class="announce announce-surface">
<p>We're hiring designers and developers. <a href="#">See open roles <i class="mi mi-arrow-right rtl-flip" aria-hidden="true"></i></a></p>
</div>
</div>Press × to see it go. Leave the close button out for a bar that always shows.
Remember it was closed
Give the bar a data-momo-dismiss name. Once a reader closes it, Momo remembers that in their browser and keeps it hidden on every page. Use a new name for the next announcement so it shows again.
Close me, then reload the page: I stay closed.
<div class="announce announce-green" data-momo-dismiss="docs-demo-1">
<p><i class="mi mi-sparkles" aria-hidden="true"></i> Close me, then reload the page: I stay closed.</p>
<button class="announce-close" type="button" aria-label="Dismiss"><i class="mi mi-x" aria-hidden="true"></i></button>
</div>
<button class="btn btn-sm mt-3" type="button" onclick="try{localStorage.removeItem('momo-dismiss:docs-demo-1')}catch(e){};document.querySelector('[data-momo-dismiss="docs-demo-1"]').hidden=false">Bring it back</button>Closing a bar sends a momo:dismiss event, in case you want to count it.
On a page
<body>
<div class="announce" data-momo-dismiss="v1-launch">…</div>
<header class="navbar navbar-sticky">…</header>
…
The docs site example has one above its sticky navbar.
Classes
| Class | Does |
|---|---|
.announce | The bar: dark by default, text in the middle (at the start on phones) |
.announce-close | The × button at the end |
.announce-start | Text at the start |
.announce-brand / -surface / -paper | Brand color / white / page color (with a line under it) |
.announce-<color> / .announce-<color>-soft | Any Momo color, full or soft |
data-momo-dismiss="name" | Stays hidden once closed (saved in this browser) |
Accessibility
- The close button needs a name:
aria-label="Dismiss". - Keep it to one short sentence and one link; it is read first on every page.
- For something urgent the reader must act on, use an alert in the page instead.