Dismissible announcement bar
A slim bar at the top of the page with a message, a link and a close button; once closed, it stays hidden for the period you choose.
- Tailwind
- React
- CSS
- WordPress
Description
To announce a promotion, holidays or an exceptional closure without bothering visitors who have already read it. The dismissal is stored in the browser (localStorage) under a message id: publish a new announcement with another id and it shows again for everyone. The data-bafm-days attribute sets how long the bar stays hidden (30 days in the example, 0 for ever) and data-bafm-until an end date after which it disappears on its own. An optional “Show the announcement again” button reopens it, and closing it also applies to the other open tabs. The script goes right after the bar, so an announcement that was already closed never flashes on load; if the browser blocks storage, the dismissal lasts for the current page. Accessibility: a region named “Annonce”, a 44 px close button with an explicit name, focus sent to the main content after closing and back to the bar when it is shown again, visible focus, AA contrast in light and dark mode, non-breaking space before colons. Without JavaScript the bar stays readable and the useless close button is hidden. The text wraps on mobile from 360 px. The React version also exports an AnnouncementRestore component and keeps the bar hidden during hydration. Example: the year-end holidays of a cabinetmaking workshop.
Code
Loading the code…
The code of this component in
Archive contents
bandeau-annonce-fermable-memorise-html-tailwind.zip3 files · 6 Ko
- index.html7 Ko
- README.md5 Ko
- LICENSE.md1 Ko
Tags
Updated on December 2, 2026.
Reviews
No reviews yet.
In the same spirit

A sticky sidebar table of contents for blog posts: it highlights the section being read, shows the reading time left and folds into a list under the title on mobile.
- Tailwind
- React
- CSS
- WordPress

A column of dots on the side of the page that follows the section being read and lets visitors jump to it, with a label on hover and focus.
- Tailwind
- React
- CSS
- WordPress

Step indicator
FreeAn order step indicator: finished steps clickable to go back, the current step announced, upcoming steps locked.
- Tailwind
- React
- CSS
- WordPress

Tooltips in four positions that open on hover, tap and keyboard focus, and close with Escape, as WCAG requires.
- Tailwind
- React
- CSS
- WordPress