Is there an efficient way to handle SVG usage in Svelte?
Instead of this hideous block of code in the picture, is there an easier way to handle using an svg? it really does make it very difficult to see what the hell is going on when I scroll through my code..
8 Replies
I usually just make them components
makes sense.. import the svg from static/react.svg then use that component in the +page.svelte
yup
I have a bunch of IconDescription.svelte components (so IconHome, IconSearch, ...) and then just import them where I need them. Keeps the components you work in nice and clean
for what I'm attempting to do, I assume I can't just throw them all into 1 component, I'd need to have each it's own?
SvelteIcon, ReactIcon, HtmlIcon etc..
I mean, "need" is a strong word
you could make a component that's all the icons together, and just accept that it's going to be a mess of inline svg tags
I make them separate because I generally use icons for controls
I'll attempt to do them separately
If I can figure out how to do pathing again LOL
you can take advantage of svg symbols
also, your svg is full of useless stuff
you have 2 empty groups with HUGE ids
yea, it's triggering me, but I'm using sveltekit so the SSR part of it is screwing with my just importing my ReactIcon.svelte into my +page.svelte