widgets
beginner
cookie
consent
banner
privacy
GDPR
Category · Widgets Difficulty Level · Beginner Published on · August 22, 2025

Animated Cookie Consent Banner

Modern cookie consent banner with smooth animations and customizable options, perfect for GDPR and privacy compliance.

#cookie #consent #banner #privacy #GDPR

Responsive Design

Yes

Dark Mode Support

No

lines

462

Browser Compatibility

Chrome · Firefox · Safari · Edge

Live Preview

Interact with the component without leaving the page.

200px

Overview

Modern cookie consent banner with smooth animations and customizable options, perfect for GDPR and privacy compliance.

How to use

  1. Copy the HTML markup into your page.
  2. Paste the CSS into your stylesheet and ensure the selectors match your markup.
  3. Paste the JavaScript and load it after the markup.
  4. Adjust spacing, colors, and text to match your design system.

Customization tips

  • Rename class names to avoid collisions with your existing CSS.
  • Replace hard-coded colors with CSS variables for theming.
  • Verify the layout at 320px, 768px, and 1024px widths.

HTML

61

lines

CSS

298

lines

JavaScript

103

lines


                <div class="cookie-consent-demo">
  <button class="show-banner-btn" id="showBannerBtn">Show Cookie Banner</button>
</div>

<div class="cookie-consent-banner" id="cookieConsentBanner">
  <div class="banner-content">
    <div class="banner-text">
      <h4>We use cookies</h4>
      <p>We use cookies to improve your experience and for marketing purposes. By continuing to use our site, you consent to our cookie policy.</p>
    </div>
    <div class="banner-actions">
      <button class="btn btn-secondary" id="rejectCookies">Reject</button>
      <button class="btn btn-primary" id="acceptCookies">Accept All</button>
      <button class="btn btn-outline" id="customizeCookies">Customize</button>
    </div>
  </div>
  
  <div class="customization-panel" id="customizationPanel">
    <div class="panel-header">
      <h4>Cookie Preferences</h4>
      <button class="close-panel" id="closePanel">×</button>
    </div>
    <div class="panel-content">
      <div class="cookie-option">
        <div class="option-info">
          <h5>Essential Cookies</h5>
          <p>Required for the website to function properly</p>
        </div>
        <label class="switch">
          <input type="checkbox" id="essentialCookies" checked disabled>
          <span class="slider"></span>
        </label>
      </div>
      
      <div class="cookie-option">
        <div class="option-info">
          <h5>Analytics Cookies</h5>
          <p>Help us understand how visitors interact with our site</p>
        </div>
        <label class="switch">
          <input type="checkbox" id="analyticsCookies" checked>
          <span class="slider"></span>
        </label>
      </div>
      
      <div class="cookie-option">
        <div class="option-info">
          <h5>Marketing Cookies</h5>
          <p>Used to track visitors across websites for personalized ads</p>
        </div>
        <label class="switch">
          <input type="checkbox" id="marketingCookies">
          <span class="slider"></span>
        </label>
      </div>
    </div>
    <div class="panel-actions">
      <button class="btn btn-primary" id="savePreferences">Save Preferences</button>
    </div>
  </div>
</div>

              
61lines
2184characters
HTMLLanguage

Browser Compatibility

Chrome

>= 50

Firefox

>= 45

Safari

>= 10

Edge

>= 15

Related Code Snippets

Explore template packs

Need larger building blocks? Browse responsive landing pages and component bundles.

Open HTML Template Library ->