Skip to content

Design4 min read

How to Change the Accent Color Based on Time in Webflow

Learn how to automatically change your Webflow site’s accent color based on the time of day.

In this tutorial, Sandro, cofounder of Gemeos Webflow agency, shows you how to automatically change your Webflow site’s accent color based on the time of day.

Active palette by time of day — simulate a time slot

Active time slot

Loading...

Time slotNamePrimary color
0h - 6hNightIndigo #6366f1
6h - 9hMorningAmber #f59e0b
9h - 12hLate morningEmerald #10b981
14h - 18hAfternoonBlue #3b82f6
18h - 20hEveningPink #ec4899
20h - 24hDuskPurple #8b5cf6

1. Use CSS variables in Webflow

In your Webflow styles, use the var(--accent-primary), var(--accent-secondary), and var(--accent-bg) variables on your accent elements (buttons, links, colored headings, and more). The script updates them automatically on load.

2. Or use the data-accent attribute

Add data-accent="bg", data-accent="color", or data-accent="border" to any element so it picks up the current color.

(function() {
  var palettes = [
    { start: 0,  end: 6,  name: 'Night',           primary: '#6366f1', secondary: '#a5b4fc', bg: '#0f0f23' },
    { start: 6,  end: 9,  name: 'Morning',           primary: '#f59e0b', secondary: '#fcd34d', bg: '#fffbeb' },
    { start: 9,  end: 12, name: 'Late morning',  primary: '#10b981', secondary: '#6ee7b7', bg: '#ecfdf5' },
    { start: 12, end: 14, name: 'Noon',             primary: '#f97316', secondary: '#fed7aa', bg: '#fff7ed' },
    { start: 14, end: 18, name: 'Afternoon', primary: '#3b82f6', secondary: '#bfdbfe', bg: '#eff6ff' },
    { start: 18, end: 20, name: 'Evening',   primary: '#ec4899', secondary: '#fbcfe8', bg: '#fdf2f8' },
    { start: 20, end: 24, name: 'Dusk',    primary: '#8b5cf6', secondary: '#ddd6fe', bg: '#f5f3ff' },
  ];

  var hour = new Date().getHours();
  var palette = palettes.find(function(p) { return hour >= p.start && hour < p.end; }) || palettes[0];

  var root = document.documentElement;
  root.style.setProperty('--accent-primary', palette.primary);
  root.style.setProperty('--accent-secondary', palette.secondary);
  root.style.setProperty('--accent-bg', palette.bg);

  var label = document.getElementById('palette-name');
  if (label) label.textContent = palette.name + ' · ' + hour + 'h';

  document.querySelectorAll('[data-accent]').forEach(function(el) {
    var type = el.dataset.accent;
    if (type === 'bg') el.style.background = palette.primary;
    if (type === 'color') el.style.color = palette.primary;
    if (type === 'border') el.style.borderColor = palette.primary;
  });
})();

Conclusion

A site whose palette changes with the time of day creates a unique, memorable experience. Use cases:

  • Creative portfolios with a strong visual identity
  • Lifestyle or wellness brand websites
  • Landing pages with time-based storytelling

Published on May 20, 2026

Sandro DA SILVA

Growth Marketer, Webflow expert, and jack-of-all-trades. Sandro handles commercial operations, ensures projects run smoothly, and addresses marketing-related issues (SEO, Tracking, Copywriting, etc).

You're going to working with us, guaranteed

Ready to launch your business?

get a quote

Let’s f*****G GO !!