We have a project that uses glyphicons intensively. Bootstrap v4 drops the glyphicon font altogether.
Is there an equivalent for icons shipped with Bootstrap V4?
http://v4-alpha.getbootstrap.com/migration/
Bootstrap 4 does not have its own icon library (Glyphicons from Bootstrap 3 are not supported in BS4). However, there are many free icon libraries to choose from, such as Font Awesome and Google Material Design Icons.
Free Alternatives to Glyphicons You can use both Font Awesome and Github Octicons as a free alternative for Glyphicons.
Bootstrap Versions The main differences between Bootstrap 5 and Bootstrap 3 & 4, is that Bootstrap 5 has switched to JavaScript instead of jQuery. Note: Bootstrap 3 and Bootstrap 4 is still supported by the team for critical bugfixes and documentation changes, and it is perfectly safe to continue to use them.
Migrating from Glyphicons to Font Awesome is quite easy.
Include a reference to Font Awesome (either locally, or use the CDN).
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
Then run a search and replace where you search for glyphicon glyphicon-
and replace it with fa fa-
, and also change the enclosing element from <span
to <i
. Most of the CSS class names are the same. Some have changed though, so you have to manually fix those.
You can use both Font Awesome and Github Octicons as a free alternative for Glyphicons.
Bootstrap 4 also switched from Less to Sass, so you might integerate the font's Sass (SCSS) into you build process, to create a single CSS file for your projects.
Also see https://getbootstrap.com/docs/4.1/getting-started/build-tools/ to find out how to set up your tooling:
/bootstrap
directory and run npm install
to install our local dependencies listed in package.json.gem install bundler
, and finally run bundle install
. This will install all Ruby dependencies, such as Jekyll and plugins.Font Awesome
font-awesome/scss
folder into your /bootstrap folderOpen your SCSS /bootstrap/bootstrap.scss
and write down the following SCSS code at the end of this file:
$fa-font-path: "../fonts"; @import "../font-awesome/scss/font-awesome.scss";
Notice that you also have to copy the font file from font-awesome/fonts
to dist/fonts
or any other public folder set by $fa-font-path
in the previous step
npm run dist
to recompile your code with Font-AwesomeGithub Octicons
octicons
folder into your /bootstrap
folderOpen your SCSS /bootstrap/bootstrap.scss
and write down the following SCSS code at the end of this file:
$fa-font-path: "../fonts"; @import "../octicons/octicons/octicons.scss";
Notice that you also have to copy the font file from font-awesome/fonts
to dist/fonts
or any other public folder set by $fa-font-path
in the previous step
npm run dist
to recompile your code with OcticonsGlyphicons
On the Bootstrap website you can read:
Includes over 250 glyphs in font format from the Glyphicon Halflings set. Glyphicons Halflings are normally not available for free, but their creator has made them available for Bootstrap free of cost. As a thank you, we only ask that you include a link back to Glyphicons whenever possible.
As I understand you can use these 250 glyphs free of cost restricted for Bootstrap but not limited to version 3 exclusive. So you can use them for Bootstrap 4 too.
bootstrap/scss
folder$bootstrap-sass-asset-helper: false; $icon-font-name: 'glyphicons-halflings-regular'; $icon-font-svg-id: 'glyphicons_halflingsregular'; $icon-font-path: '../fonts/'; @import "glyphicons";
npm run dist
to recompile your code with GlyphiconsNotice that Bootstrap 4 requires the post CSS Autoprefixer for compiling. When you are using a static Sass compiler to compile your CSS you should have to run the Autoprefixer afterwards.
You can find out more about mixing with the Bootstrap 4 SCSS in here.
You can also use Bower to install the fonts above. Using Bower Font Awesome installs your files in bower_components/components-font-awesome/
also notice that Github Octicons sets the octicons/octicons/octicons-.scss
as the main file whilst you should use octicons/octicons/sprockets-octicons.scss
.
All the above will compile all your CSS code including into a single file, which requires only one HTTP request. Alternatively you can also load the Font-Awesome font from CDN, which can be fast too in many situations. Both fonts on CDN also include the font files (using data-uri's, possible not supported for older browsers). So consider which solution best fits your situation depending on among others browsers to support.
For Font Awesome paste the following code into the <head>
section of your site's HTML:
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
Also try Yeoman generator to scaffold out a front-end Bootstrap 4 Web app to test Bootstrap 4 with Font Awesome or Github Octicons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With