feather icon indicating copy to clipboard operation
feather copied to clipboard

What is the way to import only certain icons?

Open dionsnoeijen opened this issue 3 years ago • 9 comments

This is all I can find: import feather from "feather-icons";.

It helps me to use feather.replace() in this class. But I don't want to load the whole set of icons in my js file. Can I only have the icons imported that I'm actually using?

Thanks!

dionsnoeijen avatar Aug 14 '21 09:08 dionsnoeijen

Hi @dionsnoeijen, there is an approach you could consider to solve your need. If you use Icomoon (https://icomoon.io/app/#/select/library) you will see that Feather icons are included in their icon library. You select it and then Icomoon allows you to select which icons will be included in the final generated webfont.

The way I see it, it's a really good way to keep webfonts light and even to include custom icons. I hope this helps.

pizaranha avatar Aug 25 '21 17:08 pizaranha

https://github.com/feathericons/feather#feathericonsnametosvgattrs

Valexr avatar Aug 25 '21 17:08 Valexr

Thanks! I will try!

dionsnoeijen avatar Aug 26 '21 11:08 dionsnoeijen

@Valexr As soon as I import feather, all icons are imported into js. Am I missing something obvious here?

dionsnoeijen avatar Aug 27 '21 09:08 dionsnoeijen

Yep, it's not modularity... & bundled all icons in one Object...🤔

Valexr avatar Aug 27 '21 12:08 Valexr

@Valexr As soon as I import feather, all icons are imported into js. Am I missing something obvious here?

Well, be sure to select only those you will use. I am talking about Icomoon app. When you touch each icon you can toggle the selection.

pizaranha avatar Aug 28 '21 16:08 pizaranha

One more alt way:

<img src=https://unpkg.com/[email protected]/dist/icons/activity.svg />

<!- or ->

<img src= https://cdn.jsdelivr.net/npm/[email protected]/dist/icons/activity.svg />

Valexr avatar Aug 29 '21 06:08 Valexr

& I make this file: https://gist.github.com/Valexr/6ed010b646470425d896726981c6fae1 Maybe it will be useful

Valexr avatar Aug 29 '21 06:08 Valexr

I had opened an issue for this last January: #1028

In short, no, the current implementation does not support adding specific icons only in any way.

ajitzero avatar Dec 26 '21 09:12 ajitzero