Flaticon Icon Font Integration Documentation
This documentation covers the Flaticon icon font integration provided by the SCSS and demo HTML files located under linuxfront-v2-logistics/css/flaticons. It explains:
- How the font is registered and optimized
- How icon glyphs are mapped to CSS classes
- SCSS variables for programmatic use
- A demo HTML page illustrating usage
Font Registration 📦
The SCSS file registers the Flaticon webfont and provides fallbacks for various browser engines.
@font-face {
font-family: "Flaticon";
src: url("./Flaticon.eot");
src: url("./Flaticon.eot?#iefix") format("embedded-opentype"),
url("./Flaticon.woff") format("woff"),
url("./Flaticon.ttf") format("truetype"),
url("./Flaticon.svg#Flaticon") format("svg");
font-weight: normal;
font-style: normal;
}
@media screen and (-webkit-min-device-pixel-ratio: 0) {
@font-face {
font-family: "Flaticon";
src: url("./Flaticon.svg#Flaticon") format("svg");
}
}
- Formats supported: EOT, WOFF, TTF, SVG
- Fallback hack: Ensures SVG font is used on WebKit devices when needed
Base Icon Selector 🎨
A universal selector sets up the icon environment:
.fi:before {
display: inline-block;
font-family: "Flaticon";
font-style: normal;
font-weight: normal;
font-variant: normal;
line-height: 1;
text-decoration: inherit;
text-rendering: optimizeLegibility;
text-transform: none;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
.fi:beforeapplies to any element with classfi- Ensures crisp rendering and consistent sizing
Glyph Class Mapping
Each icon is exposed via a CSS class that injects its Unicode glyph. The naming convention follows:
.flaticon-{icon-name}:before { content: "{unicode}"; }
| Class | Unicode | Example Usage |
|---|---|---|
.flaticon-add |
\f104 |
<i class="fi flaticon-add"></i> |
.flaticon-address |
\f107 |
<span class="fi flaticon-address"></span> |
.flaticon-logistics |
\f18c |
<i class="fi flaticon-logistics"></i> |
.flaticon-zooming |
\f1ff |
<i class="fi flaticon-zooming"></i> |
Full list: Over 500 icon classes are defined in the file
SCSS Variables ⚙️
To leverage icon codes programmatically, SCSS variables mirror each glyph’s Unicode value:
$font-Flaticon-add: "\f104";
$font-Flaticon-address: "\f107";
$font-Flaticon-logistics: "\f18c";
$font-Flaticon-zooming: "\f1ff";
Example: Using Variables in SCSS
.my-custom-icon:before {
content: $font-Flaticon-add;
font-family: "Flaticon";
font-size: 24px;
color: #007bff;
}
- Benefit: Centralizes Unicode values for maintenance and theming
Demo Page Explanation 🔍
The provided flaticon.html showcases how to include and use the icon font:
<!DOCTYPE html>
<html>
<head>
<title>Flaticon WebFont Demo</title>
<!-- Google Font for base text -->
<link href="http://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
<!-- Flaticon CSS -->
<link rel="stylesheet" href="flaticon.css">
<meta charset="UTF-8">
<style>
/* Basic reset and demo layout */
[class^="flaticon-"]:before {
font-family: Flaticon;
font-size: 30px;
margin-left: 20px;
color: #333;
}
.iconsuse { margin: 1em; }
.glyph { display: inline-block; width: 120px; text-align: center; }
.class-name { font-size: 0.9em; margin-top: 0.5em; }
</style>
</head>
<body>
<section class="iconsuse">
<div class="glyph">
<div class="glyph-icon flaticon-2412"></div>
<div class="class-name">.flaticon-2412</div>
<div class="author-name">Author: GraphBerry</div>
</div>
<!-- Additional glyphs… -->
</section>
</body>
</html>
- Reset styles ensure consistent appearance across browsers
.iconsuseand.glyphclasses arrange icon examples- Author attribution included per glyph as generated by flaticon.com
Usage Guidelines
- Include
flaticon.cssin your project before using any.flaticon-*classes. - Combine the base class
fiwith icon-specific classes:<i class="fi flaticon-delivery16"></i> - Customize size and color via CSS:
.fi.flaticon-delivery16 { font-size: 40px; color: #28a745; } - Access Unicode values with SCSS variables for dynamic or themed usage.
Summary
The _flaticon.scss file provides a comprehensive integration of the Flaticon icon set:
- Font registration with fallbacks for broad compatibility
- Utility base class for consistent icon rendering
- Over 500 glyph classes mapping semantic names to Unicode
- SCSS variables for maintainable theming
- Demo HTML illustrating practical usage
This setup offers a scalable, performant, and flexible approach to embedding vector icons in your web project.