115 Components

Announcement Banner

Navigation

Slim, animated top banner that announces product releases, features, or offers with Snappy spring physics, smooth rotation, and collapse animations.

NewBannerDismissibleSpring
/r/announcement-banner.json

Installation

Install directly into your project using the shadcn CLI or copy the source code manually.

Requires:framer-motionlucide-reactclsxtailwind-merge
$npx shadcn@latest add "https://boseui.site/r/announcement-banner.json"

Props

TypeScript props supported by <AnnouncementBanner />.

11 props
PropTypeDefaultDescription
messagesrequiredAnnouncementMessage[]—Array of announcement messages. A single item displays statically; multiple items rotate automatically.
variant"default" | "accent" | "inverted" | "glass" | "fade" | "outline" | "highlight""default"Visual style variant: subtle neutral ('default'), teal accent ('accent'), high contrast ('inverted'), frosted ('glass'), horizontal gradient ('fade'), minimal border ('outline'), or warning yellow ('highlight').
dismissiblebooleantrueWhether to display the close button and enable banner dismissal.
storageKeystring"boseui-announcement"Local storage key namespace. Dismissal tracks messages[0].id so updated announcements reappear.
rotateIntervalnumber5000Interval in milliseconds between rotating messages when multiple messages are supplied.
stickybooleanfalseIf true, pins the banner to the top of the viewport during scrolling.
stiffnessnumber380Spring stiffness coefficient matching the Snappy preset.
dampingnumber24Spring damping coefficient controlling oscillation decay matching the Snappy preset.
onDismiss() => voidundefinedCallback invoked when the user dismisses the banner.
backgroundReact.ReactNodeundefinedOptional background element (e.g. FlickeringGrid or canvas texture).
classNamestringundefinedAdditional Tailwind classes applied to the outer container.

Key Features

  • Snappy spring physics preset (stiffness 380, damping 24) powering enter, rotation, and collapse transitions.
  • Zero-jump collapsing dismiss animation that smoothly slides the entire page content up.
  • Auto-rotating message sequence that automatically pauses on hover, keyboard focus, and background tabs.
  • SSR and hydration safe localStorage persistence with message-id invalidation.
  • Dynamic --announcement-height CSS variable synchronization for sticky headers.
  • Accessible keyboard navigation with visible focus rings and WCAG AA contrast across 3 color variants.

Keyboard & Accessibility

  • Landmark semantics with role='region' and aria-label='Announcement'.
  • Rotating text container uses aria-live='off' to prevent interrupting screen readers.
  • Accessible dismiss button with minimum hit target, keyboard focus states, and aria-label.
  • Full reduced-motion compatibility disabling slide animations and auto-rotation.