Edit: workaround for CSS variables:
The font awesome CSS file contains the @ font-face definition, which currently does not work in shadowDOM, at least in Chrome ( ref1 , ref2 ). One way is to move the @ font-face definition from the CSS fa file and place it as a global style tag. For instance:
<html> <head> <style> @font-face { font-family: 'FontAwesome'; src: url('font-awesome-4.0.3/fonts/fontawesome-webfont.eot?v=4.0.3'); src: url('font-awesome-4.0.3/fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'), url('font-awesome-4.0.3/fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'), url('font-awesome-4.0.3/fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('font-awesome-4.0.3/fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg'); font-weight: normal; font-style: normal; } </style> <script type='application/dart'>export 'package:polymer/init.dart';</script> <script type="text/javascript" src="packages/browser/dart.js"></script>
You can then reference the local copy of the edited CSS CSS file inside your custom polymer element without having to use applyAuthorStyles as follows:
<polymer-element name="dropdown-menu-element"> <template> <link rel="stylesheet" href="../font-awesome-4.0.3/css/font-awesome.css">
Make sure you upload the entire fa directory to your project. The fa badges can now be used in your polymer element.
Original answer using applyAuthorStyles:
I will just add an awesome font path in the head section of index.html:
<head> <title>Working with Polymer</title> <link rel="stylesheet" href="css/font-awesome-4.0.0/css/font-awesome.min.css"> <link rel="import" href="elements/navbar_element.html"> <script type='application/dart'> export 'package:polymer/init.dart'; </script> <script type="text/javascript" src="packages/browser/dart.js"></script> </head>
Then, in my navbar_element.html file navbar_element.html I simply refer to the icons the way you normally would:
<polymer-element name="navbar-element"> <template> <style> /* other styles here */ } </style> <div> <div class="st-container"> <nav class="st-nav"> <template repeat="{{item in menu}}" > <a id={{item.id}} href="#" class={{item.arrowClass}} on-click="{{menuHandler}}"> <span class="menuName">{{item.text}} </span> <i class={{item.icon}}></i> </a> </template> <div class="arrow_box"></div> </nav> </div> </div> </template> <script type="application/dart" src="navbar_element.dart"></script> </polymer-element>
In this case, I refer to the special font awesome icon <i class={{item.icon}}></i> in the navbar_element.dart file using the observed list:
final ObservableList<Item> menu = toObservable([ new Item('Fourier', 'fourier', 'fa fa fa-sort-amount-desc fa-rotate-270', false), new Item('Sequences', 'sequence', 'fa fa-tasks', false), new Item('Convolution', 'convolution', 'fa fa-asterisk', true), new Item('Deconvolution', 'deconvolution', 'fa fa-headphones fa-rotate-90', false), new Item('Filters', 'filter', 'fa fa-filter', false) ]);
where the icon field is just a field in the Item class, and I set bool get applyAuthorStyles => true; .