Neon Dark Cookie Consent Banner
A futuristic dark-themed cookie consent banner with neon glow effects and cyberpunk aesthetics
Responsive Design
Yes
Dark Mode Support
No
lines
741
Browser Compatibility
No
Live Preview
Interact with the component without leaving the page.
Neon Dark Cookie Consent Banner
A stunning dark-themed cookie consent banner featuring neon glow effects and cyberpunk aesthetics. Perfect for modern websites with dark themes or futuristic designs.
Features
- Cyberpunk Design: Futuristic dark theme with neon accents
- Glow Effects: Beautiful neon glow animations and hover effects
- Customizable Colors: Easy to modify neon colors and themes
- Smooth Animations: Fluid transitions and interactive feedback
- GDPR Compliant: Proper consent management and cookie categorization
- Responsive Design: Works perfectly on all devices
- Accessibility: Full keyboard navigation and screen reader support
- Local Storage: Remembers user preferences
Preview
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neon Dark Cookie Banner</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
min-height: 100vh;
color: #ffffff;
overflow-x: hidden;
}
.demo-content {
padding: 2rem;
text-align: center;
margin-top: 5rem;
}
.demo-content h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
background: linear-gradient(45deg, #00ffff, #ff00ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Cookie Banner Styles */
.neon-cookie-banner {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: rgba(10, 10, 10, 0.95);
backdrop-filter: blur(20px);
border-top: 2px solid #00ffff;
box-shadow:
0 -10px 30px rgba(0, 255, 255, 0.3),
0 0 50px rgba(0, 255, 255, 0.1),
inset 0 1px 0 rgba(255, 255, 255, 0.1);
padding: 1.5rem;
transform: translateY(100%);
transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 10000;
font-family: 'Courier New', monospace;
}
.neon-cookie-banner.show {
transform: translateY(0);
}
.neon-cookie-banner::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
#00ffff 20%,
#ff00ff 50%,
#00ffff 80%,
transparent 100%);
animation: neonPulse 3s ease-in-out infinite;
}
.cookie-content {
max-width: 1200px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr auto;
gap: 2rem;
align-items: center;
}
.cookie-text {
color: #e0e0e0;
line-height: 1.6;
}
.cookie-title {
font-size: 1.2rem;
font-weight: bold;
margin-bottom: 0.5rem;
color: #00ffff;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
.cookie-description {
font-size: 0.95rem;
opacity: 0.9;
}
.cookie-link {
color: #ff00ff;
text-decoration: none;
transition: all 0.3s ease;
text-shadow: 0 0 5px rgba(255, 0, 255, 0.3);
}
.cookie-link:hover {
color: #ffffff;
text-shadow: 0 0 15px rgba(255, 0, 255, 0.8);
}
.cookie-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.neon-btn {
padding: 0.8rem 1.5rem;
border: 2px solid;
background: transparent;
color: #ffffff;
font-family: 'Courier New', monospace;
font-size: 0.9rem;
font-weight: bold;
cursor: pointer;
position: relative;
overflow: hidden;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
min-width: 120px;
}
.neon-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s ease;
}
.neon-btn:hover::before {
left: 100%;
}
.btn-accept {
border-color: #00ff00;
color: #00ff00;
box-shadow:
0 0 20px rgba(0, 255, 0, 0.3),
inset 0 0 20px rgba(0, 255, 0, 0.1);
}
.btn-accept:hover {
background: rgba(0, 255, 0, 0.1);
box-shadow:
0 0 30px rgba(0, 255, 0, 0.6),
inset 0 0 30px rgba(0, 255, 0, 0.2);
transform: translateY(-2px);
}
.btn-decline {
border-color: #ff0040;
color: #ff0040;
box-shadow:
0 0 20px rgba(255, 0, 64, 0.3),
inset 0 0 20px rgba(255, 0, 64, 0.1);
}
.btn-decline:hover {
background: rgba(255, 0, 64, 0.1);
box-shadow:
0 0 30px rgba(255, 0, 64, 0.6),
inset 0 0 30px rgba(255, 0, 64, 0.2);
transform: translateY(-2px);
}
.btn-settings {
border-color: #ffff00;
color: #ffff00;
box-shadow:
0 0 20px rgba(255, 255, 0, 0.3),
inset 0 0 20px rgba(255, 255, 0, 0.1);
}
.btn-settings:hover {
background: rgba(255, 255, 0, 0.1);
box-shadow:
0 0 30px rgba(255, 255, 0, 0.6),
inset 0 0 30px rgba(255, 255, 0, 0.2);
transform: translateY(-2px);
}
/* Settings Modal */
.cookie-settings-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
backdrop-filter: blur(10px);
display: flex;
align-items: center;
justify-content: center;
z-index: 10001;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.cookie-settings-modal.show {
opacity: 1;
visibility: visible;
}
.settings-content {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
border: 2px solid #00ffff;
border-radius: 10px;
padding: 2rem;
max-width: 500px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
box-shadow:
0 0 50px rgba(0, 255, 255, 0.3),
inset 0 0 50px rgba(0, 255, 255, 0.1);
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}
.settings-title {
font-size: 1.3rem;
color: #00ffff;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
.close-btn {
background: none;
border: none;
color: #ff0040;
font-size: 1.5rem;
cursor: pointer;
transition: all 0.3s ease;
}
.close-btn:hover {
color: #ffffff;
text-shadow: 0 0 15px rgba(255, 0, 64, 0.8);
transform: scale(1.2);
}
.cookie-category {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 5px;
background: rgba(255, 255, 255, 0.05);
}
.category-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.category-title {
font-weight: bold;
color: #ffffff;
}
.category-description {
font-size: 0.9rem;
color: #cccccc;
line-height: 1.4;
}
/* Toggle Switch */
.toggle-switch {
position: relative;
width: 50px;
height: 25px;
background: #333;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid #555;
}
.toggle-switch.active {
background: linear-gradient(45deg, #00ffff, #ff00ff);
box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}
.toggle-switch::before {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 19px;
height: 19px;
background: #ffffff;
border-radius: 50%;
transition: all 0.3s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.toggle-switch.active::before {
transform: translateX(25px);
box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}
.settings-actions {
display: flex;
gap: 1rem;
justify-content: flex-end;
margin-top: 2rem;
padding-top: 1rem;
border-top: 1px solid rgba(0, 255, 255, 0.3);
}
/* Animations */
@keyframes neonPulse {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
@keyframes glitch {
0% { transform: translateX(0); }
20% { transform: translateX(-2px); }
40% { transform: translateX(2px); }
60% { transform: translateX(-1px); }
80% { transform: translateX(1px); }
100% { transform: translateX(0); }
}
.glitch-effect:hover {
animation: glitch 0.3s ease-in-out;
}
/* Responsive Design */
@media (max-width: 768px) {
.cookie-content {
grid-template-columns: 1fr;
gap: 1.5rem;
text-align: center;
}
.cookie-actions {
justify-content: center;
}
.neon-btn {
flex: 1;
min-width: auto;
}
.settings-content {
padding: 1.5rem;
margin: 1rem;
}
}
@media (max-width: 480px) {
.neon-cookie-banner {
padding: 1rem;
}
.cookie-actions {
flex-direction: column;
}
.neon-btn {
width: 100%;
}
}
</style>
</head>
<body>
<div class="demo-content">
<h1>Neon Dark Cookie Banner Demo</h1>
<p>Scroll down to see the futuristic cookie consent banner</p>
<button onclick="showCookieBanner()" style="margin-top: 2rem; padding: 1rem 2rem; background: linear-gradient(45deg, #00ffff, #ff00ff); border: none; color: white; cursor: pointer; border-radius: 5px;">Show Cookie Banner</button>
</div>
<!-- Cookie Banner -->
<div id="neonCookieBanner" class="neon-cookie-banner">
<div class="cookie-content">
<div class="cookie-text">
<div class="cookie-title glitch-effect">🍪 COOKIE PROTOCOL INITIATED</div>
<div class="cookie-description">
We use advanced tracking algorithms to enhance your digital experience.
<a href="#" class="cookie-link">Privacy Matrix</a> |
<a href="#" class="cookie-link">Data Protocols</a>
</div>
</div>
<div class="cookie-actions">
<button class="neon-btn btn-accept" onclick="acceptCookies()">ACCEPT</button>
<button class="neon-btn btn-decline" onclick="declineCookies()">DECLINE</button>
<button class="neon-btn btn-settings" onclick="openSettings()">SETTINGS</button>
</div>
</div>
</div>
<!-- Settings Modal -->
<div id="cookieSettingsModal" class="cookie-settings-modal">
<div class="settings-content">
<div class="settings-header">
<h3 class="settings-title">COOKIE CONFIGURATION</h3>
<button class="close-btn" onclick="closeSettings()">×</button>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Essential Protocols</span>
<div class="toggle-switch active" data-category="essential">
</div>
</div>
<div class="category-description">
Core system functions required for basic website operations. Cannot be disabled.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Analytics Matrix</span>
<div class="toggle-switch" data-category="analytics">
</div>
</div>
<div class="category-description">
Data collection algorithms for performance optimization and user behavior analysis.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Marketing Algorithms</span>
<div class="toggle-switch" data-category="marketing">
</div>
</div>
<div class="category-description">
Targeted advertising protocols and personalized content delivery systems.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Social Networks</span>
<div class="toggle-switch" data-category="social">
</div>
</div>
<div class="category-description">
Third-party social media integration and sharing capabilities.
</div>
</div>
<div class="settings-actions">
<button class="neon-btn btn-decline" onclick="saveSettings(false)">SAVE & DECLINE</button>
<button class="neon-btn btn-accept" onclick="saveSettings(true)">SAVE & ACCEPT</button>
</div>
</div>
</div>
<script>
class NeonCookieBanner {
constructor(options = {}) {
this.options = {
autoShow: true,
showDelay: 1000,
storageKey: 'neon_cookie_consent',
expiryDays: 365,
onAccept: null,
onDecline: null,
onSettingsSave: null,
...options
};
this.banner = document.getElementById('neonCookieBanner');
this.modal = document.getElementById('cookieSettingsModal');
this.consent = this.getStoredConsent();
this.init();
}
init() {
if (this.options.autoShow && !this.consent) {
setTimeout(() => this.show(), this.options.showDelay);
}
this.setupEventListeners();
this.loadSettings();
}
setupEventListeners() {
// Toggle switches
document.querySelectorAll('.toggle-switch').forEach(toggle => {
toggle.addEventListener('click', () => {
if (toggle.dataset.category !== 'essential') {
toggle.classList.toggle('active');
}
});
});
// Modal backdrop click
this.modal.addEventListener('click', (e) => {
if (e.target === this.modal) {
this.closeSettings();
}
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
this.closeSettings();
}
});
}
show() {
this.banner.classList.add('show');
// Add glitch effect on show
setTimeout(() => {
this.banner.querySelector('.cookie-title').classList.add('glitch-effect');
}, 300);
}
hide() {
this.banner.classList.remove('show');
}
accept() {
const consent = {
essential: true,
analytics: true,
marketing: true,
social: true,
timestamp: Date.now()
};
this.saveConsent(consent);
this.hide();
if (this.options.onAccept) {
this.options.onAccept(consent);
}
}
decline() {
const consent = {
essential: true,
analytics: false,
marketing: false,
social: false,
timestamp: Date.now()
};
this.saveConsent(consent);
this.hide();
if (this.options.onDecline) {
this.options.onDecline(consent);
}
}
openSettings() {
this.modal.classList.add('show');
document.body.style.overflow = 'hidden';
}
closeSettings() {
this.modal.classList.remove('show');
document.body.style.overflow = '';
}
saveSettings(acceptAll = false) {
const toggles = document.querySelectorAll('.toggle-switch');
const consent = { timestamp: Date.now() };
toggles.forEach(toggle => {
const category = toggle.dataset.category;
if (acceptAll) {
consent[category] = true;
toggle.classList.add('active');
} else {
consent[category] = toggle.classList.contains('active');
}
});
this.saveConsent(consent);
this.closeSettings();
this.hide();
if (this.options.onSettingsSave) {
this.options.onSettingsSave(consent);
}
}
loadSettings() {
if (this.consent) {
document.querySelectorAll('.toggle-switch').forEach(toggle => {
const category = toggle.dataset.category;
if (this.consent[category]) {
toggle.classList.add('active');
} else {
toggle.classList.remove('active');
}
});
}
}
saveConsent(consent) {
const expiryDate = new Date();
expiryDate.setDate(expiryDate.getDate() + this.options.expiryDays);
const consentData = {
...consent,
expiry: expiryDate.getTime()
};
localStorage.setItem(this.options.storageKey, JSON.stringify(consentData));
this.consent = consent;
}
getStoredConsent() {
try {
const stored = localStorage.getItem(this.options.storageKey);
if (stored) {
const data = JSON.parse(stored);
if (data.expiry && Date.now() < data.expiry) {
return data;
} else {
localStorage.removeItem(this.options.storageKey);
}
}
} catch (e) {
console.error('Error reading cookie consent:', e);
}
return null;
}
reset() {
localStorage.removeItem(this.options.storageKey);
this.consent = null;
this.show();
}
getConsent() {
return this.consent;
}
}
// Initialize the banner
const cookieBanner = new NeonCookieBanner({
onAccept: (consent) => {
console.log('Cookies accepted:', consent);
// Initialize analytics, marketing scripts, etc.
},
onDecline: (consent) => {
console.log('Cookies declined:', consent);
// Only load essential scripts
},
onSettingsSave: (consent) => {
console.log('Settings saved:', consent);
// Load scripts based on user preferences
}
});
// Global functions for demo
function showCookieBanner() {
cookieBanner.reset();
}
function acceptCookies() {
cookieBanner.accept();
}
function declineCookies() {
cookieBanner.decline();
}
function openSettings() {
cookieBanner.openSettings();
}
function closeSettings() {
cookieBanner.closeSettings();
}
function saveSettings(acceptAll) {
cookieBanner.saveSettings(acceptAll);
}
</script>
</body>
</html>Usage
Basic Implementation
// Initialize with default settings
const cookieBanner = new NeonCookieBanner();
// Initialize with custom options
const cookieBanner = new NeonCookieBanner({
autoShow: true,
showDelay: 2000,
storageKey: 'my_cookie_consent',
expiryDays: 180,
onAccept: (consent) => {
console.log('User accepted cookies:', consent);
// Load analytics scripts
if (consent.analytics) {
loadGoogleAnalytics();
}
// Load marketing scripts
if (consent.marketing) {
loadMarketingPixels();
}
},
onDecline: (consent) => {
console.log('User declined cookies:', consent);
// Only load essential functionality
},
onSettingsSave: (consent) => {
console.log('User saved custom settings:', consent);
// Load scripts based on specific preferences
}
});Advanced Configuration
// Custom styling and behavior
const advancedBanner = new NeonCookieBanner({
autoShow: false, // Manual control
showDelay: 0,
storageKey: 'advanced_consent',
expiryDays: 90,
// Custom callbacks
onAccept: (consent) => {
// Advanced analytics setup
initializeAdvancedTracking(consent);
},
onDecline: (consent) => {
// Minimal tracking setup
initializeEssentialOnly();
},
onSettingsSave: (consent) => {
// Granular script loading
loadScriptsBasedOnConsent(consent);
}
});
// Manual control
function showConsentBanner() {
advancedBanner.show();
}
// Check current consent status
function checkConsentStatus() {
const consent = advancedBanner.getConsent();
if (consent) {
console.log('Current consent:', consent);
} else {
console.log('No consent given yet');
}
}API Methods
Core Methods
show()- Display the cookie bannerhide()- Hide the cookie banneraccept()- Accept all cookies and hide bannerdecline()- Decline optional cookies and hide bannerreset()- Clear stored consent and show banner again
Settings Management
openSettings()- Open the settings modalcloseSettings()- Close the settings modalsaveSettings(acceptAll)- Save current settingsloadSettings()- Load and apply stored settings
Data Management
getConsent()- Get current consent objectsaveConsent(consent)- Save consent to storagegetStoredConsent()- Retrieve consent from storage
Customization Options
Visual Customization
- Neon Colors: Modify CSS custom properties for different color schemes
- Glow Effects: Adjust box-shadow values for intensity
- Animations: Customize transition timing and effects
- Typography: Change font families and sizes
Functional Configuration
- Auto Display: Control automatic banner appearance
- Storage Duration: Set cookie consent expiry period
- Delay Settings: Configure show/hide timing
- Callback Functions: Custom handlers for user actions
Accessibility Features
- Keyboard Navigation: Full keyboard support with focus indicators
- Screen Reader Support: Proper ARIA labels and descriptions
- High Contrast: Enhanced visibility for accessibility
- Focus Management: Proper focus trapping in modal
Browser Compatibility
- Chrome 60+
- Firefox 55+
- Safari 12+
- Edge 79+
- Mobile browsers (iOS Safari 12+, Chrome Mobile 60+)
License
MIT License - feel free to use in personal and commercial projects.
HTML
711
lines
CSS
1
lines
JavaScript
29
lines
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neon Dark Cookie Banner</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
min-height: 100vh;
color: #ffffff;
overflow-x: hidden;
}
.demo-content {
padding: 2rem;
text-align: center;
margin-top: 5rem;
}
.demo-content h1 {
font-size: 2.5rem;
margin-bottom: 1rem;
background: linear-gradient(45deg, #00ffff, #ff00ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
/* Cookie Banner Styles */
.neon-cookie-banner {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: rgba(10, 10, 10, 0.95);
backdrop-filter: blur(20px);
border-top: 2px solid #00ffff;
box-shadow:
0 -10px 30px rgba(0, 255, 255, 0.3),
0 0 50px rgba(0, 255, 255, 0.1),
inset 0 1px 0 rgba(255, 255, 255, 0.1);
padding: 1.5rem;
transform: translateY(100%);
transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
z-index: 10000;
font-family: 'Courier New', monospace;
}
.neon-cookie-banner.show {
transform: translateY(0);
}
.neon-cookie-banner::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 1px;
background: linear-gradient(90deg,
transparent 0%,
#00ffff 20%,
#ff00ff 50%,
#00ffff 80%,
transparent 100%);
animation: neonPulse 3s ease-in-out infinite;
}
.cookie-content {
max-width: 1200px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr auto;
gap: 2rem;
align-items: center;
}
.cookie-text {
color: #e0e0e0;
line-height: 1.6;
}
.cookie-title {
font-size: 1.2rem;
font-weight: bold;
margin-bottom: 0.5rem;
color: #00ffff;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
.cookie-description {
font-size: 0.95rem;
opacity: 0.9;
}
.cookie-link {
color: #ff00ff;
text-decoration: none;
transition: all 0.3s ease;
text-shadow: 0 0 5px rgba(255, 0, 255, 0.3);
}
.cookie-link:hover {
color: #ffffff;
text-shadow: 0 0 15px rgba(255, 0, 255, 0.8);
}
.cookie-actions {
display: flex;
gap: 1rem;
flex-wrap: wrap;
}
.neon-btn {
padding: 0.8rem 1.5rem;
border: 2px solid;
background: transparent;
color: #ffffff;
font-family: 'Courier New', monospace;
font-size: 0.9rem;
font-weight: bold;
cursor: pointer;
position: relative;
overflow: hidden;
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
min-width: 120px;
}
.neon-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s ease;
}
.neon-btn:hover::before {
left: 100%;
}
.btn-accept {
border-color: #00ff00;
color: #00ff00;
box-shadow:
0 0 20px rgba(0, 255, 0, 0.3),
inset 0 0 20px rgba(0, 255, 0, 0.1);
}
.btn-accept:hover {
background: rgba(0, 255, 0, 0.1);
box-shadow:
0 0 30px rgba(0, 255, 0, 0.6),
inset 0 0 30px rgba(0, 255, 0, 0.2);
transform: translateY(-2px);
}
.btn-decline {
border-color: #ff0040;
color: #ff0040;
box-shadow:
0 0 20px rgba(255, 0, 64, 0.3),
inset 0 0 20px rgba(255, 0, 64, 0.1);
}
.btn-decline:hover {
background: rgba(255, 0, 64, 0.1);
box-shadow:
0 0 30px rgba(255, 0, 64, 0.6),
inset 0 0 30px rgba(255, 0, 64, 0.2);
transform: translateY(-2px);
}
.btn-settings {
border-color: #ffff00;
color: #ffff00;
box-shadow:
0 0 20px rgba(255, 255, 0, 0.3),
inset 0 0 20px rgba(255, 255, 0, 0.1);
}
.btn-settings:hover {
background: rgba(255, 255, 0, 0.1);
box-shadow:
0 0 30px rgba(255, 255, 0, 0.6),
inset 0 0 30px rgba(255, 255, 0, 0.2);
transform: translateY(-2px);
}
/* Settings Modal */
.cookie-settings-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.8);
backdrop-filter: blur(10px);
display: flex;
align-items: center;
justify-content: center;
z-index: 10001;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
}
.cookie-settings-modal.show {
opacity: 1;
visibility: visible;
}
.settings-content {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
border: 2px solid #00ffff;
border-radius: 10px;
padding: 2rem;
max-width: 500px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
box-shadow:
0 0 50px rgba(0, 255, 255, 0.3),
inset 0 0 50px rgba(0, 255, 255, 0.1);
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
padding-bottom: 1rem;
border-bottom: 1px solid rgba(0, 255, 255, 0.3);
}
.settings-title {
font-size: 1.3rem;
color: #00ffff;
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}
.close-btn {
background: none;
border: none;
color: #ff0040;
font-size: 1.5rem;
cursor: pointer;
transition: all 0.3s ease;
}
.close-btn:hover {
color: #ffffff;
text-shadow: 0 0 15px rgba(255, 0, 64, 0.8);
transform: scale(1.2);
}
.cookie-category {
margin-bottom: 1.5rem;
padding: 1rem;
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 5px;
background: rgba(255, 255, 255, 0.05);
}
.category-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.category-title {
font-weight: bold;
color: #ffffff;
}
.category-description {
font-size: 0.9rem;
color: #cccccc;
line-height: 1.4;
}
/* Toggle Switch */
.toggle-switch {
position: relative;
width: 50px;
height: 25px;
background: #333;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
border: 1px solid #555;
}
.toggle-switch.active {
background: linear-gradient(45deg, #00ffff, #ff00ff);
box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}
.toggle-switch::before {
content: '';
position: absolute;
top: 2px;
left: 2px;
width: 19px;
height: 19px;
background: #ffffff;
border-radius: 50%;
transition: all 0.3s ease;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.toggle-switch.active::before {
transform: translateX(25px);
box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}
.settings-actions {
display: flex;
gap: 1rem;
justify-content: flex-end;
margin-top: 2rem;
padding-top: 1rem;
border-top: 1px solid rgba(0, 255, 255, 0.3);
}
/* Animations */
@keyframes neonPulse {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
@keyframes glitch {
0% { transform: translateX(0); }
20% { transform: translateX(-2px); }
40% { transform: translateX(2px); }
60% { transform: translateX(-1px); }
80% { transform: translateX(1px); }
100% { transform: translateX(0); }
}
.glitch-effect:hover {
animation: glitch 0.3s ease-in-out;
}
/* Responsive Design */
@media (max-width: 768px) {
.cookie-content {
grid-template-columns: 1fr;
gap: 1.5rem;
text-align: center;
}
.cookie-actions {
justify-content: center;
}
.neon-btn {
flex: 1;
min-width: auto;
}
.settings-content {
padding: 1.5rem;
margin: 1rem;
}
}
@media (max-width: 480px) {
.neon-cookie-banner {
padding: 1rem;
}
.cookie-actions {
flex-direction: column;
}
.neon-btn {
width: 100%;
}
}
</style>
</head>
<body>
<div class="demo-content">
<h1>Neon Dark Cookie Banner Demo</h1>
<p>Scroll down to see the futuristic cookie consent banner</p>
<button onclick="showCookieBanner()" style="margin-top: 2rem; padding: 1rem 2rem; background: linear-gradient(45deg, #00ffff, #ff00ff); border: none; color: white; cursor: pointer; border-radius: 5px;">Show Cookie Banner</button>
</div>
<!-- Cookie Banner -->
<div id="neonCookieBanner" class="neon-cookie-banner">
<div class="cookie-content">
<div class="cookie-text">
<div class="cookie-title glitch-effect">🍪 COOKIE PROTOCOL INITIATED</div>
<div class="cookie-description">
We use advanced tracking algorithms to enhance your digital experience.
<a href="#" class="cookie-link">Privacy Matrix</a> |
<a href="#" class="cookie-link">Data Protocols</a>
</div>
</div>
<div class="cookie-actions">
<button class="neon-btn btn-accept" onclick="acceptCookies()">ACCEPT</button>
<button class="neon-btn btn-decline" onclick="declineCookies()">DECLINE</button>
<button class="neon-btn btn-settings" onclick="openSettings()">SETTINGS</button>
</div>
</div>
</div>
<!-- Settings Modal -->
<div id="cookieSettingsModal" class="cookie-settings-modal">
<div class="settings-content">
<div class="settings-header">
<h3 class="settings-title">COOKIE CONFIGURATION</h3>
<button class="close-btn" onclick="closeSettings()">×</button>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Essential Protocols</span>
<div class="toggle-switch active" data-category="essential">
</div>
</div>
<div class="category-description">
Core system functions required for basic website operations. Cannot be disabled.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Analytics Matrix</span>
<div class="toggle-switch" data-category="analytics">
</div>
</div>
<div class="category-description">
Data collection algorithms for performance optimization and user behavior analysis.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Marketing Algorithms</span>
<div class="toggle-switch" data-category="marketing">
</div>
</div>
<div class="category-description">
Targeted advertising protocols and personalized content delivery systems.
</div>
</div>
<div class="cookie-category">
<div class="category-header">
<span class="category-title">Social Networks</span>
<div class="toggle-switch" data-category="social">
</div>
</div>
<div class="category-description">
Third-party social media integration and sharing capabilities.
</div>
</div>
<div class="settings-actions">
<button class="neon-btn btn-decline" onclick="saveSettings(false)">SAVE & DECLINE</button>
<button class="neon-btn btn-accept" onclick="saveSettings(true)">SAVE & ACCEPT</button>
</div>
</div>
</div>
<script>
class NeonCookieBanner {
constructor(options = {}) {
this.options = {
autoShow: true,
showDelay: 1000,
storageKey: 'neon_cookie_consent',
expiryDays: 365,
onAccept: null,
onDecline: null,
onSettingsSave: null,
...options
};
this.banner = document.getElementById('neonCookieBanner');
this.modal = document.getElementById('cookieSettingsModal');
this.consent = this.getStoredConsent();
this.init();
}
init() {
if (this.options.autoShow && !this.consent) {
setTimeout(() => this.show(), this.options.showDelay);
}
this.setupEventListeners();
this.loadSettings();
}
setupEventListeners() {
// Toggle switches
document.querySelectorAll('.toggle-switch').forEach(toggle => {
toggle.addEventListener('click', () => {
if (toggle.dataset.category !== 'essential') {
toggle.classList.toggle('active');
}
});
});
// Modal backdrop click
this.modal.addEventListener('click', (e) => {
if (e.target === this.modal) {
this.closeSettings();
}
});
// Keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
this.closeSettings();
}
});
}
show() {
this.banner.classList.add('show');
// Add glitch effect on show
setTimeout(() => {
this.banner.querySelector('.cookie-title').classList.add('glitch-effect');
}, 300);
}
hide() {
this.banner.classList.remove('show');
}
accept() {
const consent = {
essential: true,
analytics: true,
marketing: true,
social: true,
timestamp: Date.now()
};
this.saveConsent(consent);
this.hide();
if (this.options.onAccept) {
this.options.onAccept(consent);
}
}
decline() {
const consent = {
essential: true,
analytics: false,
marketing: false,
social: false,
timestamp: Date.now()
};
this.saveConsent(consent);
this.hide();
if (this.options.onDecline) {
this.options.onDecline(consent);
}
}
openSettings() {
this.modal.classList.add('show');
document.body.style.overflow = 'hidden';
}
closeSettings() {
this.modal.classList.remove('show');
document.body.style.overflow = '';
}
saveSettings(acceptAll = false) {
const toggles = document.querySelectorAll('.toggle-switch');
const consent = { timestamp: Date.now() };
toggles.forEach(toggle => {
const category = toggle.dataset.category;
if (acceptAll) {
consent[category] = true;
toggle.classList.add('active');
} else {
consent[category] = toggle.classList.contains('active');
}
});
this.saveConsent(consent);
this.closeSettings();
this.hide();
if (this.options.onSettingsSave) {
this.options.onSettingsSave(consent);
}
}
loadSettings() {
if (this.consent) {
document.querySelectorAll('.toggle-switch').forEach(toggle => {
const category = toggle.dataset.category;
if (this.consent[category]) {
toggle.classList.add('active');
} else {
toggle.classList.remove('active');
}
});
}
}
saveConsent(consent) {
const expiryDate = new Date();
expiryDate.setDate(expiryDate.getDate() + this.options.expiryDays);
const consentData = {
...consent,
expiry: expiryDate.getTime()
};
localStorage.setItem(this.options.storageKey, JSON.stringify(consentData));
this.consent = consent;
}
getStoredConsent() {
try {
const stored = localStorage.getItem(this.options.storageKey);
if (stored) {
const data = JSON.parse(stored);
if (data.expiry && Date.now() < data.expiry) {
return data;
} else {
localStorage.removeItem(this.options.storageKey);
}
}
} catch (e) {
console.error('Error reading cookie consent:', e);
}
return null;
}
reset() {
localStorage.removeItem(this.options.storageKey);
this.consent = null;
this.show();
}
getConsent() {
return this.consent;
}
}
// Initialize the banner
const cookieBanner = new NeonCookieBanner({
onAccept: (consent) => {
console.log('Cookies accepted:', consent);
// Initialize analytics, marketing scripts, etc.
},
onDecline: (consent) => {
console.log('Cookies declined:', consent);
// Only load essential scripts
},
onSettingsSave: (consent) => {
console.log('Settings saved:', consent);
// Load scripts based on user preferences
}
});
// Global functions for demo
function showCookieBanner() {
cookieBanner.reset();
}
function acceptCookies() {
cookieBanner.accept();
}
function declineCookies() {
cookieBanner.decline();
}
function openSettings() {
cookieBanner.openSettings();
}
function closeSettings() {
cookieBanner.closeSettings();
}
function saveSettings(acceptAll) {
cookieBanner.saveSettings(acceptAll);
}
</script>
</body>
</html>