Using Font Awesome in Vue3 with Bulma - html

How should Font Awesome be used with Vue? I have vue-fontawesome added to my project, as well as Bulma, so am I supposed to intermix the two? Or choose one or the other? I would like to be able to use Bulma's classes for coloring the icons.
Vue-fontawesome shows using this syntax:
<font-awesome-icon icon="address-card" />
and Bulma shows using this syntax:
<span class="icon">
<i class="fas fa-home"></i>
</span>
Questions:
If I am supposed to intermix the two, how should the html syntax look?
If I can only choose one or the other, what would be the limitations of each?

<font-awesome-icon> is just a convenience component. When you check your resulting HTML, you will find it renders <i class="fas fa-home"></i>.
The above statement is of course really simplified. In my projects I am using the SVG icons, so <font-awesome-icon> will render as <svg>...</svg>.
Bulma's HTML provides a container to put an arbitrary icon into it. That can be Font Awesome, but it can also be something else. It just provides the layout.
With that in mind, I would answer your questions:
Just put the icon (Font Awesome) into the container (Bulma)
<span class="icon">
<font-awesome-icon icon="address-card" />
</span>
To color the icon, Bulma's helpers work just fine:
<span class="icon has-text-danger">
<font-awesome-icon icon="exclamation" />
</span>
Does not apply, since both of them serve different purposes and complement each other.

Install Font Awesome package
npm install --save #fortawesome/fontawesome-free
Then load its CSS files
import '#fortawesome/fontawesome-free/css/all.min.css'
Example loading it globally
// Vue.js 3
import { createApp } from 'vue'
import App from './App.vue'
import "bulma/bulma.sass"
import '#fortawesome/fontawesome-free/css/all.min.css'
createApp(App).mount('#app')
Its is an Vue 3 example, but should work the same way on Vue 2 apps if the same steps are followed.

Related

How can i make changes in imported react icon using styled components

I am using styled component library to style my website. I want to do changes in my imported react icon component.
for example: if I am use normal CSS then I can easy make changes in
<i class="fab fa-facebook"></i>
by targeting <i> tag in CSS.
but in react I am using react-icon library and i used that icon as component.
for example:
<FaGithub />
how can I make changes like font-size and line-height in that component without using inline CSS and using styled component.
Colours of some icons cant be changed.
Still, there are two ways to do this.
There are some changes that you need to make to your code.
For example your code is like this
<div className="randomClass">
<FaGithub />
</div>
Then at the bottom of the page at the last line you need to style it like this.
const Github = styled(FaGithub)`
color: purple;
transform: scale(2);
margin: 5%;
`;
Once it is done what you need to do is, you need to rename the components to the styled components we created.
//So, instead of
<div className="randomClass">
<FaGithub />
</div>
// It will become
<div className="randomClass">
<Github />
</div>
For a different approach, you can visit here

Have Two Font Awesome Icons in One i Tag

I've been scouring the web, and I can't find an answer to this. Is there away to add two Font Awesome icons in one i tag?
I can do it if I put two i tags side by side, like this:
Good for: <i class="fa fa-male fa-2x"></i><i class=" fa fa-female fa-2x"></i>
So is there anyway to do this?
Glyph-based fonts like this generally function by changing the content of the element to a specific value, which the font picks up and renders as the appropriate glyph.
So it's unlikely that you'll be able to use a single tag to display both of them unless the library provides specific syntax for handling that behavior on it's own (similar to how Font Awesome uses stacking).
This is not possible in a single <i> tag, reason is the way how the glyph identifying classes are applied. For longer or dynamic sequences you can however directly use the icons codes in markup notation:
html: <span class="font-awesome">&#xf183&#xf182</span>
css: .font-awesome { font-family: FontAwesome; }
This obviously requires that you load the font as FontAwesome.
I created a fiddler as simple demonstration: https://jsfiddle.net/6ofmn36g/
I do agree though that this is an approach that is somewhat hard to read, though...
With Font Awesome 5, it's possible!
Masking
Combine two icons create one single-color shape, thanks to the power of SVG in Font Awesome 5! Use it with our new Power Transforms for some really awesome effects.
Go through the Masking section in this link.
The below snippet is a small working example taken from their site
<!-- Important : Use the SVG & JS method and reference the Js file, not the CSS file -->
<script src="https://use.fontawesome.com/releases/v5.0.13/js/all.js"></script>
<div class="fa-4x">
<i class="fas fa-pencil-alt" data-fa-transform="shrink-10 up-.5" data-fa-mask="fas fa-comment" style="background:MistyRose"></i>
<i class="fab fa-facebook-f" data-fa-transform="shrink-3.5 down-1.6 right-1.25" data-fa-mask="fas fa-circle" style="background:MistyRose"></i>
<i class="fas fa-headphones" data-fa-transform="shrink-6" data-fa-mask="fas fa-square" style="background:MistyRose"></i>
</div>
Not possible with current library of FontAwesome. But there are work arounds as arkascha has suggested below.
Additional Info:
Not exactly what you are asking for But I think this will help you, Also future crowd who falls into this thread with the title.
I had answered similar stuff... Here
https://stackoverflow.com/a/36491858/2592042
You can also build a custom icon by using set of icons available in the font-awesome icon set by stacking and aligning them accordingly. Stacked Icons
Example:
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="fa-stack fa-lg">
<i class="fa fa-male fa-stack-1x"></i>
<i class="fa fa-female fa-stack"></i>
</span>

Font awesome icons don't work

I'm having a problem with Font Awesome. In the following jsfiddle you can see that I am getting some really weird character instead of a bluetooth icon
https://jsfiddle.net/petarvasilev/q5bjz945/2/
this is the code that I am using
<div class="fa-bluetooth fa-4x"></div>
and this is the link I am using to import font awesome
https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css
any help much appreciated : )
There is no need to include font itself. This is how you should use it:
<div class="fa fa-bluetooth fa-4x"></div>
You are missing "FA" class name for your icon.

Font awesome does not show all icons in JSF app [duplicate]

This question already has answers here:
How to use 3rd party CSS libraries such as Font Awesome with JSF? Browser can't find font files referenced in the CSS file
(5 answers)
Closed 7 years ago.
I would like to use font awesome within my jsf app, but unfortunately it seems, that some icons are not displayed.
Instead of the icon I just could see a square symbol.
My jsf page look like this:
<div class="centerbox" style="bottom: 5mm; top: 5mm;">
<i class="fa fa-chain fa-5x"></i>
<i class="fa fa-wheelchair fa-5x"></i>
<h:outputLabel value="#{msg.systemNotAvailable}" />
<h:outputText value="Allocation"/>
</div>
I included the css file as follows:
<h:outputStylesheet name="font-awesome.css" library="css" media="screen"/>
The strangs thing is, that the fa-chain icon is displayed correct, but the wheelchair icon not.
When I look into the html and change the code of the icon, it seems that there are a couple of icons not working.
I tried this with the lated version 4.4.0
Does anybody else face this problem or can give me a hint how to fix?
You can always use the live css from MaxCDN, example:
http://jsfiddle.net/web_nfo/zfdgna5w/
https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css
( Source: https://fortawesome.github.io/Font-Awesome/get-started/#bootstrapcdn )
Maybe the font files (fontawesome-webfont.eot, fontawesome-webfont.woff2, etc) are not loaded properly. In the css there are some relative paths, if you do not have the fonts on your (local) server it does not work.
first of all thanks for your reply.
I think the problem was, that the font files were installed in resource folder in webapp.
Since I put it into the WebContent- root all icons could be displayed.
Thank you very much for your support :-)

Where "icon-remove-sign" has gone in Font Awesome 4.0.3

Font Awesome has recently changed icons notation from for example icon-shield to fa-shield.
But where has icon previously known as icon-remove-sign gone in the same time? I can't find it anywhere within Font Awesome 4.0.3 icon list. Actually I don't see anything with remove in name or anything that would "accompany" (as opposite) icon (now called) fa-check.
In general, nearly every FA's "yes"-like icons have their counterparts ("no"-like icons). In general, you have variety of icon-sets for both "success" and "fail"-like situations. But this one is clearly missing.
It appears the icon is now called fa-times: http://fontawesome.io/icon/times/.
At least as I understood the changes, the names should be more consistent with the actual icon shape, and "times" is the correct name for ×.
The exact missing icon-remove-sign in Font Awesome 4.0 is fa-times-circle
<i class="fa fa-times-circle"></i>
and variation
<i class="fa fa-times-circle-o"></i>