From text to icon

AI-generated summary

In the discussion From text to icon, Radu asks how to replace text with an SVG icon using CSS. NateDhaliwal responds that the SVG file needs to be uploaded and then referenced in the CSS using a variable name. CocoQuark suggests a helper tool for using icons in CSS.

After some clarification from NateDhaliwal, Radu understands the process. However, Radu then asks if multiple icons need to be uploaded separately, to which NateDhaliwal responds affirmatively. NateDhaliwal also provides an alternative guide for uploading multiple icons at once.

Radu then asks how to use a Font Awesome icon in the CSS content property. NateDhaliwal suggests downloading the icon as an SVG or creating a component. Radu wants to know if it’s possible to use a Font Awesome class in the content property, but NateDhaliwal advises against it and recommends uploading the SVG file instead. Ultimately, Radu decides to use Font Awesome as a font family with Unicode characters in the content method.

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.

Don made a helper tool for using icons in CSS:

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:

Much appreciated @Canapin, 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!

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.

@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:

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.

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.