A sleek dark app, then a blinding white date picker flashes up. This skill audits your live DOM in dark mode, measures real alpha-composited contrast, and seals every light-mode leak while keeping light mode intact.

billing.acme.co/payouts

Schedule next payout

Wire transfer to Silicon Valley Bank ···4821

$14,280.00
Dec 14, 2026▾
USD · Instant▾
December 2026‹ ›
billing.acme.co/payouts

Schedule next payout

Wire transfer to Silicon Valley Bank ···4821

$14,280.00
Dec 14, 2026▾
USD · Instant▾
December 2026‹ ›
color-scheme: normal
color-scheme: dark

Drag the divider across the OS calendar, select dropdown, and scrollbar rail

Install

Copy the skill URL or pick your coding agent below. One file, no npm packages, MIT licensed.

https://hairlineui.com/skills/fix-dark-leaks.md

Claude Code

Works in: Claude Code CLI, VS Code & JetBrains extensions, and Claude Desktop Code tab

Run this once inside your project (or use ~/.claude/skills for every project).

terminal
mkdir -p .claude/skills/fix-dark-leaks && curl -sL https://hairlineui.com/skills/fix-dark-leaks.md -o .claude/skills/fix-dark-leaks/SKILL.md

Restart or type /fix-dark-leaks in Claude Code. It scans the repo, runs the Chromium verifier, and reports every fix.

  • Zero redesign risk. Leaves your layout, brand colours, typography and component library alone.

  • Verified, not guessed. Every skill pairs static checks with a standalone verifier that proves the before and after counts.

  • No lock-in, MIT. Plain markdown plus a standalone script. Works on React, Next.js, Vue, Svelte, Astro or plain HTML.

What it catches

Every rule targets an objective browser defect and pairs a detection check with a root-cause fix.

  1. White OS date pickers, selects, autofill & scrollbars

    Without color-scheme: dark, browsers keep painting scrollbars, <select> menus, date/time calendars, and Chrome autofill boxes blinding white.

    Sets color-scheme: dark on the dark root selector and styles :-webkit-autofill to match your dark input surface.

  2. White flash on reload (pre-hydration FOUC)

    Reading localStorage inside useEffect paints a full white frame for 100–250ms before React hydrates.

    Adds a tiny synchronous inline script in <head> that sets your exact dark class and colorScheme before first paint.

  3. Hardcoded bg-white inside modals & empty states

    Popovers, tooltips, modals, and secondary states often ship with literal bg-white, text-gray-900, or #fff that only show up when triggered.

    Migrates leaks to your semantic tokens (bg-card, bg-popover, text-foreground) or paired dark: utilities so light mode stays untouched.

  4. Unpaired status colors failing contrast

    Classes like text-red-600 and bg-amber-50 read cleanly on white but drop below 3:1 contrast or glow like headlights on dark cards.

    Pairs every status text and badge with calibrated dark: steps (dark:text-red-400, dark:bg-red-500/15) passing WCAG AA.

  5. Black SVGs, vanishing borders & Tailwind v4 dark:

    Monochrome #000 icons vanish on dark headers, subtle borders disappear, and missing @custom-variant dark breaks class-based dark mode in Tailwind v4.

    Converts monochrome SVG fills to currentColor, verifies border visibility, and checks Tailwind v4 dark variant wiring.

Chromium verifier

Opens every route with prefers-color-scheme: dark, captures first-paint background luminance before hydration to catch white FOUC flashes, checks computed color-scheme on <html> and native date/time/select controls, flags hardcoded bright surfaces, computes true alpha-composited WCAG 2.1 contrast on every visible text node, and detects dark-on-dark monochrome SVGs.

curl -sL https://hairlineui.com/skills/fix-dark-leaks-check.mjs -o /tmp/fix-dark-leaks-check.mjsnode /tmp/fix-dark-leaks-check.mjs http://localhost:3000 --routes /,/settings,/login

Then just run it

Run it on a single page while building, or across your main routes before shipping.

  • “Run /fix-dark-leaks across the app — seal native date pickers, scrollbars, and the reload flash without changing light mode.”

  • “Audit /settings and /billing with /fix-dark-leaks and fix every contrast failure below 4.5:1.”

  • “Find every hardcoded bg-white, text-gray-900 and black SVG leaking into dark mode using /fix-dark-leaks.”

Source

Read every line before installing. Both files are plain text under the MIT licence.

---name: fix-dark-leaksdescription: Find and seal every dark-mode leak in your web app: blinding white native date pickers, selects, and scrollbars (missing color-scheme: dark), white flash on reload (FOUC), hardcoded bg-white/text-black/#hex inside modals and empty states, low-contrast unpaired status colors, disappearing borders, and black SVGs on dark surfaces. Works on any React, Next.js, Vue, Svelte, Astro, or plain CSS/Tailwind app.license: MITmetadata:  author: Hairline UI  url: https://hairlineui.com/skills/fix-dark-leaks  version: "1.0.0"---# /fix-dark-leaksFind and seal every light-mode leak in your app's dark theme: blinding white OS date pickers, selects, and scrollbars, white reload flashes, hardcoded white cards or tooltips, unreadable status colors, invisible borders, and black SVGs that disappear into dark backgrounds.This skill is **zero-redesign and zero-lock-in**. It keeps your existing color system, brand palette, and layout intact, fixing every leak with native CSS and your project's own dark tokens.## Guardrails (never break these)- **Keep light mode intact.** Never replace a light-mode class with a dark-only value (`bg-white` → `bg-zinc-950` breaks light mode!). Always replace with a semantic token (`bg-background`, `bg-card`, `bg-popover`, `text-foreground`) or add a `dark:` pair (`bg-white dark:bg-zinc-900`).- **Do not break intentional high-contrast surfaces** such as QR codes, print previews, white logos on brand badges, or primary buttons whose contrast is intentional.- **Respect the project's dark-mode mechanism:** detect whether the app uses a `.dark` class, `[data-theme="dark"]`, or `@media (prefers-color-scheme: dark)` before writing a single rule.- **Never add external dependencies or UI libraries.** Every fix is pure CSS, HTML, and your existing tokens.- **Never report a fix you did not verify in Chromium.**---## Step 1 — Measure the baseline (browser + source scan)### 1A. Run the Chromium dark-leaks verifier (recommended)With your local dev server running, fetch and run the verifier across your key routes in dark mode:```bashcurl -sL https://hairlineui.com/skills/fix-dark-leaks-check.mjs -o /tmp/fix-dark-leaks-check.mjsnode /tmp/fix-dark-leaks-check.mjs http://localhost:3000 --routes /,/settings,/login```*(If your app requires clicking a toggle instead of following `prefers-color-scheme: dark`, pass `--toggle "button[aria-label*='theme' i]"` or `--dark-class .dark`.)*Save the baseline numbers: reload FOUC flash, missing `color-scheme: dark` controls, bright surface leaks, WCAG contrast failures, and dark-on-dark invisible icons/borders.### 1B. Static source scanRun these from the project root and record the hit counts:```bashG='-g *.{tsx,jsx,ts,js,vue,svelte,astro,html} -g !node_modules -g !.next -g !dist'# 1. Check whether color-scheme: dark is declared anywhere in CSSrg -n 'color-scheme\s*:\s*dark' -g '*.css' -g '!node_modules' -g '!.next' -g '!dist' .# 2. Hardcoded light backgrounds without a dark: counterpart on the same linerg -n '\b(bg-white|bg-slate-50|bg-gray-50|bg-zinc-50|bg-neutral-50|bg-stone-50)\b' $G . | rg -v '\bdark:bg-'# 3. Hardcoded dark text without a dark: counterpart on the same linerg -n '\b(text-black|text-slate-900|text-gray-900|text-zinc-900|text-neutral-900|text-gray-800|text-slate-800)\b' $G . | rg -v '\bdark:text-'# 4. Hardcoded light borders without a dark: counterpartrg -n '\b(border-gray-200|border-slate-200|border-zinc-200|border-neutral-200|border-gray-300)\b' $G . | rg -v '\bdark:border-'# 5. Unpaired saturated status text/backgrounds that fail contrast on dark surfacesrg -n '\btext-(red|rose|emerald|green|amber|blue|indigo)-(600|700|800)\b' $G . | rg -v '\bdark:text-'rg -n '\bbg-(red|rose|emerald|green|amber|blue|indigo)-(50|100)\b' $G . | rg -v '\bdark:bg-'# 6. Raw hex fills/strokes in SVGs and inline styles (#000 / #fff / #111 / #333)rg -n '(fill|stroke|color|background)\s*[:=]\s*["\x27]?#(000(000)?|fff(fff)?|111(111)?|222(222)?|333(333)?)\b' $G .```---## Step 2 — Seal every dark-mode leak### 2.1 Native controls, date pickers, `<select>`, autofill, and scrollbarsWithout `color-scheme: dark`, the browser paints OS-level UI in bright white even when your entire page is dark: `<input type="date">`, `<input type="time">`, `<select>` option menus, scrollbars, checkboxes, and browser autofill highlights.- **Fix:** Set `color-scheme: dark` on the dark root selector in your global CSS:  ```css  /* Class-based dark mode (.dark or [data-theme="dark"]) */  :root {    color-scheme: light;  }  .dark,  [data-theme="dark"] {    color-scheme: dark;  }  /* If the app follows OS preference automatically */  @media (prefers-color-scheme: dark) {    :root:not(.light) {      color-scheme: dark;    }  }  ```- **Browser autofill yellow/white box fix:** If inputs turn blinding white/blue on Chrome autofill in dark mode, style `input:-webkit-autofill` using a subtle inset shadow matching your input token:  ```css  .dark input:-webkit-autofill,  .dark textarea:-webkit-autofill,  .dark select:-webkit-autofill {    -webkit-box-shadow: 0 0 0 1000px var(--background, #18181b) inset;    -webkit-text-fill-color: var(--foreground, #fafafa);    caret-color: var(--foreground, #fafafa);  }  ```### 2.2 White flash on reload (pre-hydration FOUC)If your theme is stored in `localStorage` and applied inside a `useEffect`, the browser paints a full white frame before JavaScript hydrates.- **Fix:** Add a tiny synchronous inline script in `<head>` (in `app/layout.tsx` or `index.html`) that sets the dark class **and** `color-scheme` before first paint, and put `suppressHydrationWarning` on `<html>`:  ```html  <script>    (function () {      try {        var t = localStorage.getItem('theme');        var dark = t === 'dark' || ((!t || t === 'system') && matchMedia('(prefers-color-scheme: dark)').matches);        document.documentElement.classList.toggle('dark', dark);        document.documentElement.style.colorScheme = dark ? 'dark' : 'light';      } catch (e) {}    })();  </script>  ```  *(Match the exact `localStorage` key and class/attribute your app already uses — never invent a second key.)*### 2.3 Hardcoded light surfaces, text, and bordersReplace hardcoded utilities with the project's own semantic tokens first (if using shadcn/Tailwind CSS variables), or explicit `dark:` pairs if using raw Tailwind palette classes:| Leak | Semantic token fix (preferred) | Explicit Tailwind pair (if no tokens) || --- | --- | --- || `bg-white` | `bg-background` or `bg-card` or `bg-popover` | `bg-white dark:bg-zinc-900` || `bg-gray-50` / `bg-slate-50` | `bg-muted` | `bg-gray-50 dark:bg-zinc-900/60` || `text-black` / `text-gray-900` | `text-foreground` | `text-gray-900 dark:text-zinc-100` || `text-gray-500` / `text-gray-600` | `text-muted-foreground` | `text-gray-600 dark:text-zinc-400` || `border-gray-200` / `border-gray-300` | `border-border` | `border-gray-200 dark:border-white/10` |Check **modals, popovers, dropdown menus, tooltips, command palettes, empty states, toasts, and skeleton loaders** specifically — these are where `bg-white` hides most often because they aren't visible on initial render.### 2.4 Unpaired status colors & contrast failuresColors that pass WCAG AA on white (`text-red-600`, `text-emerald-600`, `text-amber-700`, `text-blue-600`) drop below `4.5:1` on dark `#18181b` / `#191919` cards, and `bg-red-50` / `bg-amber-50` badges glow like headlights in dark mode.- **Fix status text** with lighter `dark:` steps (`>= 4.5:1` contrast):  - `text-red-600 dark:text-red-400`  - `text-emerald-600 dark:text-emerald-400`  - `text-amber-700 dark:text-amber-400`  - `text-blue-600 dark:text-blue-400`- **Fix tinted status banners/badges:**  - `bg-red-50 text-red-700 dark:bg-red-500/15 dark:text-red-300`  - `bg-emerald-50 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300`  - `bg-amber-50 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300`- **Check Tailwind v4 custom dark variant:** If the app uses Tailwind v4 with class-based dark mode (`.dark`), verify globals.css declares:  ```css  @custom-variant dark (&:where(.dark, .dark *));  ```  Without this line in Tailwind v4, every `dark:` class ignores `.dark` and only responds to OS preference!### 2.5 Disappearing borders, inputs, shadows, and black SVGs- **Black SVGs & brand marks:** Replace hardcoded `fill="#000"`, `fill="black"`, `stroke="#111"` on monochrome icons and wordmarks with `currentColor`. For raster dark logos (`<img>`), swap source or apply `dark:invert` only on monochrome black-only marks (never on multicolored logos or photos).- **Invisible unchecked checkboxes, inputs, and cards on dark backgrounds:** Ensure dark borders have at least `rgba(255, 255, 255, 0.10)`–`0.14` (and `0.18`–`0.24` on unchecked inputs/checkboxes so control boundaries remain visible).- **Vanishing shadows on floating popovers/menus:** Outer drop shadows disappear on `#18181b` surfaces. Pair floating dark surfaces with a subtle 1px edge (`dark:border-white/10` or `dark:ring-1 dark:ring-white/10`) and a slightly lifted background tone.---## Step 3 — Verify in both themes1. Run your project's typecheck and build.2. Re-run the dark-leaks verifier across the same routes:   ```bash   node /tmp/fix-dark-leaks-check.mjs http://localhost:3000 --routes /,/settings,/login   ```3. Visually check **both dark mode and light mode** (including opening modals, dropdowns, date fields, and error states) to confirm zero dark leaks and zero light-mode regressions.---## Step 4 — Report (keep it tight)```text/fix-dark-leaks — verified in dark and light mode  White reload flash (FOUC):        yes → no  Native controls missing dark:       5 → 0  (color-scheme: dark)  Bright surface leaks:               7 → 0  WCAG contrast failures (<4.5:1):   11 → 0  Dark-on-dark SVGs / icons:          3 → 0Files changed:- src/app/globals.css — added color-scheme: dark + autofill override + @custom-variant dark- src/app/layout.tsx — inline pre-paint theme script (eliminated 180ms white flash)- src/components/BillingModal.tsx — replaced bg-white/text-gray-900 with semantic tokens- src/components/StatusBadge.tsx — paired status text with dark:*-400 (>= 6.2:1 contrast)Not checked:- Embedded third-party Stripe iframe```
/skills/fix-dark-leaks.md
The full skill in plain markdown with YAML frontmatter. Drop into .claude/skills, .cursor/rules or .agents/skills.
/skills/fix-dark-leaks-check.mjs
Standalone Node verifier for /fix-dark-leaks. Runs locally with --json and --fail flags.

Templates

Every Hairline template passes these out of the box

65 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 8 are free.