How to change an SVG icon's colour
Quick steps
- Find the colour attributesOpen the SVG and look for fill="..." and stroke="..." on the <svg> root and its shapes.
- Replace them with currentColorSet fill or stroke to currentColor (leave fill="none" on outline icons as it is).
- Render the SVG inlinePaste the <svg> into your HTML or JSX; CSS cannot reach inside an <img>.
- Set the colour in CSSGive the parent a color, and add :hover or dark-mode rules as needed.
The currentColor method (best)
currentColor means "use the CSS color of this element". An icon that uses it adopts the text colour of wherever it is placed, including links, buttons, hover states and dark mode. This outline bell from the library is already set up that way:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 16v-5a6 6 0 0 1 12 0v5l2 2H4z"/><path d="M10 20.5a2 2 0 0 0 4 0"/></svg>.toolbar a { color: #5c6075; }
.toolbar a:hover { color: #5b4cf0; }
@media (prefers-color-scheme: dark) {
.toolbar a { color: #a2a8c0; }
}Outline icons are painted by stroke (with fill="none"); filled and glyph icons by fill. Change the one the icon uses.
Using CSS fill and stroke
On an inline SVG you can also set the paint from CSS. Presentation attributes such as fill="#000" have the lowest priority, so any CSS rule overrides them:
.icon { fill: none; stroke: #0891b2; }
.icon-solid { fill: #0891b2; }This does not work if the SVG uses inline style="fill:...", which beats normal CSS rules. Remove those styles first.
When the SVG is an <img> or a background image
A browser draws <img src="icon.svg"> and CSS background images as separate documents, so page CSS cannot recolour them. You have three options:
- Inline the SVG instead (best if you control the markup).
- Use the icon as a mask and paint it with
background-color; see SVG icons in CSS. - Change the colour inside the file and export a new version.
CSS filter chains (invert, sepia, hue-rotate) can approximate a colour, but they are hard to make exact and they also tint anti-aliased edges. Treat them as a last resort.
Two-colour (duotone) icons
A duotone icon has a second, translucent layer. Give that layer its own colour with a class, or keep it as currentColor with opacity="0.3" so a single color drives both layers. In SVG Creator, pick the second colour in the editor and the export writes it into the file.
Change the colour without code
Open any icon in the SVG Creator editor, use the colour picker or type a hex value, and export SVG, PNG, React or CSS with the new colour. Every icon in the free icon library has an "Edit colours" button that opens it there.
Frequently asked questions
Why doesn't CSS change my SVG icon colour?
Usually because the SVG is loaded through <img> or background-image, which CSS cannot reach, or because the SVG uses inline style attributes. Inline the SVG and replace hard-coded colours with currentColor.
How do I change an SVG icon colour on hover?
Use currentColor in the SVG and change color on :hover of the parent link or button.
Should I use fill or stroke?
Outline icons are drawn with stroke and have fill="none"; filled and glyph icons use fill. Change whichever paints the visible shape.