How can i use fontawesome with ionic 2
, i've following this tutorial but it's not working.
相关问题
- How to use folium.icon with fontawesome
- Is there any way to make the background of a 3D-mo
- binding font-awesome character in XAML to Text
- How to use font awesome icons in jQuery mobile but
- Font Awesome 5 - Inversion of the icon position
相关文章
- How to show appropriate icon on dialog box
- How to style an unordered list with jQuery UI so t
- Can I set a different icon for the android task sw
- Ionic conditional class css
- I it possible to include external SVG defs
- After reseting plugins, Ionic 2 program doesn'
- How to create or customize a Toast view using ioni
- ruby not load font-awesome
Update for Ionic 2, Ionic 3+: just one step:
Add font-awesome link to your
index.html
There is still a lot of confusion on what is a best practice when it comes to adding FontAwesome to an ionic2 app. I wrote a tutorial about it to mitigate some of that confusion. I hope this helps anybody else out there looking for this info
http://luiscabrera.site/tech/2017/01/09/fontawesome-in-ionic2.html
I tried most of the answers above but they were either too complicated or had a limitation when the core of Ionic2 was upgraded so here is my solution:
It requires manually upgrading of FA when a new version comes out but I don't need to upgrade often as I only use a few select icons.
Ignore the SASS files and copy the contents of \node_modules\font-awesome\fonts to \src\assets\fonts. Also copy \node_modules\font-awesome\css\font-awesome.min.css to the same place.
Reference the csss in your index.html file like this:
Then to use it, put this into the page's scss:
and this in the html:
And that should be it...
Update in ionic 2 RC.0
To include your icon in HTML
Ionic Beta
Install fontAwesome from the npm library.
Modify the below changes to your gulpfile.ts.
Include
@import "../../node_modules/font-awesome/scss/font-awesome";
in app.core.scss fileTo include your icon in HTML
font-awesome ionic 2 integration only with configuration files.
npm install font-awesome --save
)In the file package.json from your project add this:
On the root folder of your project create config folder and copy the files
copy.config.js
andsass.config.js
(this files are located in(..\node_modules\@ionic\app-scripts\config)
Modify the copied files. In sass.config.js add the reference to font-awesome, at the end verify that you have something like this
includePaths: [ 'node_modules/ionic-angular/themes', 'node_modules/ionicons/dist/scss', 'node_modules/ionic-angular/fonts', 'node_modules/font-awesome/scss' ],
The most important part here is the last line.
in
copy.config
add this:The most important part here is dest
'{{WWW}}/fonts/'
and not{{WWW}}/assets/fonts/'
, it becausefont-awesome.css
search fonts in"www/fonts"
file.@import "font-awesome";
invariables.css (src\theme folder)
After perform all this steps you can use font-awesome in your ionic 2 project.
It's all
Similar Approach as @Edward suggested, but a bit cleaner way to do this would be
1)
npm install font-awesome --save
2) In package.json, add
"ionic_copy": "./config/copy.config.js", "ionic_sass": "./config/sass.config.js",
3) Create the below files at root level of your project and add following content.
In the file:
./config/copy.config.js
AddIn the file:
./config/sass.config.js
Add4) In
./src/theme/variables.scss