3 ms·
Is there such a thing as SVG but where you can define a subshape and reuse it elsewhere in the file?
by anderspitman 6y ago
Is there such a thing as SVG but where you can define a subshape and reuse it elsewhere in the file?
- Silhouette 6y agoPerhaps you're looking for <defs> and <use> elements?
- anderspitman 6y agoThat looks like the ticket, thanks! It's very embarrassing that I didn't know about this before.
- ygra 6y agoThe main drawback for those things is that you cannot parameterize them, which is a bummer if you've created a shape that you might want to vary in ways that a transform cannot easily do.
- anderspitman 6y agoSeems like you can get pretty far with CSS variables though, yeah? Do you have a good example of something common that can't be accomplished?
- ygra 6y agoFor styling purposes, yes, CSS allows a lot and things like currentColor enable you to at least have colors and styling dynamic when instancing symbols. But things like parametric shapes don't work without scripting, which is a bummer, since in many other places SVG is very amenable to handwriting with a lot of cool features. Just not with a lot of abstraction options.