# consent Cookie consent banner (GDPR): 4 categories (necessary / functional / analytics / marketing), stored in a versioned cookie, Google Consent Mode, content from the CookieSettings global. A settings window in three modes to pick from (`settings`: in the bar, small window, large window with cookie details). Default look in plain Tailwind, overridable. ## Dependency The banner uses an icon from `lucide-react` — a regular `dependencies` entry of the package (`^0.400.0`), installed together with ipal-kit; you add nothing in the project. ## Config The **CookieSettings** global (slug `cookie-settings`, group *Settings*) is always built. Public read (`read: () => true` — the banner reads it for anonymous visitors); `update` is limited to the `admin` and `editor` roles (`adminOrEditor` — consent texts are legal copy, not for plain `user` accounts). To change it: `ipalKit({ globalOverrides: { 'cookie-settings': { access: { update } } } })`. The only plugin option in this module is `consentLog` (below). The editor manages the banner content (message, buttons, categories, settingsTitle) in the panel, localized. The privacy policy link comes from system pages (`privacyPolicy`), not from a separate field. **Privacy policy link in the banner (since 1.7.12)** — zero code: | What | Where from | |---|---| | Where it leads | Site Settings → System Pages → Privacy Policy | | Link text | Cookie Settings → `privacyLinkLabel` (per language) | | When the text is empty | title of the policy page in that language | `privacyPolicy` options in `getConsentTexts`: omit (automatic), `false` (no link), `{ page }` (your own page, read with `locale: 'all'`). The `label` parameter is **deprecated** — text hard-coded in code breaks A0 with several languages; it works only when the panel field is empty. Remove it from projects when you update them. ## Front — Provider + banner Usually one line in the layout (PROGRAMISTA §2.8) — `SiteProviders` (`/rsc`) wires the provider, banner, button and `Analytics` in the right order, with texts from `getSiteShell(locale).consent`: ```tsx }>{children} ``` `SiteProviders` also takes `cookieMap`, `banner={false}`, `cookieButton={false}` (or your own element) and `analytics={false | { consentMode, defer, deferTimeoutMs }}` (`consentMode: 'basic'` = no Google request before consent — see [analytics.md](./analytics.md)). By hand (your own layout) — the same from the individual parts: The provider wraps the app; the banner and the button render themselves. Import from `@intecion/ipal-kit/client`: ```tsx // app/(frontend)/[locale]/layout.tsx import { ConsentProvider, CookieBanner, CookieButton } from '@intecion/ipal-kit/client' import { getConsentTexts } from '@intecion/ipal-kit' export default async function Layout({ children, params }) { const { locale } = await params const payload = await getPayload({ config }) // texts from Cookie Settings; the policy link is automatic: // target = System Pages → Privacy Policy, text = Cookie Settings → privacyLinkLabel const texts = await getConsentTexts({ payload, config: i18nConfig, locale }) return ( {children} ) } ``` `ConsentProvider` — props: `texts` (required, `ConsentTexts` from `getConsentTexts`), `cookieMap` (extra cookies to delete on withdrawal), `logEndpoint` (consent log). `CookieBanner` does not render after a decision, `CookieButton` — the opposite (it shows only after a decision and reopens the banner); both render only after mounting on the client. `getConsentTexts({ payload, config, locale, privacyPolicy?, settingsSlug? })` — `settingsSlug` is the SiteSettings slug for the automatic link (default `'site-settings'`). Empty fields in the panel → English fallback. | `CookieBanner` prop | Default | Description | |---|---|---| | `classNames` | — | slots (table below) — a given one replaces the default | | `equalChoice` | `false` | "Reject" styled as the primary button | | `icon` | `true` | cookie icon | | `order` | `['settings', 'reject', 'accept']` | banner buttons | | `settings` | `'inline'` | `'inline' \| 'modal' \| 'detailed'` | | `controls` | `'checkbox'` | `'checkbox' \| 'switch'` | | `settingsActions` | `['back', 'save']` | buttons under the categories (`'accept' \| 'back' \| 'reject' \| 'save'`) | `CookieButton` takes only `className` (replaces the default). ## Overriding the look (Level 2) The default Tailwind classes can be overridden with `classNames`: ```tsx ``` ## Gating scripts by consent ```ts import { updateConsent, setDefaultConsent } from '@intecion/ipal-kit' // sends signals to Google Consent Mode (gtag) based on the consent state ``` The logic (categories, storage, parsing) is also available server-safe from `@intecion/ipal-kit`: ```ts import { parseConsent, CONSENT_COOKIE, CONSENT_CATEGORIES } from '@intecion/ipal-kit' // e.g. server-side script gating based on the consent cookie ``` ### ConsentScript — load a script only after consent For third parties WITHOUT their own Consent Mode (Meta Pixel, LinkedIn Insight, chats, your own analytics) use `ConsentScript` — it loads the script only after consent for its category and reacts live (accept in the banner → the script appears without a reload). Render it inside ``: ```tsx import { ConsentScript } from '@intecion/ipal-kit/client' ``` GA/GTM are better handled by Consent Mode (`updateConsent` above) — `ConsentScript` is for vendors you cannot gate that way. Note: a script once loaded runs until the page ends (a `