Xzero UI
Pro library

Announcement bar

A top banner that rotates messages, counts down, and collapses smoothly when dismissed.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/announcement-bar
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/announcement-bar

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { AnnouncementBar } from "@/components/xzero/announcement-bar/announcement-bar";

export function SiteBanner() {
  return (
    <AnnouncementBar
      id="fall-sale-2026"
      tone="inverted"
      messages={[
        { id: "sale", message: "Fall sale: 30% off annual plans.", countdown: { to: "2026-10-01T00:00:00Z", label: "Ends in" }, action: { label: "See plans", href: "/pricing" } },
        { id: "launch", message: "Workflows are now in beta.", action: { label: "Read more", href: "/blog/workflows" } },
      ]}
    />
  );
}

API reference

AnnouncementBar

A slim top-of-page bar that rotates messages with a timer ring, supports a call to action and live countdown, and remembers dismissal.

PropTypeDefaultDescription
messages (required)Announcement[]–Messages: { id, message, action?, countdown? }. action is { label, href?, onClick? }; countdown is { to, label? }.
idstring–Remembers dismissal in localStorage under arc-announcement:<id>. Change it to show a new campaign again.
openboolean–Controlled visibility. Stored dismissal is ignored when set.
defaultOpenbooleantrueStarting visibility when uncontrolled.
onOpenChange(open: boolean) => void–Called with false when the visitor dismisses the bar.
indexnumber–Controlled index of the visible message.
defaultIndexnumber0Starting message when uncontrolled.
onIndexChange(index: number) => void–Called when rotation or the arrows change the message.
intervalnumber6000Milliseconds each message stays before the next one.
autoPlaybooleantrueRotates automatically. Off when the visitor prefers reduced motion.
controlsbooleanfalseShows previous, next, and the pause ring when there are several messages. Off by default: only the close button shows and messages still rotate.
dismissiblebooleantrueShows the dismiss button.
tone"neutral" | "inverted""neutral"Muted surface, or foreground-colored bar with background text.
onAction(announcement: Announcement) => void–Called when a message's call to action is pressed, after its own onClick.
onCountdownEnd(announcement: Announcement) => void–Called once when a message's countdown reaches zero.
labelstring"Announcements"Accessible name of the region.
classNamestring–Class on the section.
refRef<HTMLElement>–The section element.

clearAnnouncementDismissal

Forgets a remembered dismissal so the bar with this id shows again.

PropTypeDefaultDescription
id (required)string–The id passed to AnnouncementBar.

Keyboard interactions

KeysAction
TabMoves through the call to action and dismiss button, plus previous, pause, and next when controls is on. Focus inside pauses rotation.
Enter / SpacePresses the focused control.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in messages

Guidance for AI tools

Announcement bar: A top banner that rotates messages, counts down, and collapses smoothly when dismissed. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components