Skip to content
Marketing block

Dismissible Announcement Bar

The strip above the navbar, with the three things it usually gets wrong fixed: a named region, a live role only when it earns one, and a dismissal that persists.

132 lineslucide-reactAdded 24 Aug 2026Updated 11 Sept 2026
  • announcement
  • banner
  • promo
  • dismissible
  • chrome

What's included

  • components/announcement-bar.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add announcement-bar

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

NewBlocks v2 is out — 134 sections, all free to browse and copy.See what changed

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/announcement-bar.tsx
'use client'

/**
 * <AnnouncementBar> — the dismissible strip above the navbar.
 *
 * Absent from the catalog until now, which is odd for the block most sites
 * ship first: a launch, a sale, a maintenance window, a conference. It is
 * small, and almost everyone gets the same three things wrong.
 *
 * It is a <section> with an accessible name, not a bare div. A visitor
 * using a screen reader lands on the page and hears the announcement before
 * the navigation, so it needs to identify itself as something other than
 * the start of the header.
 *
 * `role="status"` only when `live`, and never by default. A bar that is in
 * the markup at page load is not a status change — announcing it politely
 * on arrival is redundant with reading it in document order. `live` exists
 * for the case that actually warrants it: a bar mounted later, after an
 * incident starts, where the point is that a reader already on the page
 * finds out.
 *
 * Dismissal is not the end of it. A bar that reappears on every navigation
 * is the pattern that makes people install blockers, so `storageKey`
 * persists the dismissal — and because a promo that must not be permanently
 * dismissible exists too (a maintenance window), passing no key gives a
 * bar that dismisses for the session only.
 *
 * Reading localStorage during render would mismatch the server HTML, so the
 * dismissed state resolves in an effect and the bar renders on the server
 * as visible. The cost is a flash for a returning visitor; the alternative
 * is a hydration error on every page.
 */

import * as React from 'react'
import { ArrowRight, X } from 'lucide-react'

export interface AnnouncementBarProps {
  message?: React.ReactNode
  /** Short label, e.g. 'New'. Rendered as a pill before the message. */
  badge?: string
  ctaLabel?: string
  ctaHref?: string
  /** Persist the dismissal under this key. Omit for session-only. */
  storageKey?: string
  /** Announce to assistive tech. Only for a bar that appears after load. */
  live?: boolean
  dismissible?: boolean
  /** Names the region for screen readers and the dismiss button. */
  label?: string
  className?: string
}

export function AnnouncementBar({
  message = 'Blocks v2 is out — 134 sections, all free to browse and copy.',
  badge = 'New',
  ctaLabel = 'See what changed',
  ctaHref = '/changelog',
  storageKey,
  live = false,
  dismissible = true,
  label = 'Announcement',
  className = '',
}: AnnouncementBarProps) {
  const [dismissed, setDismissed] = React.useState(false)

  React.useEffect(() => {
    if (!storageKey) return
    try {
      if (window.localStorage.getItem(storageKey) === 'dismissed') {
        setDismissed(true)
      }
    } catch {
      // Private mode, or storage disabled. A bar that shows is the safe
      // failure; a crash on read is not.
    }
  }, [storageKey])

  const dismiss = () => {
    setDismissed(true)
    if (!storageKey) return
    try {
      window.localStorage.setItem(storageKey, 'dismissed')
    } catch {
      // Dismissed for this session regardless.
    }
  }

  if (dismissed) return null

  return (
    <section
      aria-label={label}
      {...(live ? { role: 'status' } : {})}
      className={`relative border-b border-border/60 bg-primary/10 ${className}`}
    >
      <div className="mx-auto flex max-w-7xl items-center justify-center gap-x-3 gap-y-1 px-4 py-2.5 pe-12 text-sm sm:px-6 sm:pe-14">
        <p className="flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center">
          {badge ? (
            <span className="rounded-full bg-primary px-2 py-0.5 text-xs font-semibold text-primary-foreground">
              {badge}
            </span>
          ) : null}
          <span className="text-foreground/90">{message}</span>
          {ctaLabel ? (
            <a
              href={ctaHref}
              className="inline-flex items-center gap-0.5 font-medium text-primary underline-offset-4 hover:underline"
            >
              {ctaLabel}
              <ArrowRight aria-hidden className="h-3.5 w-3.5 rtl:rotate-180" />
            </a>
          ) : null}
        </p>
      </div>

      {dismissible ? (
        <button
          type="button"
          onClick={dismiss}
          // Named for what it closes, not just "Close" — a page can hold
          // several dismissible things, and "Close" three times over tells
          // a screen-reader user nothing about which is which.
          aria-label={`Dismiss ${label.toLowerCase()}`}
          className="absolute end-2 top-1/2 -translate-y-1/2 rounded-lg p-2 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary sm:end-4"
        >
          <X aria-hidden className="h-4 w-4" />
        </button>
      ) : null}
    </section>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/announcement-bar.tsx and import it where you need the section:

import { AnnouncementBar } from '@/components/announcement-bar'

Customize

6 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
messageReact.ReactNode'Blocks v2 is out — 134 sections, all free to…
badgeShort label, e.g. 'New'. Rendered as a pill before the message.string'New'
ctaLabelstring'See what changed'
ctaHrefstring'/changelog'
storageKeyPersist the dismissal under this key. Omit for session-only.string—
liveAnnounce to assistive tech. Only for a bar that appears after load.booleanfalse
dismissiblebooleantrue
labelNames the region for screen readers and the dismiss button.string'Announcement'
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

announcement-bar.html
<!--
  Dismissible Announcement Bar — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<section aria-label="Announcement" class="relative border-b border-border/60 bg-primary/10 ">
  <div class="mx-auto flex max-w-7xl items-center justify-center gap-x-3 gap-y-1 px-4 py-2.5 pe-12 text-sm sm:px-6 sm:pe-14">
    <p class="flex flex-wrap items-center justify-center gap-x-2 gap-y-1 text-center">
      <span class="rounded-full bg-primary px-2 py-0.5 text-xs font-semibold text-primary-foreground">New</span>
      <span class="text-foreground/90">Blocks v2 is out — 134 sections, all free to browse and copy.</span>
      <a href="/changelog" class="inline-flex items-center gap-0.5 font-medium text-primary underline-offset-4 hover:underline">See what changed<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-arrow-right h-3.5 w-3.5 rtl:rotate-180" aria-hidden="true"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg></a>
    </p>
  </div>
  <button type="button" aria-label="Dismiss announcement" class="absolute end-2 top-1/2 -translate-y-1/2 rounded-lg p-2 text-muted-foreground transition-colors hover:bg-background/60 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary sm:end-4">
    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x h-4 w-4" aria-hidden="true">
      <path d="M18 6 6 18"></path>
      <path d="m6 6 12 12"></path>
    </svg>
  </button>
</section>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

4 more blocks in Navigation

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Navigation

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Navigation blocks

View category
Open the full page for this block

Signed-in Application Bar

The bar above an app rather than a site: workspace and environment named in the open, a bell that counts in words, and an impersonation strip that cannot be dismissed.

Navigation318 lines1 dep