Announcement Bar
A dismissible, site-wide bar pinned above the header for launches, promos, maintenance notices, and other messages every visitor should see. It remembers a visitor's dismissal per id in localStorage and renders nothing until mounted, which avoids hydration mismatches and dismissed-banner flashes on load.


shadcn add · no workarounds · theme neutral (none shipped)Installation
Requires @pulld in the registries of your components.json (shadcn adds official directory namespaces automatically).
Usage
import { AnnouncementBar } from "@/components/ui/announcement-bar"<AnnouncementBar id="new-release">New release is live</AnnouncementBar>- Use it for a message the whole site needs to see at the top of the page, such as a product launch, a sale or free-shipping offer, or a beta or early-access note.
- Use it for operational notices that should stay visible, such as scheduled maintenance, an incident or status message, or a plan-expiring or payment-failed warning (set dismissible={false} for these).
- Use it when a dismissal should persist across page loads and visits, and bump version or change id to show the message again after the wording changes.
- Do not use it for transient feedback that disappears on a timer (use a toast) or for blocking confirmations that need a response (use an alert dialog).
Examples
Primary promo with icon and action
A solid accent sale bar with a leading icon and a trailing link. Bumping version re-shows the bar to users who dismissed an earlier version.
import { Tag } from "lucide-react"import { AnnouncementBar } from "@/components/ui/announcement-bar"export function PromoBar() { return ( <AnnouncementBar id="summer-sale" version={2} variant="primary" label="Sale announcement" icon={<Tag className="h-4 w-4" />} action={<a href="/sale" className="underline underline-offset-4">Shop now</a>} > Summer sale: 30% off everything </AnnouncementBar> )}Permanent maintenance notice
A non-dismissible muted bar for a scheduled maintenance window. With dismissible={false} there is no close button and the bar is always shown.
import { AlertTriangle } from "lucide-react"import { AnnouncementBar } from "@/components/ui/announcement-bar"export function MaintenanceNotice() { return ( <AnnouncementBar id="maintenance-sat" dismissible={false} label="Scheduled maintenance" icon={<AlertTriangle className="h-4 w-4" />} > Scheduled maintenance on Saturday 02:00–04:00 UTC. Checkout may be unavailable. </AnnouncementBar> )}Logging dismissals with onDismiss
Calls a handler after the visitor closes the bar so the dismissal can be sent to analytics.
import { AnnouncementBar } from "@/components/ui/announcement-bar"export function LaunchBar() { return ( <AnnouncementBar id="v3-launch" version="2025-06" action={<a href="/changelog" className="underline underline-offset-4">Read more</a>} onDismiss={() => console.log("announcement dismissed: v3-launch")} > Version 3 is out now </AnnouncementBar> )}Old docs version notice
A muted default bar placed in a docs layout to warn readers they are viewing an older version.
import { AnnouncementBar } from "@/components/ui/announcement-bar"export function OldVersionNotice() { return ( <AnnouncementBar id="docs-v2-notice" label="Documentation version notice" action={<a href="/docs/v3" className="font-medium underline underline-offset-4">Go to latest</a>} > You are viewing the documentation for an older version. </AnnouncementBar> )}API reference
Accessibility
- The root element is a div with role="region" and an aria-label (default "Announcement"), so screen reader users can reach it with landmark navigation. Pass a specific label such as "Scheduled maintenance" to make it identifiable.
- The close button is a native button with type="button" and aria-label="Dismiss announcement". Its X icon is aria-hidden.
- The leading icon is wrapped in a span with aria-hidden="true" because the visible text already conveys the message.
- The close button has a visible keyboard focus ring (focus-visible:ring-2), using ring-primary-foreground on the primary variant and ring-ring on the default variant.
- The component renders nothing on the server and until mounted, so no hidden content is read out before the banner is shown. The source sets no aria-live attribute, so the message is not announced automatically when it appears.
- Set dismissible={false} for banners that must stay visible; no close control is rendered in that case.
- If localStorage is unavailable (private mode or blocked storage), the bar still shows and dismissing it only hides it for the current page session.
Docs written by anthropic:claude-haiku-5-5 from the registry source.
Use with Coding Agent
Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.
Use the "Announcement Bar" component (pulld/announcement-bar) from its shadcn registry.1. Install it with: npx shadcn@latest add @pulld/announcement-bar2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: id, version, variant, icon, action, dismissible, label, onDismiss.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { AnnouncementBar } from "@/components/ui/announcement-bar"<AnnouncementBar id="new-release">New release is live</AnnouncementBar>```Files & dependencies
- registry/ui/announcement-bar.tsx