Closed czottmann closed 1 year ago
This is as expected. We only pass to the top-level svg
tag. If you check out the other Iconify components, they also do the same codesandbox example. This feels like it might be an issue with the IconSet more than anything.
I will leave this open for now to see if there are more people running into this issue before deciding to add a feature for it.
Dug into this a bit more for the next refactor. It seems this is an issue with the Iconify Tabler Icon Collection. You should be able to use the custom icon packs as a workaround.
// src/icons/tabler.js
import { createIconPack } from 'astro-icon/pack';
export default createIconPack({ package: "@tabler/icons", dir: "icons" });
I'm going to close this out since it has a workaround and is an issue with Iconify. I have also filed a ticket upstream https://github.com/iconify/icon-sets/issues/63
@stramel Thank you!
Issue description
Props passed to
Icon
are only applied to the "top-level"svg
element but not its children. I noticed this while working w/ Tabler icons. For example, when I tellIcon
to use a stroke width of 1 and to use the color red, the emittedsvg
element shows both those properties but they're ignored by the containedpath
element. (See example below.)I don't know whether that's by design but I was expecting my settings being passed down the chain. I understand that might not always be desirable, especially when it comes to multi-color SVGs etc. But is there a way to force the props down to the
path
etc.? If not, might such functionality (hidden behind a toggle) be a useful addition to astro-icon?Possible way to do it: iterate over children, filter their attributes for those that correlate w/ a passed-in prop and replace those.
Input
Expected output
Note: I've sorted the attributes for easier visual scanning.
Actual output
Note: I've sorted the attributes for easier visual scanning.