ember-font-awesome 0,0,0,0 editorconfig eslint jscs travis-ci Bower npm

ember-cli addon for using Font Awesome icons in Ember apps

3 years after

ember-font-awesome

npm version Build Status Ember Observer Score

An ember-cli addon for using Font Awesome icons in Ember applications.

WARNING: Please verify that you are reading the README corresponding with the version of ember-font-awesome you are using.

Table of Contents

Ember Version Compatibility

Please consult the table to check which version of ember-font-awesome you should use:

Addon version Ember version Addon name
>= 2.0.0, < 3.0.0 >= 2.3.0 ember-font-awesome
>= 1.0.0, < 2.0.0 >= 1.11.0 ember-cli-font-awesome
>= 0.1.0, < 1.0.0 >= 1.13.0 ember-cli-font-awesome
0.0.9 < 1.11.0 ember-cli-font-awesome

Installing the Add-on

In your application's directory:

$ ember install ember-font-awesome

If you have manually installed or updated the addon via NPM then you should also run:

$ ember generate ember-font-awesome

Using the Add-on

Use the component in your Handlebars templates:

{{fa-icon "camera"}}

This will render:

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

To see which icons are available please check the complete list of Font Awesome icons

The Font Awesome examples illustrate the various options and their effects. It should be fairly simple to map these options to their {{fa-icon}} counterparts.

Larger Icons

{{fa-icon "star" size="lg"}}
{{fa-icon "star" size=2}}
{{fa-icon "star" size=3}}
{{fa-icon "star" size=4}}
{{fa-icon "star" size=5}}

Fixed Width Icons

<div class="list-group">
  <a class="list-group-item" href="#">
    {{fa-icon "home" fixedWidth=true}} Home
  </a>
  <a class="list-group-item" href="#">
    {{fa-icon "book" fixedWidth=true}} Library
  </a>
</div>

List Icons

{{#fa-list as |l|}}
  <li>{{l.fa-icon "check-square"}}List icons</li>
  <li>{{l.fa-icon "check-square"}}can be used</li>
  <li>{{l.fa-icon "spinner" spin=true}}as bullets</li>
  <li>{{l.fa-icon "square"}}in lists</li>
{{/fa-list}}

Bordered & Pulled Icons

<p>
{{fa-icon "quote-left" pull="left" border=true}}
...tomorrow we will run faster, stretch out our arms farther...
And then one fine morning— So we beat on, boats against the
current, borne back ceaselessly into the past.
</p>

Animated Icons

{{fa-icon "spinner" spin=true}}
{{fa-icon "circle-o-notch" spin=true}}
{{fa-icon "refresh" spin=true}}
{{fa-icon "cog" spin=true}}
{{fa-icon "spinner" pulse=true}}

Rotate & Flipped

{{fa-icon "shield"}} normal
{{fa-icon "shield" rotate=90}} rotated 90 degrees
{{fa-icon "shield" rotate=180}} rotated 180 degrees
{{fa-icon "shield" rotate=270}} rotated 270 degrees
{{fa-icon "shield" flip="horizontal"}} flipped horizontal
{{fa-icon "shield" flip="vertical"}} flipped vertical

Stacked Icons

{{#fa-stack size="lg" as |s|}}
  {{s.stack-2x "square-o"}}
  {{s.stack-1x "twitter"}}
{{/fa-stack}}

{{#fa-stack size="lg" as |s|}}
  {{s.stack-2x "circle"}}
  {{s.stack-1x "flag" inverse=true}}
{{/fa-stack}}

{{#fa-stack size="lg" as |s|}}
  {{s.stack-2x "square"}}
  {{s.stack-1x "terminal" inverse=true}}
{{/fa-stack}}

{{#fa-stack size="lg" as |s|}}
  {{s.stack-2x "square"}}
  {{s.stack-1x "terminal" class="text-danger"}}
{{/fa-stack}}

The aria-hidden Attribute

To better support accessibility (i.e. screen readers), the helper adds the aria-hidden attribute by default:

{{fa-icon "star"}}

Results in:

<i class="fa fa-star" aria-hidden="true"></i>

To remove the aria-hidden attribute:

{{fa-icon "star" ariaHidden=false}}

Actions

You can respond to actions on the icon by passing on action handlers:

{{fa-icon "star" click=(action "myClickHandler")}}

Tag Name

Use tagName to control the generated markup:

{{fa-icon "star" tagName="span"}}

Results in:

<span class="fa fa-star"></span>

Custom Class Names

{{fa-icon "bicycle" class="my-custom-class"}}

Results in:

<i class="fa fa-bicycle my-custom-class"></i>

Title attribute

{{fa-icon "edit" title="Edit the item"}}

Results in:

<i class="fa fa-edit" title="Edit the item"></i>

Customize with Sass/Scss or Less

If you are using the ember-cli-sass or ember-cli-less addon, you can opt-in to the Scss or Less version of font-awesome by adding the following configuration in ember-cli-build.js:

var app = new EmberApp({
  'ember-font-awesome': {
    useScss: true, // for ember-cli-sass
    useLess: true  // for ember-cli-less
  }
});

Then in your app.scss or app.less:

@import "font-awesome";

Excluding assets

You can configure the addon to not import any assets (CSS or font files) by adding the following configuration in ember-cli-build.js:

var app = new EmberApp({
  'ember-font-awesome': {
    includeFontAwesomeAssets: false
  }
});

In addition, you can configure the addon to just exclude the font file assets by adding the following configuration in ember-cli-build.js:

var app = new EmberApp({
  'ember-font-awesome': {
    includeFontFiles: false
  }
});

Output path

You can change the directory where the fonts are copied to using the following configuration:

var app = new EmberApp({
  'ember-font-awesome': {
    fontsOutput: "/some/dir/"
  }
});

This is useful when you change the output paths for your ember app. By default, ember-font-awesome copies the font files to /dist/fonts. The addon produces a css file to load the fonts that will be included in the vendor css file and expect to find the fonts at ../fonts. If the css directory is not at the same level as the fonts directory, the site won't load the fonts.

For example, moving the css directory to /dist/assets/css would require the fonts directory to be /dist/assets/fonts and the configuration would look like this:

var app = new EmberApp({
    outputPaths: {
        app: {
            css: {
                  app: "/assets/css/app-name.css",
            },
            js: "/assets/js/app-name.js",
        },

        vendor: {
            css: "/assets/css/vendor.css",
            js: "/assets/js/vendor.js",
        },
    },
    'ember-font-awesome': {
        fontsOutput: "/assets/fonts"
    }
});

License

Public Domain

Related Repositories

awesome-cheatsheet

awesome-cheatsheet

:beers: awesome cheatsheet ...

awesome-opensource-documents

awesome-opensource-documents

:blue_book: A curated list of awesome open source or open source licensed docume ...

awesome-frontend

awesome-frontend

A curated list of amazingly awesome frontend libraries, resources and shiny thin ...

awesome-frontend

awesome-frontend

Awesome frontend, also my collections. ...

sl-ember-components

sl-ember-components

An Ember CLI Addon that provides a variety of UI components. ...


Top Contributors

martndemus lfridael Panman8201 homu badazz91 suluke quaertym ajcobo runspired ChrizzDF gcollazo jcano joedaniels29 rwjblue SebastianEdwards

Dependencies

package version
broccoli-funnel ^1.2.0
chalk ^1.1.3
ember-cli-babel ^6.0.0
ember-cli-htmlbars ^2.0.2
font-awesome ^4.7.0
dev broccoli-asset-rev ^2.4.5
ember-ajax ^3.0.0
ember-cli 2.13.2
ember-cli-dependency-checker ^2.0.1
ember-cli-eslint ^4.0.0
ember-cli-htmlbars ^1.1.1
ember-cli-htmlbars-inline-precompile ^0.4.0
ember-cli-inject-live-reload ^1.4.1
ember-cli-qunit ^4.0.0
ember-cli-release ^0.2.9
ember-cli-shims ^1.1.0
ember-cli-sri ^2.1.0
ember-cli-uglify ^1.2.0
ember-disable-prototype-extensions ^1.1.2
ember-export-application-global ^2.0.0
ember-load-initializers ^1.0.0
ember-resolver ^4.0.0
ember-source ~2.13.0
loader.js ^4.2.3

Releases

-   2.2.0 zip tar
-   2.1.1 zip tar
-   2.1.0 zip tar
-   2.0.0 zip tar
-   1.5.0 zip tar
-   1.4.2 zip tar
-   1.4.1 zip tar
-   1.4.0 zip tar
-   1.4.0-beta.1 zip tar
-   1.3.0 zip tar
-   1.2.0 zip tar
-   1.1.1 zip tar
-   1.1.0 zip tar
-   1.0.0 zip tar
-   0.1.1 zip tar
-   0.1.0 zip tar
-   0.0.9 zip tar
-   0.0.8 zip tar
-   0.0.7 zip tar
-   0.0.6 zip tar
-   0.0.5 zip tar
-   0.0.4 zip tar
-   0.0.3 zip tar
-   0.0.2 zip tar
-   0.0.1 zip tar