I'm making a Twitter clone app using VueJS 3.
I saved Twitter's logo as a .svg file and can use it with the <img />
tag. I can also change the color of the <svg>
tag when I provide it with the fill="#fff"
attribute. However, I want to use this .svg file in multiple locations and in different colors.
So I tried by providing the classes fill-white
, bg-white
and text-white for the
<img /> tag
to dynamically change the color of the svg, but it doesn't work.
My current .svg file - White
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" aria-hidden="true"> <g> <path fill="#fff" d="M23.643 4.937c-... 1.7-1.477 2.323-2.41z"></path> </g> </svg>
Picture tag
<img src="/twitter-bird.svg" draggable="false" class="w-52 lg:w-96 fill-white" alt="Twitter Bird" />
I tried this on a .svg file
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" aria-hidden="true"> <g> <path fill="params(fill) #fff" d="M23.643 4.937c-... 1.7-1.477 2.323-2.41z"></path> </g> </svg>
I know I need to make the colors of this svg editable. But I can't find how to do this.
You can make components from svg files and bind the padding to props: