A practical guide to syncing CSS custom property theme colors (light/dark mode) with HTML canvas rendering. The technique uses `window.getComputedStyle()` to read CSS custom properties into a JavaScript theme object, then attaches a `MediaQueryList` event listener to `prefers-color-scheme` so canvas colors automatically update whenever the user switches themes.

3m read timeFrom aaron-gustafson.com
Post cover image
Table of contents
# The CSS Setup# Applying the Theme to Canvas# Keeping Things in Sync
3 Impressions