Menu

Why Does My SVG Icon’s Why Does My SVG Icon’s Handle Stay Black? Debugging a Sprite with DevTools
📰

Why Does My SVG Icon’s Why Does My SVG Icon’s Handle Stay Black? Debugging a Sprite with DevTools

DEV Community: css·Svg/icons·13 days ago
#Sil8zi8Q
#devtocss#devto#dev#search#button
Reading 0:00
15s threshold

Hover over the Search button. The word turns purple. So does the ring of the magnifying glass. Its handle stays black.

That ring is a useful clue. The button’s hover rule works, and its color reaches the icon. Before changing any CSS, look at what draws the handle.

Reproduce the two-color magnifier

Save this snippet as demo.html and open it in a browser. Hover over the button, or press Tab to focus it. The deliberately large icon makes the short black line easy to spot.

<!doctype html> <html lang= "en" > <meta charset= "utf-8" > <title> Find the black handle </title> <style> button { display : inline-flex ; align-items : center ; gap : .4em ; padding : .4em .7em ; color : #111 ; background : white ; border : 2px solid currentColor ; border-radius : .4em ; font : 2rem system-ui ; } button :hover , button :focus-visible { color : #6932bc ; } button :focus-visible { outline : 3px solid currentColor ; outline-offset : 4px ; } </style> <svg width= "0" height= "0" aria-hidden= "true" style= "position:absolute"…

Continue reading — create a free account

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