Giter Site home page Giter Site logo

darkseal / bootstrap4-glyphicons Goto Github PK

View Code? Open in Web Editor NEW
40.0 2.0 75.0 1.01 MB

How use Glyphicons with Bootstrap 4 (without getting mad)

License: Apache License 2.0

bootstrap bootstrap4 glyphicons fontawesome workaround bootstrap4-glyphicons equivalent bootstrap3 css font-icons

bootstrap4-glyphicons's Introduction

bootstrap4-glyphicons

How to use Glyphicons with Bootstrap 4 (without getting mad)

For further info & samples, read the official page.

Introduction

If you stumbled upon this project you most likely already know Bootstrap, the award-winning and worldwide-renown open source toolkit for developing with HTML, CSS, and JS. As a matter of fact, you are probably struggling trying to switch from from Bootstrap 3 to Bootstrap 4. Among the many things that have changed (mostly summarized in the official Migration guide) there was the choice to drop the Glyphicons icon font.

If you need icons, the Bootstrap team suggest one of the following alternatives:

If you're migrating an existing website based on Bootstrap 3, the first option definitely seems the most viable one. However, the Glyphicons Basic set - the one available for free - does not cover all the icons which were available in Bootstrap, which open-source toolkit was granted with the permissions to use the Halflings set (as long as they provide a link and credits info).

Now, since Bootstrap 4 doesn't ship the Halflings set anymore, if you want to use that set you might need to pay: if you don't want to, you are basically forced to migrate from Glyphicons to a viable open-source alternative, such as the aforementioned Octicons and Font Awesome - the latter being personal preference, as its free set is good enough for most projects. However, that will undoubtely require some major HTML code rewrite, because you'll have to perform a manual mapping from something like this:

<span class="glyphicons glyphicons-home"></span>
<span class="glyphicons glyphicons-plus-sign"></span>
<span class="glyphicons glyphicons-hand-left"></span>

to something like this (in case of FontAwesome):

<span class="fas fa-home"></span>
<span class="fas fa-plus-circle"></span>
<span class="fas fa-hand-point-left"></span>

... and so on. Unfortunately, as you might see, the icon names might also be quite different, hence is not possible to search-and-replace them easily.

Alternatives

If you're building a brand new project, I strongly suggest to drop the Glyphicons package and to migrate to FontAwesome: not only you'll have more icons, but you'll also have the chance to seamlessly switch from Font icons to SVG icons, which is something that you will hardly ever regret (in case you don't know why, read here).

However, if you're dealing with an existing project which makes an extensive use of the Glyphicons Halflings set, you can install this package containing two viables workaround.

Installing

This package can be used in two alternative ways: Bootstrap 4+3 and FontAwesome Mapping.

Method #1: Bootstrap 4+3

This workaround leverages the fact that you can still use Bootstrap 3.x in addition to Bootstrap 4 without any issue of sort, as long as you only get only the "glyphicon part". You won't have any license issues, since you'll be actually using Bootstrap 3.

To implement this workaround, install the package into your web site and add the following within the <head> element:

<link href="/bootstrap4-glyphicons/css/bootstrap-glyphicons.min.css" rel="stylesheet" type="text/css" />

That's it.

Method #2: FontAwesome Mapping

Since any Glyphicon image has (more or less) their FontAwesome equivalent, we can map the various glyphycons* css classes to their fa* equivalent. This is the purpose of the file you can find in /maps/glyphicons-fontawesome.less , which will act as a transparent mapping bridge between Glyphicon and FontAwesome.

To implement this workaround, install the package into your web site and add the following within the <head> element:

<link href="/bootstrap4-glyphicons/maps/glyphicons-fontawesome.min.css" rel="stylesheet" type="text/css" />

The only caveat here is that you'll have to use the font-based icons instead of the SVG alternative (see above), but if you're a Glyphicon user you won't suffer from that: there's a much higher chance that you won't like the "new" icons... If you feel like that, just implement the Bootstrap 4+3 alternative instead.

Authors

License

This project is licensed under the APACHE 2.0 License - see the LICENSE.md file for details

bootstrap4-glyphicons's People

Contributors

chocolateboy avatar darkseal avatar dset0x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bootstrap4-glyphicons's Issues

npm package..

This is awesome. You should make an npm package for this.

json-schema-form has a hard dependency on the glyphicons.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.