twbs / icons

Official open source SVG icon library for Bootstrap.
https://icons.getbootstrap.com
MIT License
7.43k stars 1.07k forks source link

Custom element #884

Open lekoala opened 3 years ago

lekoala commented 3 years ago

Hi,

Is there any plan to provide a custom element to load the icons?

I really like this icon set, but it's going to grow with each version and loading the whole set doesn't seem like a good idea. Other options (linking directly, embedding svgs...) also have their downsides.

As a proof of concept, I made this that seems to work nicely provided you use a modern browser https://github.com/lekoala/bootstrap-icon-element

Or even inlining svgs with js maybe if the custom element is not the chosen approach?

It just feels that it would be great to have a recommended approach rather than 4 which all have their pros/cons.

RubenVerg commented 3 years ago

You can try Xel's <x-icon>

lekoala commented 3 years ago

@RubenVerg i'm aware there are ways to do this (xel's doesn't seem to include bootstrap support by default. There is also https://github.com/iconify/iconify which is interesting), i'm just a bit disappointed that there is no "official" way to do things and that it's recommended to load a whole set when in reality you are probably using a fraction of it.

lekoala commented 3 years ago

Well just in case someone else is wondering, I created this little thing https://github.com/lekoala/bootstrap-icon-element

So far, I've been really happy with it. I hope it can be of some use for others ;-)