Implementing dark mode on a personal website turned into a full UI system refactor. The key lessons: hardcoded colors had to be replaced with semantic CSS variables (e.g., --text-primary), pure black/white contrast is too harsh so grey shades work better, Tailwind's typography plugin needed explicit variable mapping, code syntax highlighting required two themes switched dynamically, SVG diagrams needed separate versions per mode, and a flash-of-wrong-theme bug required moving theme detection before browser render. Dark mode isn't a surface-level toggle — it's a cross-cutting system concern that every UI layer must support intentionally.

5m read timeFrom code.likeagirl.io
Post cover image
Table of contents
The first problem: hardcoded colorsDark mode is not blackEvery surface breaks differentlyTypography (Tailwind)Get Marsha Teo ’s stories in your inboxCode syntax highlightingImagesThe problem wasn’t only styling — it was timing tooWhat this changed for meIf you’re implementing dark mode
2 Comments

Sort: