question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can i use font-awesome icons in pages-menu?

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request
  • question about the decisions made in the repository

I need to know how to use font-awesome icons in pages-menu, the demo describe this as possible, but i don’t know how to use that icons in pages-menu, i have tried so many things, like add icon: ‘fas fa-iconname’, or icon: {icon: ‘fas fa-iconname’, pack: ‘fontawesome’}, i don’t know what can i do for this works.

Current behavior: When is defined property “icon:” with some icon from font-awesome, icon is not showed.

Expected behavior: Is expected that icon be showed.

Steps to reproduce: Change an item from pages-menu, with property icon with font-awesome related string, like ‘fas fa-check’.

Related code:

          {
            title: 'Declarações',
            icon: 'fas fa-undo',
            link: '/layout/stepper',
          },

Other information:

npm, node, OS, Browser

NPM last version, Node.JS last version, windows 10, Chrome/Firefox

Angular, Nebular

Angular 8, Nebular 4.4.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
codesiddhantcommented, Mar 2, 2020

it is very easy to register and use your own custom icon in sidebar menu by following simple steps Step 1 (for registring the custom icon pack for your module ) go to this path “src\app\pages\pages.module.ts” Step 2 Mention this code export class PagesModule { constructor(iconsLibrary: NbIconLibraries) { iconsLibrary.registerSvgPack('myicon', { 'python': '<img src="../../assets/python.png" width="25px">', }); } } Step 3 go to this path “src\app\pages\pages.menu.ts” add your menu with icon like this { title: 'Dashboard', icon: { icon: 'python', pack: 'myicon'}, link: '/pages/dashboard', home: true, }, see the result here image

I appreciate that, but, i need to use FontAwesome icons as a pack, is impractical to register all icons manually on module constructor, and you explained how to use an SVG icon, not an FontAwesome Icon.

you can use this code to use font-awesome as icon pack in-app module (“src\app\pages\pages.module.ts”) export class PagesModule { constructor(iconsLibrary: NbIconLibraries) { iconsLibrary.registerFontPack('fa', { packClass: 'fa', iconClassPrefix: 'fa' }); iconsLibrary.registerFontPack('far', { packClass: 'far', iconClassPrefix: 'fa' }); // ... }); } } and in page-menu (“src\app\pages\pages.menu.ts”) { title: 'Dashboard', icon: { icon: 'beer', pack: 'fa'}, link: '/pages/dashboard', home: true, },

see result here image

1reaction
eqplanoFrontcommented, Mar 2, 2020

I see, i have tested now and it works, but the icon is too large, i think this is something about the font size.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Add Icons | Font Awesome Docs
To add an icon, you need to know a few bits of information: The shorthand class name for the style you want to...
Read more >
Import Icons | Font Awesome Docs
Here's a primer on Font Awesome icon naming and how to import from icon ... The first version of Font Awesome used web...
Read more >
Host Font Awesome Yourself
Using Web Fonts with CSS. The /css/all.css file contains the core styling plus all of the icon styles that you'll need when using...
Read more >
Use a Kit | Font Awesome Docs
Then just add it to the <head> of each template or page of your project that you want to use Font Awesome icons....
Read more >
Get Started with Font Awesome
You can download, customize, and use the icons and default styling manually. Both CSS and CSS Preprocessor (Sass and Less) formats are included....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found