Skip to content

Corner cookie card in WordPress

A floating card in the bottom-left corner, discreet yet always visible.

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-carte-coin.php
<?php
/**
 * Plugin Name: Forge, Carte de cookies en coin d'écran
 * Description: Une carte flottante dans le coin inférieur gauche, discrète mais toujours visible. Ajoute la composition « Carte de cookies en coin d'écran » à 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-carte-coin
 *
pattern.html
<!-- wp:html -->
<div data-consent-root>
        <section class="ckc" data-consent aria-labelledby="cookies-carte-coin-title">
          <h2 id="cookies-carte-coin-title" class="ckc__title">Nous respectons vos choix</h2>
          <p class="ckc__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="ckc__link">Politique de cookies</a></p>
          <fieldset id="cookies-carte-coin-panel" class="ckc__panel" data-consent-panel hidden>
            <legend class="ckc__legend">Vos choix par catégorie</legend>
            <div class="ckc__option">
              <input id="cookies-carte-coin-necessary" type="checkbox" checked disabled class="ckc__input">
              <label for="cookies-carte-coin-necessary" class="ckc__label">Cookies nécessaires<span class="ckc__desc">Panier, connexion et sécurité : toujours actifs, ils ne nécessitent pas de consentement.</span></label>
            </div>
            <div class="ckc__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-carte-coin-bg: #ffffff;
  --ck-cookies-carte-coin-text: #1e1145;
  --ck-cookies-carte-coin-muted: #5b4c86;
  --ck-cookies-carte-coin-line: #ddd3f7;
  --ck-cookies-carte-coin-btn: #6d28d9;
  --ck-cookies-carte-coin-btn-text: #ffffff;
  --ck-cookies-carte-coin-accent: #6d28d9;
  --ck-cookies-carte-coin-ring: #6d28d9;
  --demo-cookies-carte-coin-bg: #f3effe;
  --demo-cookies-carte-coin-text: #1e1145;
  --ck-cookies-carte-coin-radius: 999px;

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 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