# \[Stencil\] How to import exactly two v4 ionicons into a Stencil component?

**URL:** <https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561>\
**Category:** Stencil\
**Created:** [February 5, 2018, 9:34pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561 "2018-02-05T21:34:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [February 5, 2018, 9:34pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/1 "2018-02-05T21:34:56Z")

</div>

I’m designing a Stencil component with Ionicons v4. Based on a condition, I’d like to either draw ionicon A or ionicon B. I’d like to ensure the component only imports those two ionicons. I have ionicons as a collection in `stencil.config.js`, and the component works correctly (though I haven’t built for production yet). Critical code is:

Inside render function:

```auto
{starCounter.map((_, currentIndex) => <ion-icon name={this.iconName(currentIndex + 1)} 
                                                onClick={_ => this.updateRating(currentIndex + 1)}
                                                style={{'font-size': fontSizeExpression}}>
                                      </ion-icon>)}

```

And the iconName function:

```auto
iconName(starNumber: number): string {
    const threshold = this.currentRating - starNumber;
    if (threshold >= 0) { return 'star'}
    else { return 'star-outline' };
  }

```

Is the compiler smart enough to know that it only needs “star” and “star-outline”? Do I need to declare that in some way? Should I alter the code? I would like to end up with as lightweight a component as possible.

@manucorporat sorry for tagging you here, but my guess is not a lot of people know the answer to this yet, so if you could ask someone on the team to take a look if I don’t get an answer otherwise, I’d appreciate it, thanks.

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [February 5, 2018, 10:08pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/2 "2018-02-05T22:08:44Z")

</div>

Let us know if components built by stencil.js are indeed faster, better than Angular 5 components.  
If so, I might jump in and transplant my current project into stencil & capacitor combo.

Ideally you can test it on smartphones

---

<div class="post-metadata">

**Author:** ![AaronSterling](https://avatars.discourse-cdn.com/v4/letter/a/51bf81/32.png) [@AaronSterling](https://forum.ionicframework.com/u/AaronSterling)\
**Post date:** [February 5, 2018, 10:11pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/3 "2018-02-05T22:11:48Z")

</div>

It promises to be way better, at least in this particular case. I’m rebuilding my star-rating component in Stencil. One weakness in the ionic-angular version is that you have to import all ionicons if you want to use any of them. If I build this correctly, I should only need two ionicons, and nothing from ionic-angular. So the component will be much lighter, and can be used by any framework.

That’s the idea anyway. But the rubber is meeting the road, and I think I’ve pushed past where the documentation currently is.

---

<div class="post-metadata">

**Author:** ![jamesharvey](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/jamesharvey/32/116080_2.png) [@jamesharvey](https://forum.ionicframework.com/u/jamesharvey)\
**Post date:** [February 5, 2018, 10:14pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/4 "2018-02-05T22:14:47Z")

</div>

To be honest. I never use ion icons.  
The best method I found is creating your own font file which has SVG icons.

Check this out:  
[https://icomoon.io/app/](https://icomoon.io/app/)

You can import any PNG, SVG file as a part of font on their online app. Icomoon can then export the collection as a font file which you can use on Ionic (angular)'s SCSS file.  
This is how I get unique icons… there are countless amount of free SVG icon files you can find online.  
and the font file can be used with custom selector like ion-icon… you can name it whatever you want in SCSS.

So stencil.js doesn’t come with Icons to reduce size… that’s good.

---

<div class="post-metadata">

**Author:** ![Shaoz](https://avatars.discourse-cdn.com/v4/letter/s/258eb7/32.png) [@Shaoz](https://forum.ionicframework.com/u/Shaoz)\
**Post date:** [November 13, 2018, 4:50pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/5 "2018-11-13T16:50:10Z")

</div>

I James,

I used icomoon with V3 but I can’t make a mixin makeIcon with v4

@mixin makeIcon($arg, $val) {  
.icon-#{$arg}:before,  
.ion-ios-icon-#{$arg}:before,  
.ion-ios-icon-#{$arg}-outline:before,  
.ion-wp-icon-#{$arg}:before,  
.ion-wp-icon-#{$arg}-outline:before,  
.ion-md-icon-#{$arg}:before,  
.ion-md-icon-#{$arg}-outline:before {  
content: #{’"\’ + $val + ‘"’};  
font-size: 0.7em;  
}  
}

Can I see your scss please?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:51pm UTC](https://forum.ionicframework.com/t/stencil-how-to-import-exactly-two-v4-ionicons-into-a-stencil-component/120561/6 "2021-07-19T21:51:46Z")

</div>

Closed on July 19, 2021, 9:51pm UTC


