Glow · Cookie consent
A small cookie consent card lit cyan from above, with a light title, one line of copy and two buttons. Recolor it by changing one CSS variable.
"use client"
import { useState } from "react"
import { XIcon } from "@phosphor-icons/react"
import { Button } from "@/components/ui/button"
// The copy: change text here, not in the markup.
const COPY = {
title: "A quiet cookie.",
description:
"One cookie keeps you signed in. Nothing tracks you across sites.",
accept: "Accept",
needed: "Only needed",
dismiss: "Dismiss",
restore: "Show again",
} as const
/** A cookie consent card lit cyan from above. Change `--glow` to recolor it. */
export default function BannerGlowCookieConsent() {
const [shown, setShown] = useState(true)
if (!shown) {
return (
<Button variant="outline" onClick={() => setShown(true)}>
{COPY.restore}
</Button>
)
}
return (
<div className="relative isolate w-full max-w-md overflow-hidden rounded-2xl bg-slate-950 text-white [--glow:34_211_238]">
<div
aria-hidden="true"
className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_center_top,rgb(var(--glow)/0.3)_0%,transparent_60%)]"
/>
<div className="relative z-10 p-6">
<div className="flex items-start justify-between gap-4">
<p className="text-xl font-light tracking-tight">{COPY.title}</p>
<Button
variant="ghost"
size="icon-sm"
aria-label={COPY.dismiss}
onClick={() => setShown(false)}
className="text-white hover:bg-white/10 hover:text-white"
>
<XIcon />
</Button>
</div>
<p className="mt-2 text-sm/6 text-white/70">{COPY.description}</p>
<div className="mt-5 flex gap-3">
<Button
onClick={() => setShown(false)}
className="h-11 bg-white px-5 text-slate-950 hover:bg-white/90"
>
{COPY.accept}
</Button>
<Button
variant="outline"
onClick={() => setShown(false)}
className="h-11 border-white/20 bg-transparent px-5 text-white hover:bg-white/10 hover:text-white"
>
{COPY.needed}
</Button>
</div>
</div>
</div>
)
}
Installation
pnpm dlx shadcn@latest add @01orbital/banner-glow-cookie-consentnpx shadcn@latest add @01orbital/banner-glow-cookie-consentyarn dlx shadcn@latest add @01orbital/banner-glow-cookie-consentbunx --bun shadcn@latest add @01orbital/banner-glow-cookie-consentMake it yours
- Its words are in
COPYat the top ofcomponents/blocks/banner/banner-glow-cookie-consent/index.tsx: change them there, not in the markup.
Built from
npm: @phosphor-icons/react. The CLI installs it for you.
Built from these parts. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:
The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.
Last updated on