# Discourse Icon

**URL:** https://meta.discourse.org/t/discourse-icon/143374
**Category:** Theme component
**Tags:** official, discourse-icon
**Created:** [March 5, 2020, 6:11am UTC](https://meta.discourse.org/t/discourse-icon/143374 "2020-03-05T06:11:14Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Discourse](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/discourse/32/148734_2.png) [@Discourse](https://meta.discourse.org/u/Discourse)
#### Post date: [March 5, 2020, 6:11am UTC](https://meta.discourse.org/t/discourse-icon/143374/1 "2020-03-05T06:11:14Z")

</div>

| | | |
| --- | --- | --- |
| :discourse2: | **Summary** | **Discourse Icon** allows you to use icons from your SVG icon subset in a post. |
| 👓 | **Preview** | [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/discourse-icon) |
| 🛠 | **Repository Link** | [https://github.com/discourse/discourse-icon](https://github.com/discourse/discourse-icon) |
| 📖 | **New 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

> [@](#):
>
> :discourse2: As this is an #official theme component maintained by the Discourse team, #Support, #Contribute > Bug, #Contribute > UX, and #Contribute > Feature requests can be made in the respective categories here on Meta, and tagged with the appropriate theme component tag. Click on a link below to get one started. 👍
> 
> [❓&nbsp; **Support**](https://meta.discourse.org/new-topic?category_id=6&tags=discourse-icon "Ask for support on configuring and using Discourse Icon") [🐛&nbsp; **Bug**](https://meta.discourse.org/new-topic?category_id=1&tags=discourse-icon "A bug report means something is broken, preventing normal/typical use of the theme component") [👀&nbsp; **UX**](https://meta.discourse.org/new-topic?category_id=9&tags=discourse-icon "Discussion about the user interface of Discourse Icon, and how features are presented (including language and UI elements)") [💡&nbsp; **Feature**](https://meta.discourse.org/new-topic?category_id=2&tags=discourse-icon "Discussion about how existing Discourse Icon features can be improved or enhanced, and how proposed new features could work")

### Features

Usage:

```plaintext
[wrap=icon id=square][/wrap]

```

Example:  
This is the icon and the icon.

```plaintext
This is the [wrap=icon id=far-square][/wrap] icon and the [wrap=icon id=pencil][/wrap] icon.

```

**Note:** if the icon doesn’t show it’s because it’s not in your subset. If you are admin you can add it in your site settings: `svg icon subset`.

  

> :discourse2: **Hosted by us?** Theme components are available to use on our Standard, Business, and Enterprise plans.

> Last edited by @kelv 2025-04-28T07:23:04Z
> 
> Last checked by @Muhammed_EKİCİ 2024-12-02T09:46:54Z
> 
> > **Check document**
> >
> > Perform check on document:

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [March 5, 2020, 7:16am UTC](https://meta.discourse.org/t/discourse-icon/143374/3 "2020-03-05T07:16:42Z")

</div>

Awesome! This is iconic!

(meta has many many themes, but luckily thanks to @kris.kotlarek we have an add to all themes button… got to sort out progress there, cause it takes a while to do its magic)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [March 5, 2020, 7:23am UTC](https://meta.discourse.org/t/discourse-icon/143374/4 "2020-03-05T07:23:03Z")

</div>

Yes didnt want to add to all for now, as I just finished coding it 😁 but will do now

Edit: oh already done

---

<div class="post-metadata">

### Author: ![maiki](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maiki/32/233950_2.png) [@maiki](https://meta.discourse.org/u/maiki)
#### Post date: [March 5, 2020, 6:31pm UTC](https://meta.discourse.org/t/discourse-icon/143374/5 "2020-03-05T18:31:05Z")

</div>

Thanks, that’s super fun! 🕶

I never got into BB script tags, nor have I hand-coded FontAwesome, so the practice of using an empty tag pair has always seemed strange to me. Is that by popular convention, or is there a webcraft reason for using tag pairs? Also, can they have stuff between them, does that affect the text?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [March 7, 2020, 12:20pm UTC](https://meta.discourse.org/t/discourse-icon/143374/6 "2020-03-07T12:20:33Z")

</div>

There are multiple causes here.

First when I wrote the wrap BBCode feature, @sam explicitly asked to me support 3 formats:

```plaintext
[wrap=foo][/wrap]
[wrap=foo]bar[/wrap]
[wrap=foo]
bar
[/wrap] 

```

This is done to be consistent with our existing BBCode usage in Discourse.

I could have a better syntax as: `[icon=times]` but then it would have to be a plugin and not a theme component.

As an experimentation, I think it’s fine as it is today, and if people were to use it a lot, we could think of having a plugin do this with a more concise syntax.

Another idea I have had is to add an API to add autocompletes symbol in the composer just like we have fore users/categories/emojis… But I’m afraid this would be a nightmare with multiple components choosing their own symbol…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 7, 2020, 12:26pm UTC](https://meta.discourse.org/t/discourse-icon/143374/7 "2020-03-07T12:26:57Z")

</div>

> [@j.jaffeux](#):
>
> I could have a better syntax as: `[icon=times]` but then it would have to be a plugin and not a theme component

Oh! I need to add support for another bbcode and those) thought that I’d use this as a starting point, but you’re saying that the wrap stuff is handled in core, which explains why I can’t find how it’s handled by your theme component.

My current solution is to use the linked words component and an ugly regex, but I’m still struggling to add the necessary classes to the links.

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [March 7, 2020, 12:28pm UTC](https://meta.discourse.org/t/discourse-icon/143374/8 "2020-03-07T12:28:09Z")

</div>

Yes read this topic to know more:

> [@Generic bbcode wrapper for theme components](https://meta.discourse.org/t/generic-bbcode-wrapper-for-theme-components/123516):
>
> I added this feature a while back and realised I didn’t post about it. You can now use a special syntax in markdown to have it cooked and usable in theme components without having to write a plugin. // wrapped in div.d-wrap [wrap=baz foo=bar]Content[/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] Content [/wrap] // wrapped in div.d-wrap [wrap=baz foo=bar] [/wrap] // this one will be rendered as a span.d-wrap instead of a div.d-wrap a [wrap=baz]Content[/wrap] b The name of the component w…

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 7, 2020, 12:34pm UTC](https://meta.discourse.org/t/discourse-icon/143374/9 "2020-03-07T12:34:13Z")

</div>

Right I’ve looked at it a dozen times. And printed out the code for your component and stared at it for hours, trying to understand if the degree to which it’s javascript or ember that I don’t understand. I can’t add a [foo] tag without a plugin? Or can I some how replace wrap in your code with foo to cover my new bbcode?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [March 7, 2020, 12:36pm UTC](https://meta.discourse.org/t/discourse-icon/143374/10 "2020-03-07T12:36:02Z")

</div>

No you can’t. Because part of it is server side. If you want your own custom BBCode you will have to write a plugin and look at how wrap is implemented for example:

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.js.es6](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/pretty-text/engines/discourse-markdown/d-wrap.js.es6)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [March 7, 2020, 12:43pm UTC](https://meta.discourse.org/t/discourse-icon/143374/11 "2020-03-07T12:43:25Z")

</div>

Thanks! It’s starting to make sense. I’ve not had this much trouble learning a new language since C++ and objective Pascal in 1990.

My current regex hack almost works. I’ll need to decide whether to go the plugin route or stick with my hack (and figure out how to add the classes).

At least now I understand why I can’t find that wrap in the theme component!

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [March 9, 2020, 10:03pm UTC](https://meta.discourse.org/t/discourse-icon/143374/12 "2020-03-09T22:03:30Z")

</div>

> [@j.jaffeux](#):
>
> I could have a better syntax as: `[icon=times]` but then it would have to be a plugin and not a theme component.

I can think of a few possible syntax layouts to add to the wrap plugin for this:

```
[wrap=foo /]
[wrap/=foo]

```

(mimicing XML’s self-closing tags) but those are both fairly ugly 😕

Anyone got amazing ideas for something that looks okay?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [March 9, 2020, 10:10pm UTC](https://meta.discourse.org/t/discourse-icon/143374/13 "2020-03-09T22:10:32Z")

</div>

yeh not a big fan of these 😕

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 24, 2023, 1:04pm UTC](https://meta.discourse.org/t/discourse-icon/143374/14 "2023-04-24T13:04:13Z")

</div>

I’ve found a big bug…

If you use an icon wrap and then highlight quote it the resulting image is wildly embiggened:

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/0/3/d03190a697ea905228fe56cec10056128cb6bd90.png)

- Use an icon wrap in a sentence in a post. eg `This is an icon [wrap=icon id=far-check-square][/wrap]`
- Highlight the relevant text and ‘Quote’
- Icon goes super big in quoted excerpt

This is what the syntax looks like when highlight quoted:

```plaintext
[quote="JammyDodger, post:1, topic:294, full:true"]
This is an icon ![](/svg-sprite/grumpy.jammydodger.monster/icon/222222/far-check-square.svg)
[/quote]

This is a reply where it gets massive

```

Though quoting it using the speech bubble in the format bar works fine.

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [April 24, 2023, 1:47pm UTC](https://meta.discourse.org/t/discourse-icon/143374/15 "2023-04-24T13:47:52Z")

</div>

How are you able to highlight quote the icon? On my test site, the icon is skipped.

 ![image](https://global.discourse-cdn.com/meta/original/4X/0/8/f/08f323a3672b5a119021a7c860c5ebf2ab023a6d.png)

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 24, 2023, 2:00pm UTC](https://meta.discourse.org/t/discourse-icon/143374/16 "2023-04-24T14:00:58Z")

</div>

I am not sure? I just use the mouse.

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

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [April 24, 2023, 2:09pm UTC](https://meta.discourse.org/t/discourse-icon/143374/19 "2023-04-24T14:09:12Z")

</div>

What browser are you using?

Using the mouse, I tested with Chrome and Firefox, and I could not select the icon. 🤔

* * *

EDIT:

If you wrap an icon unavailable in the current subset, it will create an SVG image instead.  
Then, you can quote it.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 24, 2023, 2:55pm UTC](https://meta.discourse.org/t/discourse-icon/143374/20 "2023-04-24T14:55:20Z")

</div>

> [@Arkshine](#):
>
> If you wrap an icon unavailable in the current subset, it will create an SVG image instead.

Can you provide an example? Your screenshot shows a ticked checkbox and I have no issue selecting it on my test instance (as well as other icons probably not used by Discourse like `x-ray`.

![](https://global.discourse-cdn.com/meta/original/4X/9/b/0/9b08ba9c1fddb9194f8bd2a60ce51d9cb998a2b9.gif)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [April 24, 2023, 3:02pm UTC](https://meta.discourse.org/t/discourse-icon/143374/21 "2023-04-24T15:02:31Z")

</div>

I see the issue. The component searches by looking at whether there is a wrapper with `d-wrap` class; but there is no wrapper if the provided icon is not from the subset. It creates an image as SVG instead.

For example:

> **SVG, icon within the subset**
>
> ![NVIDIA_Share_N77SdCXSsS](https://global.discourse-cdn.com/meta/original/4X/8/0/1/8013227f1347d3e088061cf27c183706cb4eed65.jpeg)

> **Image as SVG, icon not within the subset**
>
> ![NVIDIA_Share_bJkCF352Gr](https://global.discourse-cdn.com/meta/original/4X/2/b/0/2b0a286f33f94f26091cf03fe9aa13e073025a4b.jpeg)

If you quote the images, the component does nothing, as there is no wrapper (and the image is converted to markdown resulting in an image without any class)

> ****
>
> ![image](https://global.discourse-cdn.com/meta/original/4X/d/8/a/d8ad66d051caa5249ec08c5227797f3c755a720a.png)

---

<div class="post-metadata">

### Author: ![gormus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gormus/32/428592_2.png) [@gormus](https://meta.discourse.org/u/gormus)
#### Post date: [November 7, 2023, 6:44pm UTC](https://meta.discourse.org/t/discourse-icon/143374/22 "2023-11-07T18:44:07Z")

</div>

> [@joffreyjaffeux](#):
>
> **Note:** if the icon doesn’t show it’s because it’s not in your subset. If you are admin you can add it in your site settings: `svg icon subset`.

Does this mean I need to have an `svg_icons` field in `settings.yml` available in my theme? Or could I use any `svg_icons` field available from any enabled theme-components too? And if that is the case would adding this field to this theme-component make sense?

```yml
svg_icons:
  default: ''
  type: 'list'
  list_type: 'compact'

```

Because in my experience, the SVG icons are transformed to `<img />` tags, and they do not inherit the `currentColor` when the color scheme is changed:

Please compare the **Example** paragraph:

 ![Screenshot 2023-11-07 at 10.26.17 AM](https://global.discourse-cdn.com/meta/original/4X/9/d/5/9d5774c6f14283672ce3ec32f4dc7eea856e50e0.png)

 ![Screenshot 2023-11-07 at 10.26.49 AM](https://global.discourse-cdn.com/meta/original/4X/7/e/6/7e6e89abec7ea09ae5c2705cfe732f960d7eaefe.png)

 ![Screenshot 2023-11-07 at 10.27.09 AM](https://global.discourse-cdn.com/meta/original/4X/a/d/d/add9ae337294b0777cc0e41e454e7f0009d66242.png)

---

<div class="post-metadata">

### Author: ![thoka](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thoka/32/115652_2.png) [@thoka](https://meta.discourse.org/u/thoka)
#### Post date: [December 13, 2024, 5:55am UTC](https://meta.discourse.org/t/discourse-icon/143374/23 "2024-12-13T05:55:38Z")

</div>

Could the rendering in dark mode be enhanced?

 ![grafik](https://global.discourse-cdn.com/meta/original/4X/6/5/f/65f31a71b5a21b949cab6aaa7730c3ad9b13d73f.png)

Would love to have the same colors as in the interface:

 ![grafik](https://global.discourse-cdn.com/meta/original/4X/8/7/b/87bf3b803f72ac390932c24fb470e2660ae7d389.png)
