Skip to main content
Clever Ops

Announce Banner

Top-of-page announcement bar, one line, one link, one dismiss. Height collapses shut on a callback-driven dismiss, with info and warning variants in honest primary and destructive tokens.

Preview & code

Loading Announce Banner preview

Installation

pnpm dlx shadcn@latest add @cleverui/banner-announce

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { BannerAnnounce } from '@/components/blocks/banner-announce'
Exampletsx
'use client'

import { useState } from 'react'
import { BannerAnnounce } from '@/components/blocks/banner-announce'

export default function BannerAnnounceDemo() {
  const [infoKey, setInfoKey] = useState(0)
  const [warnKey, setWarnKey] = useState(0)

  return (
    <div className="flex min-h-[200px] flex-col justify-center gap-8 py-8">
      <div className="space-y-3">
        <p className="px-4 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:px-6">
          Info
        </p>
        <BannerAnnounce
          key={`info-${infoKey}`}
          message="Ledger 2.4 ships Thursday, draft reviews, shared pens, and offline ink."
          link={{ label: 'Read the notes', href: '#' }}
          variant="info"
          onDismiss={() => {
            window.setTimeout(() => setInfoKey((k) => k + 1), 600)
          }}
        />
      </div>

      <div className="space-y-3">
        <p className="px-4 font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:px-6">
          Warning
        </p>
        <BannerAnnounce
          key={`warn-${warnKey}`}
          message="Scheduled maintenance Sunday 02:00–04:00 UTC. Writes pause; reads stay live."
          link={{ label: 'Status page', href: '#' }}
          variant="warning"
          onDismiss={() => {
            window.setTimeout(() => setWarnKey((k) => k + 1), 600)
          }}
        />
      </div>
    </div>
  )
}

API reference

BannerAnnounce accepts the following props.

PropTypeDefaultDescription
message*stringthe single announcement line, e.g. 'CleverUI 2.0 ships Thursday'
link{ label: string; href: string }inline text link rendered after the message
variant'info' | 'warning''info'info keys the accent off primary; warning speaks in destructive tokens
onDismiss() => voidfired when the dismiss button is pressed; parent owns persistence (cookie/localStorage), omitting it hides the dismiss button entirely

…plus everything from Omit< React.HTMLAttributes<HTMLElement>, 'onDrag' | 'onDragStart' | 'onDragEnd' | 'onAnimationStart' >: className, event handlers, aria attributes and the rest pass straight through.

Frequently asked questions

How do I install the Announce Banner component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/banner-announce`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Announce Banner require?

Announce Banner uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Announce Banner to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services