Cookie Consent
1 variante
A floating cookie consent banner with a preferences dialog for each category, saved choices, and a corner button to change them later.
Floating banner
cookie-consent.tsxThe card rises out of a soft blur while its cookie jar bobs, and Customize grows a preferences dialog out of the button. After a choice the card sinks away and a round settings button fades into its corner.
We use cookies
Some keep the site running. Others help us measure and improve it, only with your OK. Privacy policy
TSXcomponents/previews/premium/cookie-consent-preview.tsx
"use client";
import { RotateCcw } from "lucide-react";
import { useState } from "react";
import { Button } from "@/components/motion/button";
import {
type ConsentState,
CookieConsent,
} from "@/components/premium/cookie-consent";
const LINES = ["w-11/12", "w-10/12", "w-9/12"];
export function CookieConsentPreview() {
const [open, setOpen] = useState(true);
const [consent, setConsent] = useState<ConsentState | null>(null);
return (
<div className="w-full px-4 py-10">
<div className="relative mx-auto h-96 w-full max-w-3xl overflow-clip rounded-3xl border border-border bg-background">
<div aria-hidden="true" className="space-y-8 p-5 sm:p-8">
<div className="flex items-center gap-3">
<span className="size-6 rounded-full bg-muted" />
<span className="h-2 w-12 rounded-full bg-muted" />
<span className="hidden h-2 w-10 rounded-full bg-muted sm:block" />
<span className="hidden h-2 w-14 rounded-full bg-muted sm:block" />
</div>
<div className="max-w-md space-y-3">
<span className="block h-4 w-3/4 rounded-full bg-muted" />
<span className="block h-4 w-1/2 rounded-full bg-muted" />
<div className="space-y-2 pt-2">
{LINES.map((width) => (
<span
key={width}
className={`block h-2 rounded-full bg-muted/70 ${width}`}
/>
))}
</div>
</div>
</div>
<Button
type="button"
size="sm"
variant="outline"
disabled={open}
onClick={() => {
setConsent(null);
setOpen(true);
}}
className="absolute top-4 right-4 h-8 px-3 text-xs"
>
<RotateCcw className="size-3.5" aria-hidden="true" />
Reset
</Button>
<CookieConsent
position="absolute"
value={consent}
onChange={setConsent}
open={open}
onOpenChange={setOpen}
/>
</div>
</div>
);
}
El código fuente está bloqueado
Consigue acceso para instalar componentes premium y ver todo el código fuente.
Abrir panelInstalar
$ bunx --bun shadcn add @beui-pro/cookie-consentcookie-consentcookie-consent