Tailwind UI Pattern Registry for humans and agents

banner announcement dismiss localStorage top-bar notification banner dismiss announcement localStorage top-bar persistent announcement banner with close button dismissable site-wide notification bar banner that stays hidden after closing

Dismissable Banner

Fetch pattern JSON: curl https://webspire.de/patterns/banner/dismissable.json

Details

Family
banner
Tier
enhanced
Kind
component
Responsive Dark Mode Tailwind Only Copy & Paste Requires JS
Stable Published
bannerannouncementdismisslocalStoragetop-barnotification

Slots

Name Required Description
message Yes The announcement text — may include an inline link.
close-button Yes X button that triggers dismiss and persists state.

Props

Name Type Default Description
STORAGE_KEY string ws-banner-dismissed localStorage key used to persist the dismissed state.

The banner hides immediately on load if localStorage.getItem(STORAGE_KEY) === '1', preventing any flash. On dismiss, it animates max-height and opacity to zero, then sets display: none. The localStorage write happens at click time — before the animation completes.

Changing the storage key

<script>
(function () {
  const STORAGE_KEY = 'my-app-launch-banner-v2'; // bump version to re-show
  // ...
})();
</script>

Without animation (instant dismiss)

Replace the click handler body with:

banner.style.display = 'none';
localStorage.setItem(STORAGE_KEY, '1');