Alert
A persistent message that helps people recover or continue.
A top banner that rotates messages, counts down, and collapses smoothly when dismissed.
npx shadcn@latest add @silicon-ui/announcement-barnpx shadcn@latest add @silicon-ui/announcement-barInstall the dependencies.
npm install lucide-react motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/announcement-bar/announcement-bar.tsxcomponents/silicon-ui/announcement-bar/announcement-bar.module.cssInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
| Prop | Type | Default |
|---|---|---|
messages* | Announcement[] | — |
idRemembers dismissal under this id. Change the id to show a new campaign to everyone again. | string | — |
openWhether the bar is shown. Leave it out to let the component manage it. | boolean | — |
defaultOpen | boolean | true |
onOpenChange | (open: boolean) => void | — |
indexIndex of the visible message. | number | — |
defaultIndex | number | 0 |
onIndexChange | (index: number) => void | — |
intervalMilliseconds each message stays before the next one. Defaults to 6000. | number | 6000 |
autoPlayRotate automatically. Pauses on hover, focus, or a hidden tab, and is turned off when the visitor prefers reduced motion. Defaults to true. | boolean | true |
controlsShow previous, next, and pause controls when there are several messages. Defaults to false: only the close button shows. | boolean | false |
dismissible | boolean | true |
tone | "neutral" | "inverted" | "neutral" |
onAction | (announcement: Announcement) => void | — |
onCountdownEnd | (announcement: Announcement) => void | — |
labelAccessible name of the region. | string | "Announcements" |
className | string | — |
Also accepts the props of HTMLAttributes.