Skip to content
IndexRequest a UIAboutContact

Announcement Banner

A dismissible bar at the top of the page in info, success, warning and promo styles.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Clean website mockup with a slim full-width announcement banner above the header: a pale blue bar with a small info icon, the text New: dark mode is here, a text link Try it, and a close cross on the right, rounded app UI below it in light grey, flat modern style, subtle border, no shadows. Variants: green success, amber warning, and a dark promo banner with a white button. Negative: multiple banners, heavy gradients, popups, text errors, clutter. Reduced motion: static design.

About this pattern

Definition

An announcement banner carries one message that applies to the whole page or site: a launch, a maintenance window, a sale. It sits above the header, stays until dismissed and collapses smoothly so the page below does not jump.

Purpose & UX principles

  • One message, one action, one close button; the text should fit on a single line on desktop.
  • Choose the tone by role: info for news, success for confirmations, warning for risk, promo for offers.
  • Remember dismissal so it does not return on every page.

Interaction states

  • Four style buttons, a dismiss button on the banner and a Show again button.

Motion specification

  • Dismiss collapses the height over 250ms using a grid row transition.
  • Reduced motion: the banner disappears immediately.

Responsive behaviour

  • On narrow screens let the text wrap to two lines and keep the close button reachable.
  • Do not stack more than one banner.

Code

HTML
<div class="bx"><div class="pre" id="pre" role="group" aria-label="Style"><button data-p="0" aria-pressed="true">Info</button><button data-p="1" aria-pressed="false">Success</button><button data-p="2" aria-pressed="false">Warning</button><button data-p="3" aria-pressed="false">Promo</button></div><div class="pg"><div class="wr" id="wr"><div class="in"><div class="bn" id="bn" role="status"><span class="ic" id="ic"></span><span id="tx"></span><a href="#" id="ln">Learn more</a><button type="button" id="cl" aria-label="Dismiss announcement">&times;</button></div></div></div><div class="hd">Product name<span></span></div></div><button class="mini" id="sa" type="button" hidden>Show again</button></div>

Related patterns

Inline Alert Banners

↗
Inline Alert BannersFeedback & Notifications

Toast

↗
ToastFeedback & Notifications

Snackbar

↗
SnackbarFeedback & Notifications