Building a Dynamic Dark Mode Engine for CSS Color 4

Most dark mode browser extensions rely on naive filter: invert(1) hacks or legacy rgb()/hsl() regexes that fall apart on modern UI frameworks like Tailwind v4 and Cloudflare Kumo.

While building GruvDark, solving modern dashboards required three distinct subsystems:

  1. Native CSS Color 4 Remapping: Parsing oklch(), oklab(), and color() spaces directly into perceptual lightness so surfaces map cleanly onto Gruvbox (#1d2021, #282828, #ebdbb2).
  2. Ring Box-Shadow Preservation: Detecting zero-blur box-shadow hairlines (remapRingBoxShadow()) used as card and table borders instead of stripping them out.
  3. Smart Canvas Sampling: Inspecting canvas pixel luminance (processCanvas()) before inverting light-mode ECharts while leaving dark canvases and WebGL contexts untouched.
Related
Javascript · Css · Gruvbox · Web