Skip to content

Institutional cookie banner in WordPress

An understated banner with square corners and a thick rule, suited to local authorities, firms and public institutions.

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-institutionnel.php
<?php
/**
 * Plugin Name: Forge, Bandeau de cookies institutionnel
 * Description: Un bandeau sobre aux angles droits et au filet épais, adapté aux collectivités, cabinets et établissements publics. Ajoute la composition « Bandeau de cookies institutionnel » à 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-institutionnel
 *
pattern.html
<!-- wp:html -->
<div data-consent-root>
        <section class="cki" data-consent aria-labelledby="cookies-institutionnel-title">
          <h2 id="cookies-institutionnel-title" class="cki__title">Gestion des cookies</h2>
          <p class="cki__text">Ce site utilise des cookies nécessaires à son fonctionnement et, sous réserve de votre accord, des cookies de mesure d'audience et de publicité. Votre choix est conservé six mois. <a href="#politique-cookies" class="cki__link">Politique de cookies</a></p>
          <fieldset id="cookies-institutionnel-panel" class="cki__panel" data-consent-panel hidden>
            <legend class="cki__legend">Vos choix par catégorie</legend>
            <div class="cki__option">
              <input id="cookies-institutionnel-necessary" type="checkbox" checked disabled class="cki__input">
              <label for="cookies-institutionnel-necessary" class="cki__label">Cookies nécessaires<span class="cki__desc">Panier, connexion et sécurité : toujours actifs, ils ne nécessitent pas de consentement.</span></label>
            </div>
            <div class="cki__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-institutionnel-bg: #ffffff;
  --ck-cookies-institutionnel-text: #1c1917;
  --ck-cookies-institutionnel-muted: #57534e;
  --ck-cookies-institutionnel-line: #d6d3d1;
  --ck-cookies-institutionnel-btn: #1c1917;
  --ck-cookies-institutionnel-btn-text: #ffffff;
  --ck-cookies-institutionnel-accent: #1c1917;
  --ck-cookies-institutionnel-ring: #1c1917;
  --demo-cookies-institutionnel-bg: #f5f5f4;
  --demo-cookies-institutionnel-text: #1c1917;
  --ck-cookies-institutionnel-radius: 2px;

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
  • 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
  • A full-width banner pinned to the bottom of the screen, with refuse, customize and accept on the same level.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
Institutional cookie banner in WordPress: free code | Forge