From text to icon

How can I replace the text from the screenshot with any other svg icon (any) using only CSS?

Much appreciated! :stuck_out_tongue_closed_eyes:

Youā€™ll need to first upload your SVG file in the Uploads section. For the SCSS variable name, do something short and succint.
Then, add this bit to the Common tab:

th.posts.sortable.num.topic-list-data {
  content: url($name-of-variable);
}

Note that you should not put quotes inside of the url parentheses.

4 Likes

Don made a helper tool for using icons in CSS:

5 Likes

Iā€™m sorry, I donā€™t get it. What do you mean with $name-of-variable? Iā€™m trying to add a SVG code after content:, and itā€™s not working. :ok_man:

1 Like

Much appreciated @CocoQuark, but Iā€™m not looking into installing more components in order to change the word ā€œrepliesā€ with an SVG code. :smiley:

The variable name is the one you entered when you uploaded the SVG file.

:warning: You will need to be an Admin to do this.


  1. Go to /admin on the forum.
  2. In the sidebar, choose Components under the Customizations section and make a new one.
  3. Upload the SVG file under Uploads at the bottom of the componentā€™s page.
  4. Choose a name for the variable (in the upload file modal)
  5. Use the code in my post:
  1. Replace name-of-variable with the name you chose in Step 4. Keep the $ before the variable name.
  2. Youā€™re good to go!
3 Likes

Thank you so much, Itā€™s very clear now.

Quick question: If I have letā€™s say 10 icons, do I need to upload the icons one by one?

Yes, I believe you do.

2 Likes

@Radu In the event my guide doesnā€™t work, you can follow this guide, where I believe you can just upload 1 file for multiple icons:

3 Likes

This was a great post and it helped me to replace the default icons. One more thing if I mayā€¦

In the following, how can I put a FontAwsome icon inside content?

th.topic-list-data.posts.num > span {
    visibility: hidden;
}

th.topic-list-data.posts.num > span:after {
    content:'a FontAwesome Icon here'; 
    visibility: visible;
    display: inline-block;
    padding-bottom: 1.2em;
}

You can download it as a SVG and then do the same thing. Otherwise, youā€™ll have to make a component, which will be more complex.

1 Like

So there is no way of doing something like this?

content:'fa d-icon d-icon-reply'; 

If not, how would the code look like for the following method? I just need an example from where to start, because I tried basic css and there is no effect.

Kindly appreciated!

No, but you can use the same method as you did with previous methods. Upload it, then add it as an SVG file you followed using the guide;

Iā€™m not too sure where you want to place the icon. Could you send a screenshot?
Thanks.

It doesnā€™t matter where, I just want to place a FA icon inside the line content:'...'

I think I will go with the FA as a font family and Unicodes inside the content method.

You could do this:

Iā€™m not 100% sure if this works, but Iā€™m quite sure it does.