Open hamid-dionysus opened 10 months ago
Hmm. I spent about 3 hours creating a custom template to append the className
prop to the SVG class attribute.
But, I realized that is not necessary!
You shouldn't add the class
attribute to the SVG file.
Because it doesn't make sense!
You can use the class
attribute for path elements; SVGR will convert it to the style
attribute and make it inline.
But, the class
attribute for the SVG element is useless. Because the SVG file is in a separate context from the page. Like an isolated component.
Unless you directly inject an SVG element to the code which means you do not use the SVGR in this case.
Hmm. I spent about 3 hours creating a custom template to append the
className
prop to the SVG class attribute. But, I realized that is not necessary! You shouldn't add theclass
attribute to the SVG file. Because it doesn't make sense!You can use the
class
attribute for path elements; SVGR will convert it to thestyle
attribute and make it inline.But, the
class
attribute for the SVG element is useless. Because the SVG file is in a separate context from the page. Like an isolated component. Unless you directly inject an SVG element to the code which means you do not use the SVGR in this case.
Excellent, thanks! :D
Hmm. I spent about 3 hours creating a custom template to append the
className
prop to the SVG class attribute. But, I realized that is not necessary! You shouldn't add theclass
attribute to the SVG file. Because it doesn't make sense!You can use the
class
attribute for path elements; SVGR will convert it to thestyle
attribute and make it inline.But, the
class
attribute for the SVG element is useless. Because the SVG file is in a separate context from the page. Like an isolated component. Unless you directly inject an SVG element to the code which means you do not use the SVGR in this case.
I don't get what you are saying. Adam Wathan did recommend adding Tailwind classes to SVG element here https://www.youtube.com/watch?v=MbUyHQRq2go&list=PL7CcGwsqRpSM3w9BT_21tUU8JN2SnyckR&index=13
When I first tried to add the classes to svg element, they didn't work, but later I realized because tailwind doesn't detect the usage and prune these classes from the final CSS file. When I included the svg file to tailwind config, thing seems to work fine.
{
// ...other tailwind config
content: ["src/**/*.{ts,tsx,svg}"] // <- include the svg file type
}
🐛 Bug Report
need props className append to svg classes , but It is now being replaced props className to svg class
To Reproduce
Expected behavior
os