RSS Feed/News How to dynamically use FontAwesome icons in CSS with XenForo templates?

Status
Not open for further replies.

ENXF NET

Administrator
Staff member
Administrator
Moderator
+Lifetime VIP+
S.V.I.P.S Member
S.V.I.P Member
V.I.P Member
Collaborate
Registered
Joined
Nov 13, 2018
Messages
27,880
Points
823

Reputation:

Hi all,

I'm developing a XenForo 2.3 add-on and need to show icons dynamically based on template variables.

I have a variable like {$item.iconClass} that contains icon classes such as "fal fa-award".

In HTML, this works fine:

<xf:fa icon="{$item.iconClass}" />

But I want to use these icons in CSS pseudo-elements with the .m-faContent() LESS mixin, like this:

Less:

Code:
&:before {
    .m-faContent({$item.iconClass});
}

This doesn't work because .m-faContent() expects a...

Read more

Continue reading...
 
Status
Not open for further replies.
Top