Skip to content

Instantly share code, notes, and snippets.

@jreviews
Created March 1, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jreviews/f00dc7143d86e26be77a1d80e30f7bbf to your computer and use it in GitHub Desktop.
Save jreviews/f00dc7143d86e26be77a1d80e30f7bbf to your computer and use it in GitHub Desktop.
Override CSS font icons with SVGs
.jrIconEditor {
width: 16px;
height: 16px;
display: inline-block;
background-size: 16px 16px;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%234a5568' class='w-8 h-8'%3E%3Cpath fill-rule='evenodd' d='M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z' clip-rule='evenodd'%3E%3C/path%3E%3C/svg%3E");
}
.jrIconEditor:before {
content: unset;
}
@jreviews
Copy link
Author

jreviews commented Mar 1, 2020

Find the SVG of your liking, there are free resources:

Then use an encoder https://yoksel.github.io/url-encoder/ to convert the SVG to a data URL that can be used in CSS without having to load an external image. Make sure you modify the "fill" attribute in the SVG to your desired color. For example fill='%234a5568' where the %23 is just the url escaped equivalent of #4a5568. If the color string is not escaped, then it won't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment