Announcement Banner
A one-line strip across the top of a site for a launch, a notice or maintenance.
- Category
- Marketing
- Access
- Free with an account
- Source
- 159 lines · one file
- States
- 6 drawn
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 Liro's Announcement Banner for this.
Install it: npx shadcn@latest add @liro/announcement-banner
(the @liro registry is set up in components.json, with LIRO_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 @liro 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.
| Type | Notes | ||
|---|---|---|---|
message | React.ReactNode | Yes | The announcement, a sentence or two. |
action | { label: string; href?: string; onClick?: () => void } | No | A link or button after the message. |
tone | "default" | "accent" | "warning" | No | "default" is quiet, "accent" is inverted, "warning" is amber. Default "default". |
dismissible | boolean | No | Adds a close button. |
onDismiss | () => void | No | Called when closed. |
storageKey | string | No | Remember the dismissal in localStorage under this key. |
hideOnScroll | boolean | No | Tuck it away after the first scroll down. Default false. |
sticky | boolean | No | Sticks to the top while the page scrolls. Default true. |
icon | React.ReactNode | No | A small icon or emoji before the message. |
Dependencies
npm packages
clsxlucide-reacttailwind-mergeLiro foundations, installed alongside it
liro-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