Announcement bar
A slim, optionally dismissible bar above the navbar for one announcement.
Preview
The link's arrow nudges twice after the page loads, then stays still. With reduced motion turned on, it renders the plain layout.
New: pricing tables and feature grids.See what's new
New: pricing tables and feature grids.See what's new
Installation
Run this in a project that already uses shadcn/ui. It adds the component and anything it needs; the motion version also adds the plain one and the motion package.
Usage
import { AnnouncementBar } from "@/components/custom/announcement-bar";
<AnnouncementBar
message="New: pricing tables and feature grids."
link={{ label: "See what's new", href: "/changelog" }}
dismissible
/>import { AnnouncementBarMotion } from "@/components/custom/announcement-bar/announcement-bar-motion";
<AnnouncementBarMotion message="New: pricing tables." link={{ label: "See what's new", href: "/changelog" }} />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| message* (required) | string | – | One short line. |
| link | { label; href } | – | Optional link after the message. |
| dismissible | boolean | false | Adds a close button; dismissal lasts for the page view. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute goes to the root element. |
| Prop | Type | Default | Description |
|---|---|---|---|
| message* (required) | string | – | One short line. |
| link | { label; href } | – | Optional link after the message. |
| dismissible | boolean | false | Adds a close button; dismissal lasts for the page view. |
| ...props | React.ComponentProps<"div"> | – | Any other div attribute goes to the root element. |
Accessibility
- The close button is labelled “Dismiss announcement”.
- The motion version follows the visitor's reduced-motion setting and never hides content before it animates.