postcss-choose-color

Choose color based on the background brightness

Usage no npm install needed!

<script type="module">
  import postcssChooseColor from 'https://cdn.skypack.dev/postcss-choose-color';
</script>

README

PostCSS Choose Color Build Status

PostCSS plugin for choosing foreground color based on the background color brightness. The first argument is the background color in (hex, rgb or rgba). The second argument is the color that will be used on light background color. The third argument is the color that will be used on dark background color.

p {
    color: chooseColor("#000", "black", "white");
}

h1 {
    color: chooseColor("rgb(255, 255, 255)", "black", "white");
}
p {
    color: white;
}

h1 {
    color: black;
}

Usage

postcss([ require('postcss-choose-color') ])