Announcement bar
A React component in Beamline's Feedback category, in the free sample.
A banner across the top for news and offers: messages take turns, a countdown ticks, and dismissing folds it away and can remember it.
Use it for
- Site-wide news, offers and deadlines.
Not for
- Errors (alert).
- Personal notifications (notification-center).
Anatomy
- bar (a size container)
- previous / next (fold away under 28rem)
- message (one line from 28rem, two under it)
- countdown (its digits roll)
- action
- dismiss
- timer (a hairline filling over the interval while it rotates)
States
- rotating (the timer fills)
- held (pointed at, keyboard focus, or on touch a tap until the next tap; a tap on its link or arrows holds it until a touch elsewhere: the timer is gone and rotation waits)
- paused (off screen, reduced motion)
- dismissed
Keyboard
- Tab to arrows, action and dismiss
- A swipe on touch moves between messages
Motion
Messages slide and fade over --pui-duration-considered (reduced motion: a fade). While it rotates on its own a hairline along the bottom fills over the interval and restarts with each message (a transform; none while held, off screen or reduced). The countdown's digits roll over --pui-duration-considered. Dismissing folds the bar by height over --pui-duration-considered.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
messages | { id, message, action?, countdown? }[] | — | Announcements rotated through the banner in the supplied order. Required. |
id | string (remembers dismissal) | — | Remembers a dismissal in this browser under this key. |
open / index | controlled or not | — | open: Controlled open state; omit to use defaultOpen. index: Controlled zero-based index of the displayed item; omit to use defaultIndex. |
interval / autoPlay / controls / dismissible / tone | mixed | — | interval: ms per message. Default 6000. autoPlay: Rotate on its own; held by hover, keyboard focus or a tap, and still with reduced motion. Default true. controls: Previous and next arrows. Default true with more than one message. dismissible: Offers a close control for the notice. Defaults to true. tone: Legacy appearance setting; omitted by default. Deprecated: Use appearance instead. |
style / ref | CSSProperties / native Ref | — | style: Inline styles on the documented visual root; no inline overrides by default. ref: Receives the documented root element; no ref by default. |
classNames | AnnouncementBarClassNames | — | Classes for the named visual parts; no part overrides by default. |
appearance | "neutral" | "inverted" | — | Page-coloured or inverted banner treatment; defaults to neutral. |
open | boolean | — | Controlled open state; omit to use defaultOpen. |
defaultOpen | boolean | — | Initial open state when uncontrolled. Defaults to true. |
onOpenChange | ((open: boolean) => void) | — | Reports open state after a change; no callback by default. |
index | number | — | Controlled zero-based index of the displayed item; omit to use defaultIndex. |
defaultIndex | number | — | Initial visible item index when uncontrolled. Defaults to 0. |
onIndexChange | ((index: number) => void) | — | Reports visible item index after a change; no callback by default. |
interval | number | — | ms per message. Default 6000. |
autoPlay | boolean | — | Rotate on its own; held by hover, keyboard focus or a tap, and still with reduced motion. Default true. |
controls | boolean | — | Previous and next arrows. Default true with more than one message. |
dismissible | boolean | — | Offers a close control for the notice. Defaults to true. |
tone | "inverted" | "neutral" | — | Legacy appearance setting; omitted by default. Deprecated: Use appearance instead. |
onAction | ((announcement: Announcement) => void) | — | Runs the action attached to the current announcement; no handler by default. |
onCountdownEnd | ((announcement: Announcement) => void) | — | Runs when the current announcement countdown reaches zero; no handler by default. |
label | string | — | The region's name. Default "Announcements". |
style | CSSProperties | — | Inline styles on the documented visual root; no inline overrides by default. |
ref | Ref<HTMLElement> | — | Receives the documented root element; no ref by default. |
className | string | — | Classes on the documented visual root; no override by default. |
Built from
Dependencies
lucide-react, motion
Import
import { AnnouncementBar } from "@beamline/announcement-bar";
Get it
Announcement bar is part of Beamline UI. Install the parts you need in your React app as compiled packages or editable source. Announcement bar is included in the free MIT sample. Get Beamline · Connect your agent
More in Feedback
- Timer: A duration that counts down (or up) from your clock: Start, Pause, Resume, Reset and the finish reported once; the time left drawn as a bar you drag (or…
- Notification centre: Updates that wait to be read: a bell with the unread count opens All / Unread, new and earlier groups, and per item mark read or dismiss.
- Usage meter: An allowance and what fills it: one bar split by source, the room left, a warning near the limit and the overflow in its own red well past a notch at the…
- Alert: A message that stays until it is dealt with: what happened, what to do, an action; danger and warning are announced; dismissing folds its height away.
- Cookie consent: Asks once which cookies a visitor allows, with Reject all and Accept all given equal weight; Customise grows the notice in place into each category with…
- Empty state: What a place will hold and the first step to fill it, instead of a blank; a compact size for panels and filtered tables.
- Spinner: A ring that spins while work runs and closes into a drawn check or cross when it ends.
- Progress: How much of a known task is done, or a moving bar when the length is unknown, with an optional label and value.
- Skeleton: Holds the shape of content while it loads, then crossfades into it, so nothing jumps.