---
title: "Announcement Bar"
description: "A bar across the top of a site for news, offers, and outages. Visitors can close it, and it can count down or rotate several messages."
url: https://gelatinui.com/components/announcement-bar
markdown_url: https://gelatinui.com/components/announcement-bar.md
access: free
install: "npx shadcn@latest add @gelatin-ui/announcement-bar"
registry_item: https://gelatinui.com/r/announcement-bar.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Announcement Bar

> A bar across the top of a site for news, offers, and outages. Visitors can close it, and it can count down or rotate several messages.

Page: https://gelatinui.com/components/announcement-bar

## When to use it

Best for: One message across the top of a site that a visitor can close, with a link, a countdown, or a rotator.

- Put it above the site header, so it shows on every page.
- Set `dismissKey` to keep a closed bar closed after a reload and in other tabs.
- Use a status `variant` (`info`, `success`, `warning`, `destructive`) for an incident or a fix.

## When not to use it

- For a small link above a hero headline, use an [Announcement](https://gelatinui.com/components/announcement.md).
- For a message about one part of a page, use an [Alert](https://gelatinui.com/components/alert.md).

## Notes for agents

- Compose the parts: an icon, `AnnouncementBarBadge`, `AnnouncementBarTitle`, `AnnouncementBarDescription`, `AnnouncementBarAction`, and `AnnouncementBarClose`.
- `AnnouncementBarCountdown` takes `to`; `dismissOnComplete` closes the bar when the time is up.
- `AnnouncementBarRotator` holds `AnnouncementBarItem` children and turns every 5s. It holds on hover and on focus.
- `stretched` on the action makes the whole bar the link.
- It is a `<section>` with the name Announcement. Change it with `aria-label`.

## Anatomy

```text
AnnouncementBar
├─ AnnouncementBarBadge (0..n)
├─ AnnouncementBarTitle (0..n)
├─ AnnouncementBarDescription (0..n)
├─ AnnouncementBarAction (0..n)
├─ AnnouncementBarClose (0..n)
├─ AnnouncementBarCountdown (0..n)
├─ AnnouncementBarRotator (0..n)
└─ AnnouncementBarItem (0..n)
```

## API reference

### AnnouncementBar

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `aria-label` | `string` |  | Defines a string value that labels the current element. The name of the region for screen readers. Default "Announcement". Translate it. |
| `nonce` | `string` |  | The CSP nonce of the page, for the inline script that hides a stored dismiss before the first paint (`dismissKey`). Pass it when your Content Security Policy allows scripts by nonce, as the `nonce` of next-themes. |
| `align` | `"center" \| "start"` | "center" |  |
| `size` | `"default" \| "lg" \| "sm"` | "default" |  |
| `sticky` | `boolean` | false |  |
| `variant` | `"default" \| "destructive" \| "info" \| "inverse" \| "muted" \| "success" \| "warning"` | "default" |  |
| `ref` | `Ref<HTMLElement>` |  | The region element (`<section>`). |
| `dismissKey` | `string` |  | Remembers a dismiss in `localStorage` under this key, so the bar stays closed on the next visit and in other tabs. Use a new key for a new message (`"launch-2026-11"`). A controlled bar (`open`) does not read it: the page decides. |
| `defaultOpen` | `boolean` | true | Whether the bar shows at first. |
| `onOpenChange` | `function` |  | Called when the bar opens or closes (`false` after a dismiss). |
| `className` | `string` |  | Classes for the bar, the part that you see. |
| `labels` | `Partial<typeof ANNOUNCEMENT_BAR_LABELS>` |  | The words of the parts (`ANNOUNCEMENT_BAR_LABELS`). Translate them. Keep the object stable. |

Also takes every prop of Base UI `Collapsible.Root`: https://base-ui.com/react/components/collapsible

### AnnouncementBarBadge

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### AnnouncementBarTitle

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### AnnouncementBarDescription

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### AnnouncementBarAction

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `arrow` | `boolean` | true | Show the arrow after the text. It moves 2px on hover and points the other way in RTL. |
| `stretched` | `boolean` | false | Make the whole bar the link (a `::after` over the bar). Use it when the action is the only link; the close button stays on top. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

### AnnouncementBarClose

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | "Dismiss announcement" | The name of the button for screen readers. Translate it. |

### AnnouncementBarCountdown

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `to` | `string \| number \| Date` |  | The end: a `Date`, a time in ms, or a date string (`"2026-11-30T23:59:00Z"`). |
| `locale` | `LocalesArgument` |  | The language of the units ("2d 04h", "2j 04h") and of the default `label`. The browser language by default, which can differ from the page: pass the page language. |
| `label` | `function` | defaultCountdownLabel | The name for screen readers, from the end date. Translate it. |
| `onComplete` | `function` |  | Called once when the time is up (also when the end is already past). |
| `dismissOnComplete` | `boolean` | false | Close the bar when the time is up (and remember it with `dismissKey`). |

### AnnouncementBarRotator

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `interval` | `number` | 5000 | Time on each message in ms. 0 turns the rotation off. |
| `index` | `number` |  | The message that shows (controlled). A turn or a button press calls `onIndexChange`. |
| `defaultIndex` | `number` | 0 | The message that shows first (uncontrolled). |
| `onIndexChange` | `function` |  | Called when another message shows. |
| `controls` | `boolean` | true | Show the previous and next buttons. |
| `label` | `string` | "Announcements" | The names for screen readers. Translate them. |
| `slideLabel` | `function` | defaultSlideLabel |  |

### AnnouncementBarItem

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| AnnouncementBar | `announcement-bar` | `data-active`, `data-animate` | `--radius` | `hit-area`, `motion-timing` |
| AnnouncementBarBadge | `announcement-bar-badge` |  |  |  |
| AnnouncementBarTitle | `announcement-bar-title` |  |  |  |
| AnnouncementBarDescription | `announcement-bar-description` |  |  |  |
| AnnouncementBarAction | `announcement-bar-action` |  |  |  |
| AnnouncementBarClose | `announcement-bar-close` |  |  |  |
| AnnouncementBarCountdown | `announcement-bar-countdown` |  |  |  |
| AnnouncementBarRotator | `announcement-bar-rotator` |  |  |  |
| AnnouncementBarItem | `announcement-bar-item` |  |  |  |

## Usage

Put a title, an action link, and a close button in the bar, so people read the news and can hide it.

```tsx title="launch-bar.tsx"
import {
  AnnouncementBar,
  AnnouncementBarAction,
  AnnouncementBarBadge,
  AnnouncementBarClose,
  AnnouncementBarTitle,
} from "@/components/layout/announcement-bar";

export function LaunchBar() {
  return (
    <AnnouncementBar variant="inverse">
      <AnnouncementBarBadge>New</AnnouncementBarBadge>
      <AnnouncementBarTitle>Lumen 3.0: shared dashboards for every team</AnnouncementBarTitle>
      <AnnouncementBarAction href="/blog/lumen-3">Read the launch post</AnnouncementBarAction>
      <AnnouncementBarClose />
    </AnnouncementBar>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/announcement-bar
```

It adds 40 registry items: 37 files, 6210 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `@xstate/react`, `clsx`, `motion`, `tailwind-merge`, `tailwind-variants`, `xstate`.

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Announcement](https://gelatinui.com/components/announcement.md)
- [Alert](https://gelatinui.com/components/alert.md): Pick Alert for a message about one part of a page, such as an error in a form.
- [Countdown](https://gelatinui.com/components/countdown.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Tab | Moves to the action, the rotator buttons, and the close button. |
| Enter | Opens the action link, or closes the bar from the close button. |

## Motion

| Part | Motion |
| --- | --- |
| Close | panel · the bar height closes in 260ms, so the page slides up |
| Rotator | fade · the old message fades out in 100ms, then the new one fades in over 150ms |
