Great tutorial! I'm working on a similar thing but more of an icon switcher. The goal is to provide an icon name from the parent prop then dynamically import and render the SVG based on the name. The icons are dynamically imported into an object. In principle, it should work but I get a load of TypeScript errors that I can't fix.
I wasnt able to use this package since it removes viewBox attribute from the svg automatically. I tried to fix it by trying about 5 different things from different github issues and stackoverflow answers but couldnt solve. Ended up wrapping the svg with a jsx component manually.
There is none. Because it's now in jsx, you can add ID, interpolate values, CSS module scope, ternary render paths, loop generate things like mazes. You can add classes to any path. If you know how to edit svg it's real powerful.
I find adding a className to the custom SVG easier for the standard use case. However, for more specific use cases, the previous comment makes good points
hab deinen channel gestern zufällig gefunden, als ich nach videos zum t3 stack gesucht habe. richtige starke videos, hat mir echt geholfen einen anfang mit t3 zu finden. hast du discord oder so. Hätte ggf mal ein paar fragen :)
Great tutorial! I'm working on a similar thing but more of an icon switcher.
The goal is to provide an icon name from the parent prop then dynamically import and render the SVG based on the name.
The icons are dynamically imported into an object. In principle, it should work but I get a load of TypeScript errors that I can't fix.
Did you managed to make this work?
@1:53: Takes sip.
Great video, big help, thanks!
Wow, thank you very much for this video, it helped me a lot now in NextJS 14. Very good.
I wasnt able to use this package since it removes viewBox attribute from the svg automatically. I tried to fix it by trying about 5 different things from different github issues and stackoverflow answers but couldnt solve. Ended up wrapping the svg with a jsx component manually.
Why don't you encapsulate the SVG into a component as a function/class and modify using props? Is there a disadvantage to that?
There is none. Because it's now in jsx, you can add ID, interpolate values, CSS module scope, ternary render paths, loop generate things like mazes. You can add classes to any path. If you know how to edit svg it's real powerful.
I find adding a className to the custom SVG easier for the standard use case. However, for more specific use cases, the previous comment makes good points
This works Great Hoowever, if the svgs have stroke it doesnt work, how can this be overided?
Thanks for the kind help
for me, only works on development..
when deploying to Vercel, every time I have a "could not resolve ./svg/google.svg" error..
Really useful!! Thanks a lot, mate
Thank you Josh.
Can I use class inside SVG to use css?
How would I do this in React JS?
What about the license without pro version?
This does not work on the app server, just the page server. can you do an app server demo?
how ca I use public folder?
If I use this package means.. the next image not getting load.. I'm using NEXT JS 14.. anyone help me in that
bro it is work in 14 version!
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
use: [{ loader: '@svgr/webpack', options: { icon: true } }],
});
return config;
},
};
export default nextConfig;
hab deinen channel gestern zufällig gefunden, als ich nach videos zum t3 stack gesucht habe. richtige starke videos, hat mir echt geholfen einen anfang mit t3 zu finden.
hast du discord oder so. Hätte ggf mal ein paar fragen :)
like and sign up for you as this worked perfectly for me, thanks for the help.
Thank you and great work.
It's a complete shit show trying to implement this with NextJS 14
دمت گرم.
thanks mate! really helpful and easy
It would be great to learn how to work in Next.js with sprite.svg
great tutorial thanks so much!
You are a life saver!
thanks, it work for me, finally
Thanks this video very useful
Happy to hear that
great stuff!
Good.
useful video
This is dumb, why does it not work out of the box. SVGs are pretty popular
it works in react, but not in nextjs.. kind of dumb