AnnouncementSection
Present announcements, promotions, countdowns, and multiple dismissible notices with accessible controls.
AnnouncementSection displays a concise notice with optional icon and consumer-provided action. It supports a single message, a countdown, or independently dismissible messages. It does not own campaign routing, persistence, or scheduling.
Beta API maturity: Beta.
Installation
import { AnnouncementSection } from "@puzzle-ui/pieces";Variant previews
Every supported variant has an individual runnable preview. The dismiss control is keyboard operable; countdown mode requires a valid date string or Date.
bar - A compact notice at the top or bottom of a page.
dismissible - A temporary notice that visitors can close.
centered - A short, centered message with one clear action.
split - A message and action that need separate alignment.
promotional - A promotion with a prominent call to action.
countdown - A time-bound offer with a live countdown.
ticker - A long, scrollable strip of brief updates.
multi-message - Several independent notices in one region.
floating - A contained notice above surrounding content.
minimal - A low-emphasis message with minimal decoration.
API
| Prop | Type | Description |
|---|---|---|
variant | "bar" | "dismissible" | "centered" | "split" | "promotional" | "countdown" | "ticker" | "multi-message" | "floating" | "minimal" | Selects the presentation. Defaults to bar. |
message | ReactNode | Content for a single announcement. |
icon | ReactNode | Optional decorative icon for a single announcement. |
action | ReactNode | Consumer-provided action for a single announcement. |
dismissible | boolean | Enables the dismiss button. Defaults to true for the dismissible variant. |
dismissLabel | string | Accessible name for the dismiss button. |
countdownTarget | Date | string | Required with variant="countdown"; invalid dates throw a RangeError. |
announcements | readonly AnnouncementItem[] | Required with variant="multi-message"; each item needs a stable id and message. |
| Shared section props | SectionRootProps and heading props | Semantic root, theme, native attributes, optional heading, actions, and children. |
Usage
<AnnouncementSection
variant="dismissible"
message="A new collection is available."
action={<a href="/collections">Explore the collection</a>}
/>multi-message accepts icon, action, and dismissLabel per announcement item. Dismissed messages are removed for the current mounted instance; persistence is the consumer's responsibility. The ticker layout is horizontally scrollable and does not animate automatically.
Accessibility
Dismiss controls are real buttons with an accessible name and normal keyboard behavior. Use meaningful action text, keep notice content concise, and do not place essential information only in a decorative icon. A countdown is exposed as a time element; it is not announced every second.