Installation
Run this in a project that already uses shadcn/ui. The CLI adds the block, its components and npm dependencies.
pnpm dlx shadcn@latest add https://ui.sumansharma.info.np/r/banner-1.jsonPrefer to iterate with AI?Open in
Usage
The CLI writes the block to components/banner-1.tsx. Import it anywhere:
Loading...
Source
The CLI writes this component to components/banner-1.tsx.
'use client'
import { useState } from 'react'
import Link from 'next/link'
import { ArrowRight, Sparkles, X } from 'lucide-react'
export default function Banner() {
const [visible, setVisible] = useState(true)
if (!visible) {
return (
<div className="flex min-h-40 items-center justify-center">
<button
type="button"
onClick={() => setVisible(true)}
className="text-muted-foreground hover:text-foreground text-sm underline underline-offset-4">
Show banner again
</button>
</div>
)
}
return (
<div
role="region"
aria-label="Announcement"
className="bg-foreground text-background relative isolate flex items-center gap-x-6 overflow-hidden px-6 py-2.5 sm:px-3.5 sm:before:flex-1">
<div
aria-hidden
className="absolute inset-0 -z-10 bg-[linear-gradient(110deg,transparent_25%,rgb(255_255_255/0.08)_50%,transparent_75%)] bg-[length:250%_100%] motion-safe:animate-[banner-shine_6s_linear_infinite] dark:bg-[linear-gradient(110deg,transparent_25%,rgb(0_0_0/0.08)_50%,transparent_75%)]"
/>
<p className="flex flex-wrap items-center gap-x-2 text-sm leading-6">
<Sparkles className="size-4 shrink-0" />
<strong className="font-semibold">Lyra 2.0 is here</strong>
<span
aria-hidden
className="hidden opacity-50 sm:inline">
·
</span>
<span className="opacity-80">Faster builds, a new editor and 40 fresh components.</span>
<Link
href="#"
className="group inline-flex items-center gap-1 font-semibold underline-offset-4 hover:underline">
Read the launch post
<ArrowRight className="size-3.5 transition-transform group-hover:translate-x-0.5" />
</Link>
</p>
<div className="flex flex-1 justify-end">
<button
type="button"
onClick={() => setVisible(false)}
aria-label="Dismiss announcement"
className="-m-2 rounded-md p-2 opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-2 focus-visible:outline-current">
<X className="size-4" />
</button>
</div>
<style>{`@keyframes banner-shine { from { background-position: 100% 0 } to { background-position: -150% 0 } }`}</style>
</div>
)
}