xaoseric's avatar

Using Fontawesome 5 with Laravel

How would I use Fontawesome 5 with laravel, has anyone tried this?

0 likes
7 replies
5150studios's avatar

Hello!

are you using the standard .css file or are you using Less or Sass?

If it's just the standard .css file, just keep it in your /public/css or /public/fonts folder and then go with something like: <link rel="stylesheet" href="css/FONTAWESOME5_FILE_NAME.css" type="text/css"/> in your <head></head> section

bensholdice's avatar

I'm using 5.6 with Fontaweose 5 - can anyone suggest a way to only use selected icons, rather than including the entire set?

for example, instead of

import fontawesome from '@fortawesome/fontawesome';
import solid from '@fortawesome/fontawesome-free-solid';
fontawesome.library.add(solid);

can I do something like:

import fontawesome from '@fortawesome/fontawesome';
import faAddressBook from '@fortawesome/fontawesome-free-solid/faAddressBook.js';
fontawesome.library.add(faAddressBook);

Can't see why it doesnt work - npm run dev throws no errors but I dont see the icons in my view.

thanks in advance!

rodney.hess's avatar

@bensholdice - Assuming you haven't gotten this:

Within your assets/javascript file you will want something like this:

import {library, dom} from '@fortawesome/fontawesome-svg-core';
import {faCaretUp} from '@fortawesome/free-solid-svg-icons';
import {faCaretDown} from '@fortawesome/free-solid-svg-icons';
import {faStar} from '@fortawesome/free-solid-svg-icons';
import {faCheck} from '@fortawesome/free-solid-svg-icons';

library.add([faCaretDown, faCaretUp, faCheck, faStar]);

dom.watch();

This is based on this doc: https://fontawesome.com/how-to-use/on-the-web/advanced/svg-javascript-core

1 like

Please or to participate in this conversation.