Menu

Make an SVG Logo Work in Light and Dark Mode (With One File)
📰

Make an SVG Logo Work in Light and Dark Mode (With One File)

DEV Community: beginners·BMU Socialmedia·3 days ago
#pkwy4hWe
#devtobeginners#devto#dev#dark#colour
Long article (308 words) — no AI summary yet.
Reading 0:00
15s threshold

A common launch-day bug: the logo looks great in light mode, then disappears completely when a user's system switches to dark mode. Here's a one-file fix, and a quick way to check whether the logo itself is the real problem.

The fix: currentColor + CSS

Edit the SVG so its fills use currentColor instead of a fixed hex value:

<svg viewBox = "0 0 120 32" class = "logo" role = "img" aria-label = "Brand name" > <path fill = "currentColor" d = "..." /> </svg>

Enter fullscreen mode

Exit fullscreen mode

Then control the colour from CSS:

.logo { color : #121F2F ; } /* brand navy on light */

@media ( prefers-color-scheme : dark ) { .logo { color : #FFFFFF ; } /* white on dark */ }

Enter fullscreen mode

Exit fullscreen mode

One file, both themes, no extra HTTP requests.

Two-colour logos

If the logo has an accent colour, use a CSS custom property for the second fill:

<path fill = "currentColor" d = "..." /> <path fill = "var(--logo-accent, #8BB72C)" d = "..." />

Enter fullscreen mode

Exit fullscreen…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.