| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Custom template for Cookiebot cookie banners. Copy template files and customize it or use as is. Respects your site's styling but has functional base styling on its own.
Designed for Finnish rendition of EU cookie law but it is similar in many countries in EU.
True neutral option without highlighted accept button and banner is located at the bottom of the screen without blocking the user before decision.
Includes permitted (at least by Finnish version of EU Cookie Law) ways to optimize interaction by positioning banner to the center of the screen and blocking interaction with site before decision (by mouse or touch). Accept button is highlghted with color but declining is as easy as accepting.
This is sort of general setup of Cookiebot. If you have setup Cookiebot before the only different part is in Dialog tab when you add this custom template.
In Cookiebot dialog editor you can change and save the code for HTML/CSS/JS files and they are automatically served via embed code. For HTML and JS related changes to banner, this is pretty much the only way to do it.
For styling there are more options. You can change CSS in the dialog editor but if you are just adding things on top of the template (like styling for buttons) it can be easier to do it in the website. Or if you have multiple projects/customers in same domain group, you can personalize the banners in website code.
The styles rely on ID selectors which mean that overriding styles either need to use ID selectors as well or be stuck with !important. ID selectors are used to minimize conflicts with website's own selectors by boosting priority.
As default styles often use #CookieBanner on selectors, the easy way to override is to chain two ID selectors as #CookieBanner #CookieBannerNotice like #CookieBanner #CookieBannerNotice .cookiebanner__main.
These templates include lots of CSS variables that let you customize the template for most use cases by just defining CSS variables.
These variables exist in both templates.
// layout --cb-dialog-max-width // overlay --cb-overlay-background // base typopgraphy --cb-text-color // title --cb-title-font-family --cb-title-font-weight --cb-title-font-size-mobile --cb-title-font-size-desktop // description --cb-description-font-size-mobile --cb-description-font-size-desktop --cb-description-font-family --cb-description-font-weight // base button --cb-button-border --cb-button-border-radius --cb-button-background --cb-button-font-weight --cb-button-font-size --cb-button-font-family --cb-button-color // base button :hover/:focus/:active --cb-button-active-color --cb-button-active-background --cb-button-active-border // accept button (inherits all base button settings) --cb-accept-button-color --cb-accept-button-background --cb-accept-button-border --cb-accept-button-active-color --cb-accept-button-active-background --cb-accept-button-active-border // details button (doesn't inherit base button settings) --cb-details-button-font-size // preference accent color (toggle control) --cb-preference-accent-color
Notice that you only need to define/change those variables that you want. You don't have to define/use them all.
Example 1: Styling accept button in website stylesheet
You can define variables in :root.
:root {
--cb-accept-button-color: #fff;
--cb-accept-button-background: #f0f0f0;
}
Example 2: Styling buttons in Cookiebot style field
At the moment :root is not supported in Cookiebot custom code but you can set the variables for the wrapper where they are inherited downwards.
#CookieBanner {
--cb-button-border: 0;
--cb-button-border-radius: 0;
--cb-button-background: #0f0f0f;
--cb-button-font-weight: 500;
--cb-button-font-size: 16px;
--cb-button-font-family: sans-serif;
--cb-button-color: #fff;
--cb-button-active-color: #0f0f0f;
--cb-button-active-background: #ddd;
--cb-button-active-border: 0;
}
Notice that you can also change the base styles as you want but it can be easier to define variables in the start of the code.
Notice that in Cookiebot settings you can preview your cookie dialog. With custom templates this is only partly helpful. Yes, you can see that your HTML and JS are functional but your styling will be incomplete as some of your websites styles will be inherited (mostly fonts). So best way to test the dialog is using development/staging site with domain alias in the Domains tab.
Thanks to @samikeijonen from accessability help and testing.
| Back | FazBrowse Home | New Git URL |