Persisted Dismissible Banner
7ovr/announcement-3FreeBlock
Single-line announcement banner that remembers its dismissal in localStorage over a page placeholder, with a link to show it again.
Install it
npx shadcn@latest add https://7ovr.com/r/announcement-3.jsonSource
1"use client"23import { useEffect, useState } from "react"4import { Button } from "@/components/ui/button"5import { IconPlaceholder } from "@/components/icons/icon-placeholder"67const STORAGE_KEY = "acme-announcement-3-dismissed"89export default function AnnouncementBlock() {10 const [mounted, setMounted] = useState(false)11 const [dismissed, setDismissed] = useState(false)1213 useEffect(() => {14 const id = requestAnimationFrame(() => {15 try {16 if (localStorage.getItem(STORAGE_KEY) === "true") {17 setDismissed(true)18 }19 } catch {}20 setMounted(true)21 })22 return () => cancelAnimationFrame(id)23 }, [])2425 function handleDismiss() {26 setDismissed(true)27 try {28 localStorage.setItem(STORAGE_KEY, "true")29 } catch {}30 }3132 function handleReset() {33 setDismissed(false)34 try {35 localStorage.removeItem(STORAGE_KEY)36 } catch {}37 }3839 return (40 <section className="flex min-h-svh w-full flex-col items-center bg-muted/30 px-6 py-16 text-foreground">41 <div className="w-full max-w-5xl">42 {mounted && !dismissed && (43 <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">44 <IconPlaceholder45 lucide="Rocket"46 tabler="IconRocket"47 hugeicons="RocketIcon"48 phosphor="Rocket"49 remixicon="RiRocket2Line"50 className="hidden size-4 shrink-0 sm:block"51 aria-hidden="true"52 />53 <p className="min-w-0 flex-1 truncate font-medium">54 <span className="font-semibold">Acme Cloud is live.</span>{" "}55 <span className="text-primary-foreground/80">56 Deploy in seconds with zero config.57 </span>{" "}58 <Button59 variant="link"60 size="sm"61 render={<a href="#" />}62 nativeButton={false}63 className="h-auto p-0 align-baseline text-primary-foreground underline underline-offset-2 hover:text-primary-foreground/80"64 >65 Get Started66 </Button>67 </p>68 <Button69 variant="ghost"70 size="icon-sm"71 aria-label="Dismiss announcement"72 onClick={handleDismiss}73 className="-mr-1 shrink-0 hover:bg-primary-foreground/10 hover:text-primary-foreground"74// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from 7ovr
All 241 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Mission Statement With Statsabout-1 | 7ovr | Blocks | Free | 1 dep | |
| Founder Story With Photoabout-2 | 7ovr | Blocks | Free | 1 dep | |
| Values Card Gridabout-3 | 7ovr | Blocks | Free | 1 dep | |
| Mission Vision Values Columnsabout-4 | 7ovr | Blocks | Free | 1 dep | |
| Recent Activity Cardactivity-1 | 7ovr | Blocks | Free | 1 dep | |
| Activity Grouped By Dayactivity-2 | 7ovr | Blocks | Free | 1 dep | |
| Audit Log With Icon Tilesactivity-3 | 7ovr | Blocks | Free | 1 dep | |
| Activity Tabs With Unreadactivity-4 | 7ovr | Blocks | Free | 1 dep |
