Font Awesome Cheatsheet
This post serves as my notebook for using Font Awesome icons on this blog (or any other rendered by Hugo engine). Get aclass
from Font Awesome website and use it as follows
:(fa-solid fa-house):
:(fas fa-clock):
which renders as
Sizing
FA provides list of standard sizes. Not only do these classes scale icons up or down but also provide appropriate vertical alignment. The following is the list of standard relative sizes provided by the library
Size | Font Size | Equivalent in Pixels | Example |
---|---|---|---|
fa-2xs | 0.625em | 10px | |
fa-xs | 0.75em | 12px | |
fa-sm | 0.875em | 14px | |
fa-lg | 1.25em | 20px | |
fa-xl | 1.5em | 24px | |
fa-2xl | 2em | 32px |
In addition to relative sizes, also literal sizes are available
Literal Sizing Class | Font Size | Example |
---|---|---|
fa-1x | 1em | |
fa-2x | 2em | |
fa-3x | 3em | |
fa-4x | 4em | |
fa-5x | 5em | |
fa-6x | 6em | |
fa-7x | 7em | |
fa-8x | 8em | |
fa-9x | 9em | |
fa-10x | 10em |
Animation
There are couple of animations built-in FA library. For more info follow here
Beat animation
Beat animation allows to draw attentions to a “living” object. Employfa-beat
to use it
:(fa-solid fa-heart fa-beat):
:(fa-solid fa-clock fa-beat):
which renders as
In order to obtain more control on animation one must use HTML syntax
<div class="fa-3x">
<i class="fa-solid fa-circle-plus fa-beat"></i>
<i class="fa-solid fa-heart fa-beat"></i>
<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 0.5s;" ></i>
<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 2s;"></i>
<i class="fa-solid fa-heart fa-beat" style="--fa-beat-scale: 2.0;"></i>
</div>
Spin animation
One of the most useful animations is a spin effect that is wrapped infa-spin
class:
:(fa-solid fa-sync fa-spin):
:(fa-solid fa-circle-notch fa-spin):
which render as
More advanced examples can be obtained as follows
<div class="fa-3x">
<i class="fa-solid fa-sync fa-spin"></i>
<i class="fa-solid fa-circle-notch fa-spin"></i>
<i class="fa-solid fa-cog fa-spin"></i>
<i class="fa-solid fa-cog fa-spin fa-spin-reverse"></i>
<i class="fa-solid fa-spinner fa-spin-pulse"></i>
<i class="fa-solid fa-spinner fa-spin-pulse fa-spin-reverse"></i>
</div>