← Back to Writing

The Invisible Icon Problem: Theme-Aware SVG Thumbnails in KDE

Nov 15, 2026 · 3 min read

If you use KDE Plasma on a dark theme and work with modern SVG icon sets (like Lucide, Tabler, Feather, or Breeze), you’ve probably noticed this:

Dolphin Screenshot

You open a folder of icons in Dolphin, turn on previews, and you get a wall of invisible black-on-black silhouettes.

Modern icons use CSS currentColor to inherit their parent's text color. But when Dolphin renders an SVG thumbnail, it hands it to QSvgRenderer. Because a standalone SVG file has no parent webpage or DOM element to inherit text color from, QSvgRenderer falls back to an ancient default: black text on white paper.

On a dark theme, black icons on a dark canvas are essentially invisible.

The Upstream Attempt (and the Caching Trap)

I opened a Merge Request on KDE's kio-extras (!566) to inject the active system text color (QPalette::WindowText) into currentColor.

That led to an interesting philosophical debate with KDE maintainer Nicolas Fella about whether a thumbnailer should be a raw, unfiltered view of the file's literal bytes, or an adaptable preview tailored for human visibility.

While testing it on my machine, I discovered a much bigger problem: scheduled night mode.

Desktop Linux follows the Freedesktop Thumbnail Specification, caching previews as static PNG files in ~/.cache/thumbnails/ keyed strictly by MD5(file_uri).

If my patch generated a white thumbnail while I was in Dark Mode, that white icon was baked into a static PNG. The next morning when Plasma switched back to Light Mode, Dolphin didn't re-render anything—it loaded the cached white PNG onto a light background, turning the icons invisible white-on-white.

Baking dynamic colors into a static, theme-agnostic disk cache was fundamentally broken. I closed the MR.

Building kio-tasvg

Upstream KDE has to maintain strict backwards compatibility for millions of users. But I still wanted my file manager to look clean, so I wrote kio-tasvg as a standalone C++ thumbnailer plugin for Plasma 6.

It parses the root <svg> element, safely checks word boundaries so attributes like stop-color aren't mistaken for text colors, and injects the active system palette color directly into the root tag. It also handles compressed .svgz files using KCompressionDevice:

if (!hasExplicitFixedColor(rootTag)) {
    const QByteArray themeColor = QGuiApplication::palette().color(QPalette::WindowText).name().toLatin1();
    svgData.insert(svgStart + 4, " color=\"" + themeColor + "\" ");
}

Any child elements using fill="currentColor" or stroke="currentColor" automatically inherit the system color without touching raw file bytes on disk.


Handling the Day/Night Desync

For the 80%+ of developers who permanently live in dark mode, the caching issue never happens. But for users who switch themes on a schedule, I built an optional companion background service: tasvg-daemon.

When Plasma switches color schemes (QGuiApplication::paletteChanged), the daemon:

  1. Scans ~/.cache/thumbnails/ and reads the embedded PNG metadata chunks, safely deleting only thumbnails where Thumb::Mimetype == "image/svg+xml" (leaving your photos and videos untouched).
  2. Broadcasts org.kde.KDirNotify.FilesChanged over DBus so active Dolphin windows repaint the new thumbnails immediately.

It ships as an optional systemd --user service that stays disabled unless you explicitly turn it on.


Try It Out

kio-tasvg is open source under LGPL-2.0-or-later with pre-built .rpm, .deb, and a Nix flake module: