Skip to content

Bottom cookie banner in WordPress

A full-width banner pinned to the bottom of the screen, with refuse, customize and accept on the same level.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

cookies-bandeau-bas.php
<?php
/**
 * Plugin Name: Forge, Bandeau de cookies en bas de page
 * Description: Un bandeau pleine largeur fixé en bas de l'écran, avec refus, personnalisation et acceptation au même niveau. Ajoute la composition « Bandeau de cookies en bas de page » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-cookies-bandeau-bas
 *
pattern.html
<!-- wp:html -->
<div data-consent-root>
        <section class="ckb" data-consent aria-labelledby="cookies-bandeau-bas-title">
          <h2 id="cookies-bandeau-bas-title" class="ckb__title">Nous respectons vos choix</h2>
          <p class="ckb__text">Avec votre accord, nous utilisons des cookies pour mesurer l'audience et personnaliser la publicité. Vous pouvez accepter, refuser ou choisir par catégorie, et changer d'avis à tout moment. <a href="#politique-cookies" class="ckb__link">Politique de cookies</a></p>
          <fieldset id="cookies-bandeau-bas-panel" class="ckb__panel" data-consent-panel hidden>
            <legend class="ckb__legend">Vos choix par catégorie</legend>
            <div class="ckb__option">
              <input id="cookies-bandeau-bas-necessary" type="checkbox" checked disabled class="ckb__input">
              <label for="cookies-bandeau-bas-necessary" class="ckb__label">Cookies nécessaires<span class="ckb__desc">Panier, connexion et sécurité : toujours actifs, ils ne nécessitent pas de consentement.</span></label>
            </div>
            <div class="ckb__option">
script.js
(() => {
  if (!true) return;
  const STORAGE_KEY = "forge-consent";
  // The CNIL recommends asking again after six months.
  const MAX_AGE = 1000 * 60 * 60 * 24 * 182;

  function readConsent() {
    try {
      const stored = JSON.parse(localStorage.getItem(STORAGE_KEY));
      return stored && Date.now() - Date.parse(stored.date) < MAX_AGE ? stored : null;
    } catch {
      return null;
style.css
:root {
  --ck-cookies-bandeau-bas-bg: #ffffff;
  --ck-cookies-bandeau-bas-text: #0b1b3a;
  --ck-cookies-bandeau-bas-muted: #46577a;
  --ck-cookies-bandeau-bas-line: #c9d6f2;
  --ck-cookies-bandeau-bas-btn: #1d4ed8;
  --ck-cookies-bandeau-bas-btn-text: #ffffff;
  --ck-cookies-bandeau-bas-accent: #1d4ed8;
  --ck-cookies-bandeau-bas-ring: #1d4ed8;
  --ck-cookies-bandeau-bas-radius: 10px;
  --demo-cookies-bandeau-bas-bg: #eef2fb;
  --demo-cookies-bandeau-bas-text: #0b1b3a;

Free component: copy it freely, including for commercial projects.

Cookie banners components in WordPress
  • A rounded dark bar floating at the bottom of the screen, text on the left and buttons on the right on large screens.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An understated banner with square corners and a thick rule, suited to local authorities, firms and public institutions.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A floating card in the bottom-left corner, discreet yet always visible.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A banner at the top of the page, in the document flow, that never hides content.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component