Package detail

iconfonts

rstacruz4kMIT0.12.0

Fine-tuned icon fonts integration for Sass, Less and Stylus.

font awesome, fonts, icon, iconfonts

readme

Icon fonts

Fine-tuned icon fonts integration for Sass, Less and Stylus. Features the following icon sets:

Status

Installation

Manual: Get the files you need over at /stylesheets/ and put it in your project.

Bower: Using bower makes files available via bower_components/iconfonts/stylesheets/.

$ bower install iconfonts

In your less/sass/styl files:

@include '../bower_components/iconfonts/stylesheets/ionicons';

NPM: Using npm makes files available via node_modules/iconfonts/stylesheets/.

$ npm install iconfonts --save

In your less/sass/styl files:

@include '../node_modules/iconfonts/stylesheets/ionicons';

Rails: Use rails-assets.org.

source 'https://rails-assets.org' do
  gem 'rails-assets-iconfonts'
end

In your sass files:

@import 'iconfonts/stylesheets/ionicons';

npm version

Why is it needed?

This lets you use CSS definitions only for the icons you need, on the elements that you need them.

The CSS files that these fonts provide usually give you a lot of cruft, and defines all the classes in one giant file.

/* CSS */
.fa-user:before { content: '\f007'; }
.fa-film:before { content: '\f008'; }
.fa-th-large:before { content: '\f009'; }
... and 300 more

/* HTML */
<button class="btn btn-plus"><i class="fa fa-plus"></i> Add user</button>

I prefer to not have them in my CSS files unless I need them. This project lets you do that.

/* Stylus */
.btn-plus:before {
  fa-icon("plus");
  margin-right: 10px;
}

/* HTML */
<button class="btn-plus">Add user</button>

Setup

SCSS (example)

@import 'font-awesome';

/* embeds the @font-face. use this only once. */
@include fa-font();

button:before {
  @include fa-icon("music", 14px);
}

See a Sass file for more info.

SCSS on Rails without CDN's

Optional: If you're on Rails (with sass-rails), and prefer to keep the files in your project, download the font files to vendor/assets/images/. Afterwards, use xx-font-rails() instead of xx-font() to embed the @font-face. Usage is otherwise the same as above.

@import 'font-awesome';
@include fa-font-rails();

Stylus (example)

@require font-awesome

fa-font()

button:before
  fa-icon("music", 14px)

See a stylus file for more info.

Less (example)

@import 'font-awesome';
.fa-font();

button:before {
  .fa-icon("music");
  font-size: 14px;
}

See a less file for more info.

Less on Rails

If you're on Rails (with less-rails) and prefer to keep the files in your project, download the font files to vendor/assets/images/. Afterwards, use xx-font-rails() instead of xx-font() to embed the @font-face. Usage is otherwise the same as above.

@import 'font-awesome';
.fa-font-rails();

PostCSS + cssnext + postcss-import

@import 'iconfonts/stylesheets/font-awesome.cssnext.css';

@apply --fa-font;

button::before {
  @apply --fa-icon;
  @apply --fa-icon-music;
}

Thanks

Iconfonts © 2014-2017, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors.

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz

changelog

v0.12.0

Sep 25, 2017

  • #5 - Upgrade font-awesome (4.5 → 4.7) (@atomita)

v0.11.1

Mar 29, 2017

  • Remove a stray file.

v0.11.0

Mar 12, 2017

[v0.10.0]

Oct 14, 2016

  • Add support for ionicons 3 (ionicons@3.scss).

v0.9.0

Feb 22, 2016

v0.8.0

Dec 10, 2015

  • Always use HTTPS for fonts when available and deprecate the the of protocol-relative URLs. See the protocol-relative URL for details.

v0.7.0

January 24, 2015

  • Update PaymentFont to 1.0.0
  • Fix .less files's cachebusters to look consistent
  • Update ionicons to 2.0.1

v0.6.0

December 9, 2014

  • Add PaymentFont 0.1.0 (experimental)
  • Update ionicons to 2.0.0

v0.5.1

November 26, 2014

  • Update font-awesome to 4.2.0

v0.4.0

October 15, 2014

  • SCSS: fix. (it didn't work well at all before!)

v0.3.0

August 4, 2014

  • SCSS: Remove an extra variable definition that's not needed.
  • Released to the Bower registry.

v0.2.0

June 26, 2014

  • Update file comments to link to project page.
  • Officially support node-sass.
  • Ionicons: update comments to point to correct site URL.
  • SCSS: add xxx-font-rails() mixin for Rails integration.
  • Less: add xxx-font-rails() mixin for Rails integration.

v0.1.0

June 24, 2014

  • Update Elusive to v1.5.0.
  • Update FontAwesome to v4.1.0.
  • Add Foundation Icons General v1.5.2.
  • Update the sass and less templates to actually work.
  • Add more documentation comments.

v0.0.0

June 24, 2014

Initial release.