React Announcement Banner
AnnouncementBanner is a React announcement banner: a dismissible top bar on glass with a tone, an optional link and static copy. It stores nothing and reports the dismissal through onDismiss so you can remember it.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/announcement-banner.jsonVersion 2 is out: new blocks and a faster build. Read the notes
AnnouncementBannerdefaultAnnouncementBannerLabels
Remember the dismissal yourself
Controlled with open and onOpenChange; onDismiss fires once when the visitor presses the button, which is where you save it (a cookie, localStorage or an account setting) and pass defaultOpen={false} next time.
Version 2 is out: new blocks and a faster build. Read the notes
import { useState } from "react";
import { AnnouncementBanner } from "@/components/sheenui/blocks/announcement-banner";
// Package build (after the first npm release, or a packed tarball): import { AnnouncementBanner } from "@sheenui/theme";
// Your own storage: the banner only reports the dismissal.
const remember = () => window.localStorage.setItem("banner-v2", "dismissed");
export function Example() {
const [open, setOpen] = useState(true);
return (
<AnnouncementBanner
open={open}
onOpenChange={setOpen}
onDismiss={remember}
link={{ label: "Read the notes", href: "/changelog" }}
>
Version 2 is out: new blocks and a faster build.
</AnnouncementBanner>
);
}Files to copy
6 folders · 8 files · 3 packages
- From
theme/src/ blocks/announcement-banner.tsxcomponents/status-icons/hooks/{use-controllable.ts, use-media-query.ts, use-preferences.ts}motion/{presets.ts, tokens.ts}lib/{cn.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/announcement-banner.jsonRegistry item: announcement-banner. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add clsx motion tailwind-merge
Tones
The words carry the meaning; the tone only lights the edge and picks the icon. Set dismissible={false} for a notice that must stay.
This is a accent announcement.
This is a info announcement.
This is a success announcement.
This is a warning announcement.
This is a danger announcement.
This is a neutral announcement.
import { AnnouncementBanner, type AnnouncementTone } from "@/components/sheenui/blocks/announcement-banner";
// Package build (after the first npm release, or a packed tarball): import { AnnouncementBanner, type AnnouncementTone } from "@sheenui/theme";
const tones: AnnouncementTone[] = ["accent", "info", "success", "warning", "danger", "neutral"];
export function Example() {
return (
<div style={{ display: "grid", gap: 12 }}>
{tones.map((tone) => (
<AnnouncementBanner key={tone} tone={tone} dismissible={tone === "accent"}>
This is a {tone} announcement.
</AnnouncementBanner>
))}
</div>
);
}Props
Keyboard
Accessibility
- A labelled group (labels.region), not a landmark and deliberately not a live region, so it is not read out on every page load. Dismissing moves focus on and announces it politely.
- Tone is never the only signal: the text says it and the icon is aria-hidden. Keep the copy static; a live countdown would be a moving target for assistive tech.
- The dismiss button has an accessible name and a 44 px target. The banner stores nothing, so there is no hidden persistence to explain.
- It slides up by transform and fades on its own surface, faster on the way out. Reduced motion: a short fade.
All exports on this page
AnnouncementBanner— A dismissible announcement bar for the top of a page: one sentence, an optional link and a close button.defaultAnnouncementBannerLabels— The English AnnouncementBannerLabels used when labels is omitted; a partial labels prop is merged over it.
When to use the announcement banner
- Use AnnouncementBanner above the navbar for a release, a maintenance window or a promotion, with one sentence and a link to the details.
- Use onDismiss to save the choice in your own storage (a cookie, localStorage or an account setting) and pass defaultOpen={false} on the next visit, so the component itself never touches storage.
- Use tone to pick the icon and light the edge: accent, info, success, warning, danger or neutral; the wording always says what it means, so colour is never the only signal.
- Skip live countdowns and rotating text inside it; a moving banner is hard to read with assistive technology, and the component is designed for static copy.
- Pair it with HeroSection and Navbar below it, and use dismissible={false} for a notice that must stay visible, such as a legal change.
Frequently asked questions
Related pages
20 blocks pages in all: browse them on All blocks.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .