Skip to content

Announcement Bar

Free

A bar across the top of a site for news, offers, and outages. Visitors can close it, and it can count down or rotate several messages.

  • Base UI
  • Motion
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Put a title, an action link, and a close button in the bar, so people read the news and can hide it.

launch-bar.tsx

AnnouncementBar

<div>
PropTypeDefaultDescription
aria-labelstring—Defines a string value that labels the current element. The name of the region for screen readers. Default "Announcement". Translate it.
noncestring—The CSP nonce of the page, for the inline script that hides a stored dismiss before the first paint (dismissKey). Pass it when your Content Security Policy allows scripts by nonce, as the nonce of next-themes.
align"center""start""center"
size"default""lg""sm""default"
stickybooleanfalse
variant"default""destructive""info""inverse""muted""success""warning""default"
refRef<HTMLElement>—The region element (<section>).
dismissKeystring—Remembers a dismiss in localStorage under this key, so the bar stays closed on the next visit and in other tabs. Use a new key for a new message ("launch-2026-11"). A controlled bar (open) does not read it: the page decides.
defaultOpenbooleantrueWhether the bar shows at first.
onOpenChange—Called when the bar opens or closes (false after a dismiss).
classNamestring—Classes for the bar, the part that you see.
labels—The words of the parts (ANNOUNCEMENT_BAR_LABELS). Translate them. Keep the object stable.
From Base UICollapsible.RootBase UI docs
openboolean—Whether the collapsible panel is currently open. To render an uncontrolled collapsible, use the defaultOpen prop instead.
style—Style applied to the element, or a function that returns a style object based on the component's state.
...props<div> attributes—Every other attribute goes to the <div>.

AnnouncementBarBadge

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

AnnouncementBarTitle

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

AnnouncementBarDescription

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.

AnnouncementBarAction

<a>
PropTypeDefaultDescription
arrowbooleantrueShow the arrow after the text. It moves 2px on hover and points the other way in RTL.
stretchedbooleanfalseMake the whole bar the link (a ::after over the bar). Use it when the action is the only link; the close button stays on top.
From Base UIUseRenderBase UI docs
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
...props<a> attributes—Every other attribute goes to the <a>, with a ref.

AnnouncementBarClose

<button>
PropTypeDefaultDescription
labelstring"Dismiss announcement"The name of the button for screen readers. Translate it.
...props<button> attributes—Every other attribute goes to the <button>, with a ref.

AnnouncementBarCountdown

<time>
PropTypeDefaultDescription
toRequiredstring | number | Date—The end: a Date, a time in ms, or a date string ("2026-11-30T23:59:00Z").
localeLocalesArgument—The language of the units ("2d 04h", "2j 04h") and of the default label. The browser language by default, which can differ from the page: pass the page language.
labeldefaultCountdownLabelThe name for screen readers, from the end date. Translate it.
onComplete—Called once when the time is up (also when the end is already past).
dismissOnCompletebooleanfalseClose the bar when the time is up (and remember it with dismissKey).
...props<time> attributes—Every other attribute goes to the <time>, with a ref.

AnnouncementBarRotator

<section>
PropTypeDefaultDescription
intervalnumber5000Time on each message in ms. 0 turns the rotation off.
indexnumber—The message that shows (controlled). A turn or a button press calls onIndexChange.
defaultIndexnumber0The message that shows first (uncontrolled).
onIndexChange—Called when another message shows.
controlsbooleantrueShow the previous and next buttons.
labelstring"Announcements"The names for screen readers. Translate them.
slideLabeldefaultSlideLabel
...props<section> attributes—Every other attribute goes to the <section>, with a ref.

AnnouncementBarItem

<div>
PropTypeDefaultDescription
...props<div> attributes—Every other attribute goes to the <div>, with a ref.
  • Put it above the site header, so it shows on every page.
  • Set dismissKey to keep a closed bar closed after a reload and in other tabs.
  • Use a status variant (info, success, warning, destructive) for an incident or a fix.
  • For a small link above a hero headline, use an Announcement.
  • For a message about one part of a page, use an Alert.
TabMoves to the action, the rotator buttons, and the close button.
EnterOpens the action link, or closes the bar from the close button.
Close
panel · the bar height closes in 260ms, so the page slides up
Rotator
fade · the old message fades out in 100ms, then the new one fades in over 150ms
  1. AddedAnnouncement Bar.
Open the release