Code Monkey home page Code Monkey logo

font-awesome-sass's Introduction

FontAwesome::Sass

Gem Version

'font-awesome-sass' is a Sass-powered version of FontAwesome for your Ruby projects and plays nicely with Ruby on Rails, Compass, Sprockets, etc.

Refactored to support more Ruby environments with code and documentation humbly used from the excellent bootstrap-sass project by the Bootstrap team

Breaking Changes

With the update to Font Awesome 5.x there are some breaking changes that will effect your use of this gem. Some of the changes include:

  • Icon name changes
  • New icons
  • The use of an icon style (solid, regular, or brands)

You can find more detailed information on these changes on our Getting Started guide, our How to Use guide, and our Upgrading from Version 4 guide.

Installation

Please see the appropriate guide for your environment of choice:

a. Ruby on Rails

In your Gemfile include:

gem 'font-awesome-sass', '~> 5.9.0'

And then execute:

bundle install

Import the FontAwesome styles in your app/assets/stylesheets/application.css.scss. The font-awesome-sprockets file includes the sprockets assets helper Sass functions used for finding the proper path to the font file.

@import "font-awesome-sprockets";
@import "font-awesome";

If app/assets/stylesheets/application.css.scss does not exist then rename app/assets/stylesheets/application.css and add the @import statements below the *= require statements but outside of the comment block.

Rails Helper usage

With Font Awesome 5.x you now need to select what style of icon you want to use. Font Awesome 5.x has 3 styles:

  • solid (fas)
  • regular (far)
  • brands (fab)

In your view:

icon('fas', 'flag')
# => <i class="fas fa-flag"></i>
icon('far', 'address-book', class: 'strong')
# => <i class="far fa-address-book strong"></i>
icon('fab', 'font-awesome', 'Font Awesome', id: 'my-icon', class: 'strong')
# => <i id="my-icon" class="fab fa-font-awesome strong"></i> Font Awesome

Note: the icon helper can take a hash of options that will be passed to the content_tag helper

b. Compass without Rails

Install the gem

gem install font-awesome-sass

If you have an existing Compass project:

# config.rb:
require 'font-awesome-sass'

Import the FontAwesome styles

@import "font-awesome-compass";
@import "font-awesome";

Upgrading from FontAwesome::Sass 4.x

Prepend the style of the icon you want to use (fas, far, fab) class to existing icons:

4.x Syntax

<i class="fa fa-github"></i>

5.x Syntax (GitHub icon exists in the Brands style)

<i class="fab fa-github"></i>

font-awesome-sass's People

Contributors

supercodepoet avatar foobear avatar aderyabin avatar brandoncc avatar bonkydog avatar brianpattison avatar gnagel avatar henrik avatar jeltef avatar jokklan avatar mathieugagne avatar mkozono avatar kugaevsky avatar ourai avatar prdolmos avatar suprnova32 avatar paulmwatson avatar renatocarvalho avatar dlackty avatar mockdeep avatar sbonami avatar timvandijck avatar undr avatar

Watchers

James Cloos avatar

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.