Cookie Banner Widget Demo

GDPR/CCPA compliant cookie consent banner. No dependencies, mobile responsive, accessible.

Demo 1: Basic Cookie Banner

Simple cookie consent with accept/decline buttons.

<div data-tradecalcs-cookie-banner
     data-message="We use cookies to improve your experience."
     data-accept-text="Accept"
     data-decline-text="Decline">
</div>

Current Status:

Demo 2: With Privacy Policy Link

Include a link to your privacy policy for full compliance.

<div data-tradecalcs-cookie-banner
     data-message="We use cookies to improve your experience and analyze site traffic."
     data-accept-text="Accept All"
     data-decline-text="Reject All"
     data-policy-url="/privacy"
     data-policy-text="Privacy Policy">
</div>

Demo 3: Custom Message for Contractors

Customize the message to fit your business.

<div data-tradecalcs-cookie-banner
     data-message="This site uses cookies to remember your preferences and show you relevant project examples."
     data-accept-text="Got it"
     data-decline-text="No thanks"
     data-policy-url="/privacy"
     data-policy-text="Learn more">
</div>

📦 Installation

Step 1: Add the CSS and JavaScript files to your HTML:

<!-- Add to <head> -->
<link rel="stylesheet" href="/widgets/cookie-banner.css">

<!-- Add before closing </body> -->
<script src="/widgets/cookie-banner.js"></script>

Step 2: Add the banner to your page (typically in footer or just before </body>):

<div data-tradecalcs-cookie-banner
     data-message="We use cookies to improve your experience."
     data-accept-text="Accept"
     data-decline-text="Decline"
     data-policy-url="/privacy"
     data-policy-text="Privacy Policy">
</div>

Note: Replace d790a6cc.tradecalcs.pages.dev with tradecalcs.com once the production domain is configured.

Configuration Options

Data Attributes

CSS Custom Properties

JavaScript API

// Initialize all banners manually
TradeCalcsCookieBanner.init();

// Initialize specific banner
const element = document.querySelector('[data-tradecalcs-cookie-banner]');
TradeCalcsCookieBanner.initElement(element);

// Get consent status
const consent = TradeCalcsCookieBanner.getConsent();
// Returns: true (accepted), false (declined), null (no choice yet)

// Clear consent (for testing or user request)
TradeCalcsCookieBanner.clearConsent();

// Listen for consent response
document.addEventListener('tc-cookie-consent-changed', function(e) {
  console.log('Consent changed:', e.detail);
  // { accepted: true/false, timestamp: "2026-05-20T..." }
});

Features

GDPR/CCPA Compliance

This widget helps you comply with cookie consent laws:

Best Practices

Implementation Example

// Check consent before loading analytics
const consent = TradeCalcsCookieBanner.getConsent();

if (consent === true) {
  // User accepted - load analytics
  loadGoogleAnalytics();
  loadFacebookPixel();
} else if (consent === false) {
  // User declined - don't load analytics
  console.log('Analytics disabled by user choice');
} else {
  // No choice yet - wait for response
  document.addEventListener('tc-cookie-consent-changed', function(e) {
    if (e.detail.accepted) {
      loadGoogleAnalytics();
      loadFacebookPixel();
    }
  });
}

Use Cases

Browser Support

Works in all modern browsers with localStorage:

Our Network

Cali Dream Construction RemodelSD Escondido Home Remodeling

Built by Cali Dream Construction · CSLB #1054602

Get a Custom Quote — Contact TradeCalcs