OfferLifetime Pro for $99

Announcement Banner

A message, an optional link and a close button. Closing it is remembered in the browser under a key you choose, so a returning visitor is not shown it again. Three tones: default, accent and warning.

MarketingFree159 lines · one file

The decision inside it

Closing it is remembered per announcement

Give each announcement its own storage key; a new one shows again even to someone who closed the last one, and a blocked storage never breaks the page.

When to use it

Use Announcement Banner for one line across the top of a site: a launch, a notice, planned maintenance. Give each announcement its own storageKey so closing it is remembered. For a message about one action, use a toast.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Layro's Announcement Banner for this.
Install it: npx shadcn@latest add @layro/announcement-banner
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/announcement-banner.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @layro registry with your CLI token: see the Namespaced tab.

Usage

components/launch-banner.tsx
import { AnnouncementBanner } from "@/components/ui/announcement-banner";

export function LaunchBanner() {
  return (
    <AnnouncementBanner
      tone="accent"
      message="Templates marketplace is live."
      action={{ label: "Browse templates", href: "/templates" }}
      dismissible
      storageKey="banner-templates-launch"
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

PropTypeNotes
messagerequiredReact.ReactNodeThe announcement, a sentence or two.
action{ label: string; href?: string; onClick?: () => void }A link or button after the message.
tone"default" | "accent" | "warning""default" is quiet, "accent" is inverted, "warning" is amber. Default "default".
dismissiblebooleanAdds a close button.
onDismiss() => voidCalled when closed.
storageKeystringRemember the dismissal in localStorage under this key.
hideOnScrollbooleanTuck it away after the first scroll down. Default false.
stickybooleanSticks to the top while the page scrolls. Default true.
iconReact.ReactNodeA small icon or emoji before the message.

Dependencies

npm packages

clsxlucide-reacttailwind-merge

Layro foundations, installed alongside it

layro-theme

States

All of them are drawn by the component. None is left for you to design.

  • Default
  • Accent
  • Warning
  • With action
  • Dismissed
  • Hidden on scroll

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances

Lifetime access

Every component, and everything we ship next.

  • All 232 components, source included
  • Every template, and everything released after you buy
  • shadcn CLI or download — React 18/19, Tailwind v4
  • One payment. No subscription.