Dark Mode for an Onboarding Checklist Widget
An embedded checklist that ignores the host page's theme is the most visible unstyled thing on a dark screen. What actually needs theming, and what doesn't.
An onboarding checklist is almost always the newest piece of UI on a page that has existed for a while, which means it's also the piece most likely to have been built, tested and shipped in light mode only. That's invisible until a user running the host app in dark mode opens the checklist and gets a bright white card sitting on a dark background — the most visually loud thing on the screen, for exactly the wrong reason. A widget is supposed to blend into the product it's embedded in. Getting that wrong on day one isn't a cosmetic bug; it's the first thing a dark-mode user sees of the feature, and it reads as unfinished.
The widget doesn't know the host's theme — it has to be told
An embedded widget runs in an iframe or a shadow-DOM-scoped div, which means it doesn't inherit the host page's CSS variables or `prefers-color-scheme` the way a component built directly into the app would. The host page being in dark mode tells the browser nothing about what's inside the widget's own isolated styling context. The widget has to be told explicitly, either by reading the signal itself or by the integration passing it down:
<div
data-getting-started-widget
data-theme="dark"
data-api-key="..."
></div>
Reading `prefers-color-scheme: dark` from `window.matchMedia` inside the widget is a reasonable default when the integration doesn't pass a value, but it's a default, not a substitute — a product with its own light/dark toggle that's independent of the OS setting (a common pattern) will have users whose OS says light and app says dark, and the widget should follow the app, not the OS, when the app has an opinion.
Three things actually need re-theming, not everything
Dark mode gets treated as an all-or-nothing palette swap, but a checklist widget has a small surface area and most of it doesn't change meaning between themes — only three things do. Background and card surface need a dark equivalent, obviously, or the white-card-on-dark-page problem persists. Text and icon contrast needs its own pass rather than a simple invert, because inverting a light palette often produces colors that pass a casual look but fail actual contrast ratios against the new background — a muted gray that reads fine on white can disappear on near-black. And the completion state's accent color (the checkmark, the progress bar fill) needs to stay recognizable as "done" in both themes; a green that works on white can look identical to a different semantic color on a dark surface depending on the rest of the host app's dark palette. Borders, shadows and the step icons that aren't state-dependent generally don't need separate treatment beyond the surface and text changes already covering them.
CSS variables over a second stylesheet
The lowest-maintenance way to support both themes is a small set of CSS custom properties scoped to the widget's root, swapped by the `data-theme` attribute, rather than two complete stylesheets maintained in parallel:
[data-theme="light"] { --gs-bg: #ffffff; --gs-text: #1a1a1a; --gs-accent: #16a34a; }
[data-theme="dark"] { --gs-bg: #18181b; --gs-text: #e4e4e7; --gs-accent: #22c55e; }
Two stylesheets drift apart the moment someone fixes a spacing bug in one and forgets the other; one stylesheet with theme-scoped variables physically cannot drift on anything but the variables themselves, because every other rule only exists once.
A theme the host app changes at runtime
A user flipping their app's theme toggle while the checklist is open is the case that breaks a widget built assuming the theme is set once at load. If `data-theme` is only read when the widget initializes, a runtime toggle leaves the widget stuck on the theme the page had when it mounted until the next full reload — a small but visible inconsistency that makes the widget look like a separate, unmaintained thing bolted onto the page rather than part of it. Watching the attribute (a `MutationObserver` on `data-theme`, or re-reading `matchMedia` on its `change` event if that's the signal source) and re-applying the CSS variables without re-mounting the whole widget keeps it in sync with zero perceived lag.
What to measure instead of assuming it matters
Whether dark mode support changes completion or dismissal rates isn't something to assume either way without data this site doesn't have yet: the comparison that would answer it is completion rate for sessions where the host page is in dark mode versus light, segmented by whether the widget itself was correctly themed at the time (a before/after around this kind of fix, or a flag during rollout). A widget that's visually broken in one theme and that theme is rare in the user base might not move the aggregate number much even though it's embarrassing on sight; a widget broken in the theme that's the majority for a given product's users is a different story. See onboarding widget performance for the other "it has to not stand out" constraint, and the embed reference for the full list of `data-*` attributes the widget reads at mount.