@csstools/postcss-contrast-color-function
Dynamically specify a text color with adequate contrast
Last updated 9 months ago by romainmenke .
MIT-0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @csstools/postcss-contrast-color-function 
SYNC missed versions from official npm registry.

PostCSS Contrast Color Function PostCSS Logo

npm install @csstools/postcss-contrast-color-function --save-dev

PostCSS Contrast Color Function lets you dynamically specify a text color with adequate contrast following the CSS Color 5 Specification.

.color {
	color: contrast-color(oklch(82% 0.2 330));
}

/* becomes */

.color {
	color: rgb(0, 0, 0);
	color: contrast-color(oklch(82% 0.2 330));
}

Usage

Add PostCSS Contrast Color Function to your project:

npm install postcss @csstools/postcss-contrast-color-function --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssContrastColorFunction = require('@csstools/postcss-contrast-color-function');

postcss([
	postcssContrastColorFunction(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);

Options

preserve

The preserve option determines whether the original notation is preserved. By default, it is preserved.

postcssContrastColorFunction({ preserve: false })
.color {
	color: contrast-color(oklch(82% 0.2 330));
}

/* becomes */

.color {
	color: rgb(0, 0, 0);
}

Current Tags

  • 3.0.17                                ...           latest (10 days ago)

38 Versions

  • 3.0.17                                ...           10 days ago
  • 3.0.16                                ...           a month ago
  • 3.0.15                                ...           2 months ago
  • 3.0.14                                ...           2 months ago
  • 3.0.13                                ...           2 months ago
  • 3.0.12                                ...           2 months ago
  • 3.0.11                                ...           3 months ago
  • 3.0.10                                ...           3 months ago
  • 3.0.9                                ...           3 months ago
  • 3.0.8                                ...           3 months ago
  • 3.0.7                                ...           4 months ago
  • 3.0.6                                ...           5 months ago
  • 3.0.5                                ...           5 months ago
  • 3.0.4                                ...           6 months ago
  • 3.0.3                                ...           7 months ago
  • 3.0.2                                ...           9 months ago
  • 3.0.1                                ...           10 months ago
  • 3.0.0                                ...           10 months ago
  • 2.0.12                                ...           a year ago
  • 2.0.11                                ...           a year ago
  • 2.0.10                                ...           2 years ago
  • 2.0.9                                ...           2 years ago
  • 2.0.8                                ...           2 years ago
  • 2.0.7                                ...           2 years ago
  • 2.0.6                                ...           2 years ago
  • 2.0.5                                ...           2 years ago
  • 2.0.4                                ...           2 years ago
  • 2.0.3                                ...           2 years ago
  • 2.0.2                                ...           2 years ago
  • 2.0.1                                ...           2 years ago
  • 2.0.0                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           3 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Downloads
Total 43
Today 0
This Week 0
This Month 43
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE