The font-ionicons-rails is the best gem made for ionicons and provides the ionicons web fonts and stylesheets as a Rails engine for use with the asset pipeline.
Installation
Add this to your Gemfile:
gem "font-ionicons-rails"
or
gem "font-ionicons-rails", git: 'https://github.com/ricardoemerson/font-ionicons-rails.git'
and run bundle install
.
Usage
In your application.css
, include the css file:
/*
*= require ionicons
*/
Then restart your webserver if it was previously running.
Sass Support
If you prefer SCSS, add this to yourapplication.css.scss
file:
@import "ionicons";
If you use the Sass indented syntax, add this to your application.css.sass
file:
@import ionicons
Helpers
There are also some helpers (ion_icon
) for improve use.
ion_icon "camera"
# => <i class="ion-camera"></i>
ion_icon "camera", text: "Take a photo"
# => <i class="ion-camera"></i> Take a photo
ion_icon "chevron-right", text: "Get started", right: true
# => Get started <i class="ion-chevron-right"></i>
content_tag(:li, ion_icon("checkmark-round", text: "Bulleted list item"))
# => <li><i class="ion-checkmark-round"></i> Bulleted list item</li>
License
- The ionicons font is licensed under the MIT license.
Special Thanks
The font-ionicons-rails was inspired by font-awesome-rails made by David Bock.