favicon-color
v1.0.1
Published
Set a page's favicon to a solid color
Downloads
8
Maintainers
Readme
favicon-color
Set a page's favicon to a solid color
Example
var colorize = require('favicon-color');
var icon = document.querySelector('[rel=icon]');
colorize(icon, 'red');
Install
With npm do:
$ npm install favicon-color
favicon-color
is designed to work in the browser via a bundlers such as browserify and as a stand-alone script:
<script src="http://wzrd.in/standalone/favicon-color@latest"></script>
Usage
var colorize = require('favicon-color');
colorize(icon, red, green, blue)
icon
is the favicon DOM element. The color can be specified by passing the RGB values as individual arguments, by passing an array containing the RGB values as the second argument, or by passing a string as the second argument. In the latter case you are free to use any valid color string, e.g. 'red', '#ff0000', 'rgb(255, 0, 0)', etc. Note: This method temporarily removes the specified element to work around a quirk in Firefox.
Examples:
colorize(icon, 68, 68, 68);
colorize(icon, [13, 37, 42]);
colorize(icon, 'cyan');
colorize(icon, '#bada55');
colorize(icon, 'hsla(170, 50%, 45%, 1)');