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.
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
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.
| Prop | Type | Notes |
|---|---|---|
messagerequired | React.ReactNode | The 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". |
dismissible | boolean | Adds a close button. |
onDismiss | () => void | Called when closed. |
storageKey | string | Remember the dismissal in localStorage under this key. |
hideOnScroll | boolean | Tuck it away after the first scroll down. Default false. |
sticky | boolean | Sticks to the top while the page scrolls. Default true. |
icon | React.ReactNode | A small icon or emoji before the message. |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLayro foundations, installed alongside it
layro-themeStates
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.