dark-mode

Enforce CSS variable references for theme colors in SSR-rendered UIs.

275|17|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/egregore-labs/egregore --skill dark-mode-egregore-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dark-mode
Source: https://github.com/egregore-labs/egregore/tree/main/.claude/skills/dark-mode
Command: npx skills add https://github.com/egregore-labs/egregore --skill dark-mode-egregore-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Many browser-rendered artifacts break dark mode because server-side rendering emits resolved hex colors or library color references inline, preventing CSS variable overrides from remapping theme colors at runtime; this Skill enforces patterns and constraints so theme-sensitive colors remain overridable across renders.

Core Features & Use Cases

  • Enforce emitting theme-sensitive colors as CSS variable references so client-side and CSS overrides can remap light and dark palettes.
  • Provide concrete rules and palette tokens for React SSR, standalone HTML artifacts, Tailwind integration, markdown renderers, and email fallbacks.
  • Offer a pre-ship checklist and signature patterns: data-theme on html, head-first theme restoration to avoid flash, a three-state persistent toggle, and anti-patterns to grep out.
  • Use cases include fixing React SSR components that serialize resolved colors, converting inline-style render paths to variable-first outputs, and aligning design-system tokens for warm dark surfaces.

Quick Start

Replace theme-sensitive inline colors with CSS variable references, ensure data-theme is placed on the html element, and add a blocking head-run theme restore plus a three-state persistent toggle.

Frequently Asked Questions about dark-mode

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does dark mode break in my React SSR application?

Dark mode breaks in React SSR because server-side rendering emits resolved hex colors inline, preventing CSS variable overrides from remapping theme colors at runtime on the client. Emitting theme tokens as CSS variable references fixes this.

How do I prevent dark mode flash during server-side rendering?

To prevent dark mode flash during SSR, place data-theme on the html element and add a blocking head-run theme restoration script before paint. This ensures the correct theme applies immediately without waiting for client hydration.

Does this approach support Tailwind and markdown renderers for dark mode?

Yes, this approach supports Tailwind setups and markdown renderers. It provides concrete rules and palette tokens to ensure theme-sensitive colors emit as CSS variable references across standalone HTML artifacts and email fallbacks.

What is the best way to toggle dark mode with system preference fallback?

The best way to toggle dark mode is using a three-state persistent toggle that respects the prefers-color-scheme media query fallback. This allows users to select light, dark, or system defaults while persisting their choice across sessions.

How do I convert inline-style render paths to CSS variables for dark mode?

To convert inline-style render paths for dark mode, replace theme-sensitive inline colors with CSS variable references. This ensures client-side CSS overrides can successfully remap light and dark palettes across server-rendered components.

What anti-patterns should I grep out to fix SSR color overrides?

You should grep out inline-style render paths that serialize resolved hex colors or library color references. The Skill provides a pre-ship checklist and signature anti-patterns to ensure theme tokens remain overridable CSS variables.