Font awesome icons 2.3 - categories, nodes, prefixes, phrases, templates etc...

Font awesome icons 2.3 - categories, nodes, prefixes, phrases, templates etc...

Mr Lucky

Well-known member
Mr Lucky submitted a new resource:

Font awesome icons 2.3 - A general guide to using Font Awesome icons in xenforo 2.3

Introduction​

There are two main situations where you might use font awesome (or other ) icons.

Pseudo elements (before &/or after text)​

In this case you specify via CSS code that an icon appears before or after some text, e.g. a node title, prefix, or navigation item. This is usually done by adding some CSS code to the extra.less template.

For css pseudo elements (icon before/after text) use this format of code in extra.less...

Read more about this resource...
 
Great resource, questions about Font Awesome icons are recurring, we can direct members to this resource. 🙏

For reference I also offer this link:


@Mr Lucky it would have been visually comfortable to use the appropriate code blocks for each syntax, Less and HTML to name a few.
Furthermore, even if .m-faContent works correctly, as your resource only concerns XF 2.3 therefore the recommended syntax is rather .m-faIcon for what concerns Font Awesome icons. But using the .m-faContent syntax allows compatibility with XF 2.2...
 
About this:
Note that as well as inline CSS (as above style="...") you can alternatively define a class to use in your CSS (in template extra.less)
<xf:fa class="your-class" icon="fad fa-sparkles" aria-hidden="true" />

I usually add classes to FA icons this way:
HTML:
<xf:fa icon="fad fa-sparkless my-class" />

// even two classes

<xf:fa icon="fad fa-sparkless my-class another-class" />

it works very well.
I don't know if it's "academic" but it works, maybe @Jeremy P could confirm that it doesn't possibly cause problems later, elsewhere...
 
Of course, i'm dumb, in any case the second color property override the first one...
Maybe a clue here:
 
Less:
.your-icon
{
    transform: rotate(180deg); // rotation

    color: #000; // color

    .fa-secondary
    {
        color: #FFF; // secondary color (duotone)
    }
}

Unfortunately this doesn't seem to work with icons added via CSS (.m-faContent(@fa-var-duotone-star);) rather than <xf:icon>.

@Chris D

How do you specify primary and secondary colors when calling a duotone icon via CSS? class="fa-secondary" doesn't seem to get added unless the icon is added via <xf:fa icon="fa-music">. I'm trying to add icons to group banners but I can't seem to figure this out.
 
Back
Top Bottom