Login & personalization · Demo 5 of 5

Dark mode that reaches the Riddle

Your site already has a light and a dark theme. One data layer push tells the Riddle which palette to use, so the quiz switches with the page: live, without a reload.

Riddle feature: change palette via data layer

Setup: about 10 minutes

Works with prefers-color-scheme

Live Riddle

Quiz · 3 questions

[[dg-themeswitch light=Daily+Gladiator+2026 dark=Daily+Gladiator+2026+Dark]]

[[dg-riddle oHQJsQSS h=560]]

Switch the page theme above. The page and the Riddle change together; “System” follows your device setting.

[[dg-inspector]]

What just happened

One push, and the Riddle follows the page.

01

The page knows the theme

Your theme switch, or the reader's device setting through prefers-color-scheme, decides light or dark.

02

The page pushes r_p

One data layer push names the Riddle palette to use: key r_p, value the palette's name.

03

The Riddle repaints itself

With “Change palette via data layer” switched on, the Riddle swaps palettes live. No reload, no second embed.

Build it yourself

The code and the Riddle settings.

1 · On your page

Call this from your own theme switch. Push the first value before the Riddle embed loads, so the quiz never flashes in the wrong theme.

window.riddleDataLayer = window.riddleDataLayer || [];

// the names of your two palettes in the Riddle Creator
var PALETTES = { light: 'Daily Gladiator 2026', dark: 'Daily Gladiator 2026 Dark' };

function setTheme(dark) {
  document.documentElement.classList.toggle('dark', dark);
  window.riddleDataLayer.push(
    { key: 'r_p', value: dark ? PALETTES.dark : PALETTES.light }
  );
}

// follow the reader's device setting
var mq = matchMedia('(prefers-color-scheme: dark)');
setTheme(mq.matches);
mq.addEventListener('change', function (e) { setTheme(e.matches); });

2 · In the Riddle Creator

Three settings, no custom code inside the Riddle.

  1. Design → Palettes: create a light and a dark palette for the Riddle, or use the built-in default:dark.
  2. Publish → Data layer: switch on “Change palette via data layer”.
  3. Embed: use the script embed code, so the data layer reaches the Riddle. Publish again after every palette change.

Good to know

Keep both themes readable.

  • The value of r_p is the palette's name as it appears in the Riddle Creator, or a built-in palette such as default:dark.
  • Check contrast in both palettes: answer buttons, correct and wrong colours, and links.
  • The same push works for any look your site switches: seasonal themes, sponsor branding, or one Riddle on several brands' sites.

Next track · Ads & revenue

Ads inside the Riddle

Open demo →
Scroll to Top