Skip to content
caliper ui docs

Pro

Cookie consent

Asks once and plainly: reject and accept carry the same weight, choices explain what they are for, and the preferences can be reopened later.

Pro
pnpm dlx shadcn@latest add @caliper/cookie-consent
halden.example/journal

Journal · 6 min read · Lena Fischer

How we closed October two days early

Reading continues behind the banner: it never covers the page or traps focus.

No choice stored yet.

Cookies on this site

We use necessary cookies to make the site work. With your permission we would also like to measure visits and remember your settings. Cookie policy

© 2026 Halden
Installs components/ui/cookie-consent.tsxDepends on @radix-ui/react-dialog, @radix-ui/react-slot, lucide-reactMotion none in component source

When to use

Use it for

  • Sites that set analytics or marketing cookies.
  • A cookie settings link in the footer.

Skip it when

  • Only necessary cookies are used; no banner is needed, mention them in the policy.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/cookie-consent

Adds its 5 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source. It is built from CookieConsent and CookiePreferences.

example.tsx
import { CookieConsent, CookiePreferences } from "@/components/ui/cookie-consent"

The worked example comes with Pro

The 61-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

CookieConsent

component
PropTypeDefaultDescription
open *boolean—Show the banner, usually while no choice is stored.
categories *readonly CookieCategory[]—
valueCookieChoice—
onDecide *(choice: CookieChoice, decision: CookieDecision) => void—
titlestring"Cookies on this site"
descriptionstring"We use necessary cookies to make the site work. With your permission we would also like to measure visits and remember your settings."
policyHrefstring—
position"inline" | "fixed""fixed"`fixed` sits on the bottom of the viewport; `inline` stays where it is placed, e.g. in a preview.
classNamestring—

CookiePreferences

component
PropTypeDefaultDescription
open *boolean—
onOpenChange *(open: boolean) => void—
categories *readonly CookieCategory[]—
valueCookieChoice—The choice saved last time, if any.
onSave *(choice: CookieChoice, decision: CookieDecision) => void—
policyHrefstring—

Accessibility

It is built on native elements and keeps aria-describedby, aria-labelledby and aria-hidden in step with state.

Keyboard and focus handling comes from Radix dialog: arrow keys move through items, Enter and Space select, and Escape closes and returns focus.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Feedback examples