# Discourse Easy 'SVG Icon' and 'Emoji' in CSS

**URL:** https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656
**Category:** Development
**Created:** [March 23, 2024, 2:29pm UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656 "2024-03-23T14:29:09Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [March 23, 2024, 2:29pm UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/1 "2024-03-23T14:29:09Z")

</div>

Hello 👋

This topic contain two theme component.

## Discourse Easy SVG Icon CSS

> ⚠ This theme component is functional as a template, please fork it on Github or use the code to your project. You can remove the icons svg codes from the SCSS and only keep those what you really actually use… I have imported the `mixin` file to the `common.scss` file so you can add your code below that line or separately to the desktop or mobile section.

The theme component add the ability to keep the SVG icon a maintainable and easily editable in your CSS. The component contains the all svg icons found here: [discourse/vendor/assets/svg-icons/fontawesome at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/tree/main/vendor/assets/svg-icons/fontawesome)

* * *

[https://github.com/VaperinaDEV/discourse-easy-svg-icon-css](https://github.com/VaperinaDEV/discourse-easy-svg-icon-css)

* * *

### How to use?

Fix parameters:

`$icon-set`: brands, regular, solid  
`$icon-name`: icon name  
`$icon-color`: icon color (`currentColor`, hex or color variable)  
`$width and $height`: the size of the added icon

It looks like this:

```scss
@include svg-icon($icon-set, $icon-name, $icon-color, $width, $height);

```

**Using `currentColor`**  
Here is an example to adding a solid rocket icon before the **Latest** navigation bar item.

```scss
#navigation-bar {
  li.nav-item {
    &_latest {
      a {      
        gap: 0.5em;
        &:before {
          content: "";
          @include svg-icon(solid, rocket, currentColor, 1em, 1em);
        }
      }
    }
  }
}

```

![add-icon-to-latest](https://global.discourse-cdn.com/meta/original/4X/6/8/a/68a643ceb2ac685df9791af149af837d9fe414df.gif)

* * *

**Using `var(--gold)` color variable**  
Here is an example to add a regular gold star icon before the **Top** navigation bar item.

```scss
#navigation-bar {
  li.nav-item {
    &_top {
      a {      
        gap: 0.5em;
        &:before {
          content: "";
          @include svg-icon(regular, star, var(--gold), 1em, 1em);
        }
      }
    }
  }
}

```

![add-star-to-top](https://global.discourse-cdn.com/meta/original/4X/8/2/c/82c83792c4ae516464246812fdc61c0794760cf4.gif)

* * *

We can easily change the icon set, the color or even the icon too on hover etc… Let’s see!

Now we change the regular icon to solid when I hover the button.

```scss
#navigation-bar {
  li.nav-item {
    &_top {
      a {      
        gap: 0.5em;
        &:hover,
        &:focus,
        &.active {
          &:before {
            @include svg-icon(solid, star, currentColor, 1em, 1em);
          }
        }
        &:before {
          content: "";
          @include svg-icon(regular, star, currentColor, 1em, 1em);
        }
      }
    }
  }
}

```

![change-icon-set](https://global.discourse-cdn.com/meta/original/4X/2/8/8/288ab22ff6488d232e60a5e2af812be72ef3ee44.gif)

* * *

## Discourse Easy Emoji CSS

> ⚠ This theme component is functional as a template, please fork it on Github or use the code to your project. I have imported the `mixin` file to the `common.scss` file so you can add your code below that line or separately to the desktop or mobile section.

[https://github.com/VaperinaDEV/discourse-easy-emoji-css](https://github.com/VaperinaDEV/discourse-easy-emoji-css)

### How to use?

The usage is similar like the SVG version.

Fix parameters:

`$emoji-set`: apple, google, twitter, win10, google\_classic, facebook\_messenger  
`$emoji-name`: emoji name  
`$width and $height`: the size of the added emoji

```scss
@include emoji($emoji-set, $emoji-name, $width, $height);

```

Here is an example to adding a `facebook_messenger` `rocket` emoji before the **Latest** and a `twitter` `star` emoji before the **Top** navigation bar item.

```scss
#navigation-bar {
  li.nav-item {
    &_latest {
      a {      
        gap: 0.5em;
        &:before {
          content: "";
          @include emoji(facebook_messenger, rocket, 1em, 1em);
        }
      }
    }
    &_top {
      a {      
        gap: 0.5em;
        &:before {
          content: "";
          @include emoji(twitter, star, 1em, 1em);
        }
      }
    }
  }
}

```

![Screenshot 2024-03-25 at 5.26.26](https://global.discourse-cdn.com/meta/original/4X/9/e/9/9e9f0a12fb60537533c141e18e145f7d98eecb9c.png)

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 25, 2024, 11:48am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/2 "2024-03-25T11:48:37Z")

</div>

Good Morning @Don,

I have been ardently following your work and believe I have incorporated all your creations into my forum. However, with this particular item, I am uncertain. Since the upgrade of the discourse, my mind has become muddled, and I cannot recall where to implement these CSS codes. I have integrated your GitHub code into the theme, yet nothing appears to be showing.

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 25, 2024, 11:54am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/3 "2024-03-25T11:54:47Z")

</div>

> [@Aaron\_Walsh](#):
>
> I have integrated your GitHub code into the theme

I believe the theme is supposed to be an editable base for you to work from:

> [@Don](#):
>
> This theme component is functional as a template, please fork it on Github or use the code to your project.

Which would explain why nothing showed up when you installed it, as the template would likely do little to nothing on it’s own.

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 25, 2024, 12:01pm UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/4 "2024-03-25T12:01:40Z")

</div>

> [@Firepup650](#):
>
> I believe the theme is supposed to be an editable base for you to work from:

 ![Screenshot_20240325_115532_Chrome](https://global.discourse-cdn.com/meta/original/4X/2/3/b/23b11e75f8f440eafd9fbf1828b355db72d27ba0.jpeg)

Shouldn’t this be visible to us?

 ![Screenshot_20240325_115729_Chrome](https://global.discourse-cdn.com/meta/original/4X/3/5/7/357f1ee367ab6730a08f7ece84d13fa5d0707875.jpeg)

or

 ![Screenshot_20240325_120045_Chrome](https://global.discourse-cdn.com/meta/original/4X/8/8/5/885606f088988de04f9a2d4b8ad622a048386386.jpeg)

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [March 25, 2024, 12:02pm UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/5 "2024-03-25T12:02:42Z")

</div>

No, as it is a remote theme, meaning you must either download it from GitHub and upload as a zip to your instance, or fork the GitHub repository and make your changes there.

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 25, 2024, 12:05pm UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/6 "2024-03-25T12:05:28Z")

</div>

Indeed, this is an entirely novel concept to me. However, I comprehend your point; each day is an opportunity for learning, and I appreciate the swift response.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [March 26, 2024, 4:56am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/7 "2024-03-26T04:56:02Z")

</div>

Hey @Aaron_Walsh 👋 Did it work finally for you? Is there any specific use case where you want to use this? If you share some details I can make a separate theme component based on this where it can easily modifiable with settings.

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 26, 2024, 6:31am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/8 "2024-03-26T06:31:09Z")

</div>

Good Morning,

The endeavor would have been successful; however, I no longer possess a Windows laptop for editing purposes. Instead, I have transitioned to using a Samsung Galaxy S9 Ultra, a decision I now find somewhat regrettable 😅.

There exists a method through which I can accomplish this task using my hosting server (cPanel) by uploading and editing. Nevertheless, I must apologetically note that the work you have crafted may prove to be intricate for some individuals.

Therefore, if you are amenable,

> [@Don](#):
>
> Should you provide some details, I am capable of creating a distinct theme component based on this. It would be designed for ease of modification through settings.

![9e9f0a12fb60537533c141e18e145f7d98eecb9c](https://global.discourse-cdn.com/meta/original/4X/4/e/b/4eb960ae7406c37c0904802b5a3c595d1995d6da.png)

This design is the object of my admiration and the one I am particularly drawn to!

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [March 26, 2024, 6:42am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/9 "2024-03-26T06:42:30Z")

</div>

> [@Aaron\_Walsh](#):
>
> Nevertheless, I must apologetically note that the work you have crafted may prove to be intricate for some individuals.

Yeah, that’s the reason it placed in #Development category but no worries I’ll make a #Customization > Theme component for this use case. 🙂

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 26, 2024, 8:37am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/10 "2024-03-26T08:37:29Z")

</div>

> [@Don](#):
>
> Yeah, that’s the reason it placed in #Development category

Apologies, that was my oversight! However, moving forward, I will be better informed about this.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [March 27, 2024, 5:54am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/11 "2024-03-27T05:54:50Z")

</div>

Hello 👋 This #Customization > Theme component is done. ✅

> [@Discourse Nav Item Icon / Emoji](https://meta.discourse.org/t/discourse-nav-item-icon-emoji/301105):
>
> information_sourceSummary Add Icon / Emoji before nav itemhammer_and_wrenchRepository [GitHub - VaperinaDEV/discourse-nav-item-icon-emoji: Add Icon / Emoji before nav item · GitHub](https://github.com/VaperinaDEV/discourse-nav-item-icon-emoji)questionInstall Guide [How to install a theme or theme component](https://meta.discourse.org/t/how-do-i-install-a-theme-or-theme-component/63682)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Hello wave With this theme component you can add icon or emoji before nav items. The theme component based o…

---

<div class="post-metadata">

### Author: ![Aaron\_Walsh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aaron_walsh/32/312661_2.png) [@Aaron\_Walsh](https://meta.discourse.org/u/Aaron_Walsh)
#### Post date: [March 27, 2024, 6:30am UTC](https://meta.discourse.org/t/discourse-easy-svg-icon-and-emoji-in-css/300656/12 "2024-03-27T06:30:20Z")

</div>

You are awesome! Thank you!
