Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Repository files navigation

postcss-contrast Travis Build Status

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

Example

PostCSS

:root {
  --bg-color: #fff;
}

body {
  background-color: var(--bg-color);
  color: contrast(var(--bg-color));
}

Compiled CSS

body {
  background-color: #fff;
  color: #000;
}

Usage

var postcss = require('postcss');
var contrast = require('postcss-contrast');

About

PostCSS plugin to change text color depending on background color contrast

Resources

Stars

24 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages