Signature
Announcement bar
A dismissible strip for news.
Variants
A strip across the top of the page. neutral for notices, primary for a launch, gradient-subtle for marketing moments. Dismiss one: it collapses and the content below glides up.
When to use
- Site-wide news: a launch, a pricing change, an event.
- A planned maintenance window everyone should see before it happens.
Not for: feedback on something the user just did (use a toast), problems inside a form or section (use an alert), anything that must block the page (use a dialog). Show one bar at a time.
Remember the dismissal
storageKey stores the dismissal in localStorage. The server always renders the bar; after hydration a stored dismissal removes it at once, without animation. Use a new key for each announcement. This example is also controlled with open and onOpenChange.
Dismiss it, then reload the page.
API
AnnouncementBar
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | 'neutral' | 'primary' | 'gradient-subtle' | 'neutral' | Surface. |
| open | boolean | — | Controlled visibility. |
| defaultOpen | boolean | true | Initial visibility when uncontrolled. |
| onOpenChange | (open: boolean) => void | — | Called when the bar is dismissed (or hidden from storage). |
| dismissible | boolean | true | Show the × button. |
| dismissLabel | string | 'Dismiss announcement' | Accessible name of the × button. |
| storageKey | string | — | Remember the dismissal in localStorage under this key. |
| icon | ReactNode | — | Leading icon or AnnouncementBarBadge. |
| action | ReactNode | — | Usually an AnnouncementBarLink. |
| aria-label | string | 'Announcement' | Name of the region landmark. |
AnnouncementBarLink
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Render your element (e.g. a Next.js Link) with the link styles and arrow. |
| arrow | boolean | true | Trailing arrow that nudges on hover. |
| ...props | AnchorHTMLAttributes | — | Forwarded to <a>. |
AnnouncementBarBadge is a small pill (“New”, “Beta”) to pass as icon.
Keyboard
| Key | Action |
|---|---|
| Tab | Moves to the link, then the × button. |
| Enter / Space | Activates the focused link or dismisses the bar. |
Accessibility
- A region landmark named by aria-label, so screen-reader users can find or skip it. Give each bar on a page its own name.
- The × is a real button with an accessible name; it has a 44px touch target without making the strip taller.
- No role="alert": an announcement is part of the page, so it does not interrupt.
Motion
- Dismiss: the height collapses (280ms) while the strip fades and lifts 4px with a light blur, so the page glides up instead of jumping.
- Showing it again after load opens it on the smooth spring; the first render never animates.
- The link arrow nudges 2px on hover (fine pointers only).
- Reduced motion: the bar disappears without movement.