postcss-contrast
PostCSS plugin to change text color depending on background color contrast. This is generally useful if your writing a mixin or placeholder selector that applies to many scenarios.
TL;DR Use the contrast()
function
anywhere and get #fff
or #000
depending on the lightness of the color you
pass in the function.
Install
npm i --save-dev postcss-contrast
Usage
var fs = ;var postcss = ;var customProperties = ;var contrast = ; var css = fs; var output = css;
PostCSS
/* input.css */
Compiled CSS
/* output.css */
Options
dark
(default: #000
)
This lets your define a custom black for all contrast functions in your project.
var out =css;
light
(default: #fff
)
This lets your define a custom white for all contrast functions in your project.
var out =css;
Contributing
Make a branch, npm test
often, submit a new pull when it passes.
git clone https://github.com/stephenway/postcss-contrast.gitgit checkout -b patch-1npm inpm test