# Persisted Dismissible Banner

> Single-line announcement banner that remembers its dismissal in localStorage over a page placeholder, with a link to show it again.

A shadcn/ui block from the [@7ovr](https://7ovr.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/7ovr/announcement-3).

- Page, with a live preview: https://shadcn.exchange/r/7ovr/announcement-3
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/7ovr/announcement-3-light-e22e1615caa30524.png
- Registry item: https://7ovr.com/r/announcement-3.json
- Categories: announcement
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://7ovr.com/r/announcement-3.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `@base-ui/react`
- Registry items: `button`

## Notes from the registry

Requires a `base-*` style in components.json (the `shadcn init` default). Legacy `new-york`/`radix-*` styles install Radix primitives, which reject the `render` prop this block uses.

## Files

### `registry/blocks/announcement/3/announcement-block.tsx`

```tsx
"use client"

import { useEffect, useState } from "react"
import { Button } from "@/components/ui/button"
import { IconPlaceholder } from "@/components/icons/icon-placeholder"

const STORAGE_KEY = "acme-announcement-3-dismissed"

export default function AnnouncementBlock() {
  const [mounted, setMounted] = useState(false)
  const [dismissed, setDismissed] = useState(false)

  useEffect(() => {
    const id = requestAnimationFrame(() => {
      try {
        if (localStorage.getItem(STORAGE_KEY) === "true") {
          setDismissed(true)
        }
      } catch {}
      setMounted(true)
    })
    return () => cancelAnimationFrame(id)
  }, [])

  function handleDismiss() {
    setDismissed(true)
    try {
      localStorage.setItem(STORAGE_KEY, "true")
    } catch {}
  }

  function handleReset() {
    setDismissed(false)
    try {
      localStorage.removeItem(STORAGE_KEY)
    } catch {}
  }

  return (
    <section className="flex min-h-svh w-full flex-col items-center bg-muted/30 px-6 py-16 text-foreground">
      <div className="w-full max-w-5xl">
        {mounted && !dismissed && (
          <div className="flex w-full items-center gap-3 rounded-lg border border-border bg-primary px-4 py-2.5 text-sm text-primary-foreground shadow-sm">
            <IconPlaceholder
              lucide="Rocket"
              tabler="IconRocket"
              hugeicons="RocketIcon"
              phosphor="Rocket"
              remixicon="RiRocket2Line"
              className="hidden size-4 shrink-0 sm:block"
              aria-hidden="true"
            />
            <p className="min-w-0 flex-1 truncate font-medium">
              <span className="font-semibold">Acme Cloud is live.</span>{" "}
              <span className="text-primary-foreground/80">
                Deploy in seconds with zero config.
              </span>{" "}
              <Button
                variant="link"
                size="sm"
                render={<a href="#" />}
                nativeButton={false}
                className="h-auto p-0 align-baseline text-primary-foreground underline underline-offset-2 hover:text-primary-foreground/80"
              >
                Get Started
              </Button>
            </p>
            <Button
              variant="ghost"
              size="icon-sm"
              aria-label="Dismiss announcement"
              onClick={handleDismiss}
              className="-mr-1 shrink-0 hover:bg-primary-foreground/10 hover:text-primary-foreground"
            >
              <IconPlaceholder
                lucide="X"
                tabler="IconX"
                hugeicons="Cancel01Icon"
                phosphor="X"
                remixicon="RiCloseLine"
                aria-hidden="true"
              />
            </Button>
          </div>
        )}

        <div className="mx-auto mt-8 w-4/5 space-y-6" aria-hidden="true">
          <div className="flex items-center justify-between">
            <div className="h-6 w-28 rounded-md bg-muted" />
            <div className="hidden items-center gap-3 sm:flex">
              <div className="h-3 w-12 rounded-md bg-muted" />
              <div className="h-3 w-12 rounded-md bg-muted" />
              <div className="h-7 w-16 rounded-md bg-muted" />
            </div>
          </div>

          <div className="space-y-2">
            <div className="h-6 w-1/2 rounded-md bg-muted" />
            <div className="h-3 w-full rounded-md bg-muted" />
            <div className="h-3 w-4/5 rounded-md bg-muted" />
          </div>

          <div className="grid gap-3 sm:grid-cols-3">
            <div className="h-20 rounded-md bg-muted" />
            <div className="h-20 rounded-md bg-muted" />
            <div className="h-20 rounded-md bg-muted" />
          </div>
        </div>

        {mounted && dismissed && (
          <p className="mt-8 text-center text-xs text-muted-foreground">
            Banner dismissed and saved to your browser.{" "}
            <Button
              variant="link"
              size="sm"
              onClick={handleReset}
              className="h-auto p-0 align-baseline text-xs"
            >
              Show It Again
            </Button>
          </p>
        )}
      </div>
    </section>
  )
}
```
