[cXF] Navigation tab icons for custom tabs

[cXF] Navigation tab icons for custom tabs

UnstucK

Administrator

Staff member
Vip Member
Reputation: 100%
Reaction score
48
Points
55

Have you created your own navigation tab and want to add icon?


Compatibility with XenForo: 2.2, 2.3

Have you created your own navigation tab and want to add icon?


Use inspect element in your browser and hover over your tab. For details check image below:

[XFTech]-cXF Navigation tab icons for custom tabs-1.webp


For that tab just add this code to your existing one (for example before the last } in above code):

CSS:
[data-nav-id="membership"]:before {
       .m-faContent(@fa-var-star);
       color: #E6BB5C;
       padding-right: 5px;
   }

CSS:
[data-nav-id="membership"]:before {
       .m-faBase();
       .m-faContent(@fa-var-star);
       color: #E6BB5C;
       padding-right: 5px;
   }

Do you want to have a different icon or its color for a selected tab?

Below it's a code example for Forums tab. Add this code to your extra.less and edit to suit your needs:

CSS:
/* Selected tabs */
.p-navEl.is-selected {
   [data-nav-id="forums"]:before {
       .m-faContent(@fa-var-star);
       padding-right: 5px;
       color: #E6BB5C;
   }
}
/* Selected tabs for off-canvas (mobile) menu */
.offCanvasMenu--nav .offCanvasMenu-linkHolder.is-selected {
   [data-nav-id="forums"]:before {
       .m-faBase();
       .m-faContent(@fa-var-star);
       padding-right: 5px;
       color: #E6BB5C;
   }
}

CSS:
/* Selected tabs */
.p-navEl.is-selected {
   [data-nav-id="forums"]:before {
       .m-faBase();
       .m-faContent(@fa-var-star);
       padding-right: 5px;
       color: #E6BB5C;
   }
}
/* Selected tabs for off-canvas (mobile) menu */
.offCanvasMenu--nav .offCanvasMenu-linkHolder.is-selected {
   [data-nav-id="forums"]:before {
       .m-faBase();
       .m-faContent(@fa-var-star);
       padding-right: 5px;
       color: #E6BB5C;
   }
}

Result:
[XFTech]-cXF Navigation tab icons for custom tabs-2.webp
 
Back
Top