How to make inline SVG icons inherit a button color
Answer in brief
Use currentColor on the SVG fill or stroke that should follow the button's text color. Check individual paths for hard-coded paint values that override the inherited choice.
Repair a two-tone outline
For a hollow search glyph, keep fill="none" and set stroke="currentColor". Change the parent color on focus and hover. Verify the lens stays hollow and both the ring and handle change together.
Trace a path that refuses to change color
Select the stubborn path and inspect its computed stroke or fill while changing the parent button color. A child style such as stroke: black overrides an inherited stroke on the svg. Change only the paths intended to track text, keeping deliberate accent colors on their own paths.
Sources
- [1] Painting: Filling, Stroking and Marker Symbols — SVG 2 — W3C, accessed November 23, 2026
Frequently asked questions
Will parent color reach inside an SVG loaded through img?
An externally loaded image has a separate document context. Use inline SVG when component-level paint inheritance is required.