Cookie Consent
NewCookie banner with accept, reject and per-category choices.
We use cookies
Some keep the site working; others help us improve it. You choose which ones we use. Cookie policy
Installation
$ pnpm dlx shadcn@latest add @synccn/cookie-consentFirst time in this project? Connect synccn with one command.
Usage
import { CookieConsent } from "@/components/ui/cookie-consent";<CookieConsent position="fixed" onSave={store} />API reference
Generated from the component's TypeScript types, so it always matches the code.
CookieConsent
Cookie banner with Accept all, Reject all and a Customise view. onSave receives { necessary, analytics, marketing }. Store the choice yourself.
- onSave
(prefs: CookiePreferences) => voidCalled with the visitor's choices. Store them yourself.
- policyHref
stringDefault
"#"Link to your cookie policy.
- position
"inline" | "fixed"Default
"inline"Fixed pins it to the bottom-left of the screen.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Components
- Switch for
Switch
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for Cookie
Accessibility
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: dialog
- ARIA attributes: aria-label