GeoIcons uses CSS currentColor to make SVG icons adapt to dark mode automatically
Most SVG icon sets hardcode a fill color, causing icons to vanish or clash when a site switches to dark mode. GeoIcons solves this by setting stroke='currentColor' on every icon, so each one inherits the text color of its parent element. Developers only need to define a color for light and dark themes once in CSS or via Tailwind utility classes, and all icons update accordingly. The approach also works with the prefers-color-scheme media query, letting icons respond to a user's system theme without any JavaScript. Interactive states like hover and focus are handled the same way — styling the container automatically recolors the icon inside it.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in