Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to color the fontawesome icon colors?

I can change fontcolor, but not the "fill". I first tried setting background-color, but that fills the whole icon box area.

For example, I have

<i class="icon-star-empty icon-large"></i> 

but I want it to be yellow.

Edit: The use case is that I want a "favorite" icon to be outline of grey, on click, the outline becomes orange, fill to yellow.

like image 527
jqed Avatar asked Jul 09 '13 05:07

jqed


People also ask

How do I color font awesome icons?

It is pretty simple to change color of icon Fa just add style="color:red" it will make font color red. On the same way you can change size of Fa icon by just adding style="font-size:50px;".

How can I change the color of my icons?

To change the color of an icon, select the icon you'd like to edit. The Format tab will appear. Then click Graphics Fill and select a color from the drop-down menu. To add an outline to your icon, click Shape Outline and select a color from the drop-down menu.

Can I modify font awesome icons?

Select the SVG of font-awesome located in your extracted zip inside fonts. Repeat the procces uploading your own svg files. Inside Home (at the header of the page) Select the icons you want to download, customize them to give your custom names and select publish to have a link or download the fonts and css.

Are font awesome icons copyright free?

Font Awesome is fully open source and is GPL friendly. You can use it for commercial projects, open source projects, or really just about whatever you want. Attribution is no longer required as of Font Awesome 3.0 but is much appreciated: "Font Awesome by Dave Gandy - http://fontawesome.io".


2 Answers

Font-awesome comes with a number of both outlined and filled icons. The star is one of them.

There are four different star icon classes that you can use:

class="icon-star" class="icon-star-empty" class="icon-star-half" class="icon-star-half-empty" 

If you're a glass-half-full type of person, you can also use the alias for 'icon-star-half-empty':

class="icon-star-half-full" 

You can colour the font-awesome icons and use different effects to achieve what you're looking for:

<i class="icon-star-empty icon-large icon-a"></i><br><br> <i class="icon-star-empty icon-large icon-b"></i><br><br> <i class="icon-star icon-large icon-c"></i> or <i class="icon-star icon-large icon-d"></i> 

Where the following CSS is used (rather than using inline styles):

.icon-a {     color: #888; }  .icon-b {     color: orange; } .icon-c {     color: yellow; } .icon-d {     color: yellow;     -webkit-text-stroke-width: 1px;     -webkit-text-stroke-color: orange; } 

You can also substitute/set the size too, if you don't want to use icon-large.

The above code outputs the following:

enter image description here

but I've put the above code and a few more options in a JSFiddle, which you can look at here.

It's also possible to use css-transitions that provides a way to animate changes to CSS properties instead of having the changes take effect instantly and or in combination with javascript.

like image 199
nickhar Avatar answered Sep 19 '22 14:09

nickhar


All you need is to set color: yellow. Because the icons are a font, they will take whatever colour you'd set to any other font (text) in the same way.

if you want to fill the whole star as yellow, try icon-star instead of icon-star-empty

you can try this

-webkit-text-stroke-width: 1px; -webkit-text-stroke-color: orange; 

to add stroke (outline) to the font itself. I hope thats what you are looking for.

and to fill it just use the normal

color: yellow; 
like image 30
Lucas Lim Avatar answered Sep 19 '22 14:09

Lucas Lim