Returns white when a color is dark and black when a color is light. 🎨
yarn add yiq
# If you're using NPM:
# npm install yiq --save
Just call the yiq
function after importing it:
import yiq from 'yiq'
console.log(yiq('#fff')) // #000
console.log(yiq('#000')) // #fff
yiq
— Returns a light color when a color is dark and black color when a color is light.
function colorYiq(
colorHex: string,
options?: {
white: string
black: string
}
): string
The second argument (options) should be used to define the colors that the function will return:
yiq('#fff', {
white: '#f0f0f0',
dark: '#333'
}) // #333
The default options are:
options.white
:#fff
;options.black
:#000
.
lffg and contributors.
MIT License, see the included MIT file.