Custom CSS Overview
Custom CSS lets you restyle any part of the consent banner — colors, fonts, radius, layout — while the GDPR compliance rules remain server-enforced and untouchable.
What is custom CSS?
Section titled “What is custom CSS?”The Kookiok consent UI renders inside a Shadow DOM — a browser-native isolation boundary that prevents your site’s styles from leaking in and the consent UI’s styles from leaking out. Custom CSS is a snippet you write in the banner editor that gets injected inside those Shadow Roots, after the template’s own styles, giving you fine-grained control over appearance.
Since v2026.08.04 the same snippet reaches all three consent surfaces — the banner, the floating privacy trigger, and the preferences popup — each in its own Shadow Root.
Think of it in three layers:
- Template recipe — sets the overall visual personality (colors, shadow, animation).
- Design tokens — CSS custom properties (
--radius,--btn-fill,--surface, …) that you can override to adjust the recipe without replacing it. - Class overrides — direct rules targeting
.ag-banner,.ag-btn,.ag-title, etc. for anything tokens can’t express.
When to use it
Section titled “When to use it”| Scenario | Recommended approach |
|---|---|
| Change brand color | Override --btn-fill, --accent tokens |
| Adjust corner roundness | Override --radius token |
| Compact padding on mobile | Class override @media rule on .ag-banner-inner |
| Custom font | Override --font-family token (self-hosted only) |
| Full visual redesign | Class overrides + token overrides combined |
For most brand alignment tasks, token overrides alone are sufficient and are less likely to break when Kookiok updates the default template styling.
What you cannot change
Section titled “What you cannot change”The compliance checker also flags CSS patterns that would violate GDPR — hiding the Reject button, pre-checking non-necessary categories, or creating visual asymmetry between Accept and Reject. See GDPR Compliance Risks.
How it works (technical)
Section titled “How it works (technical)”Browser tab└── Shadow Host (#__AG_CONSENT_HOST__) └── Shadow Root ← isolation boundary ├── <style> [recipe CSS — token defaults] ├── <style> [your custom CSS] ← injected here └── .ag-overlay └── .ag-banner └── ...banner DOMYour CSS is injected as a <style> tag inside each consent Shadow Root. This means:
- Your site’s external stylesheets have no effect on the banner.
- The banner’s styles have no effect on your site.
- Standard CSS selector specificity applies within each Shadow Root.
- Selectors only match inside the surface they belong to, so one snippet can safely style the banner, the privacy trigger and the preferences popup at once.
Size and safety limits
Section titled “Size and safety limits”- 10,000 character maximum per banner.
- A sanitizer strips dangerous patterns (
expression(),javascript:,@import, etc.) silently. - Branding-targeting rules return HTTP 422 with a structured error listing which selectors were rejected.