Glassmorphism Cookie Consent Banner

Intermediate

A modern, elegant cookie consent banner with glassmorphism design featuring frosted glass effects, smooth animations, and responsive layout.

Live Preview

Code Implementation

HTML
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Glassmorphism Cookie Banner</title>
</head>
<body>
    <!-- Demo background -->
    <div class="demo-background">
        <div class="bg-gradient"></div>
        <div class="bg-shapes">
            <div class="shape shape-1"></div>
            <div class="shape shape-2"></div>
            <div class="shape shape-3"></div>
        </div>
    </div>

    <!-- Main content -->
    <div class="main-content">
        <h1>Glassmorphism Cookie Banner Demo</h1>
        <p>This is a demo page to showcase the beautiful glassmorphism cookie consent banner.</p>
        <button class="demo-btn" onclick="showCookieBanner()">Show Cookie Banner</button>
    </div>

    <!-- Cookie Consent Banner -->
    <div id="cookieBanner" class="cookie-banner" role="dialog" aria-labelledby="cookie-title" aria-describedby="cookie-description">
        <div class="cookie-content">
            <div class="cookie-icon">
                <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor"/>
                </svg>
            </div>
            <div class="cookie-text">
                <h3 id="cookie-title">We use cookies</h3>
                <p id="cookie-description">
                    We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. 
                    By clicking "Accept All", you consent to our use of cookies.
                </p>
            </div>
            <div class="cookie-actions">
                <button class="btn btn-secondary" onclick="declineCookies()" aria-label="Decline cookies">
                    <span>Decline</span>
                </button>
                <button class="btn btn-primary" onclick="acceptCookies()" aria-label="Accept all cookies">
                    <span>Accept All</span>
                    <div class="btn-shine"></div>
                </button>
            </div>
        </div>
        <button class="cookie-close" onclick="hideCookieBanner()" aria-label="Close cookie banner">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 4L4 12M4 4l8 8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
            </svg>
        </button>
    </div>

    <!-- Backdrop -->
    <div id="cookieBackdrop" class="cookie-backdrop"></div>
</body>
</html>

Snippet Features

Responsive Design: Yes
Dark Mode Support: No
Category: interactive
Difficulty Level: Intermediate