@csstools/postcss-gamut-mapping
Gamut map css colors to fit display specific gamuts
Last updated a month ago by romainmenke .
MIT-0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @csstools/postcss-gamut-mapping 
SYNC missed versions from official npm registry.

PostCSS Gamut Mapping PostCSS Logo

npm install @csstools/postcss-gamut-mapping --save-dev

PostCSS Gamut Mapping lets you use wide gamut colors with gamut mapping for specific displays following the CSS Color 4 Specification.

When out of gamut colors are naively clipped the result can be radically different.
A saturated and bright color will be much darker after clipping.

To correctly adjust colors for a narrow gamut display, the colors must be mapped.
This is done by lowering the chroma in oklch until the color is in gamut.

Using the @media (color-gamut) media feature makes it possible to only use the wide gamut colors on displays that support them.

p {
	background-color: oklch(80% 0.05 0.39 / 0.5);
	color: oklch(20% 0.234 0.39 / 0.5);
	border-color: color(display-p3 0 1 0);
}

/* becomes */

p {
	background-color: oklch(80% 0.05 0.39 / 0.5);
	color: rgba(48, 0, 20, 0.5);
	border-color: rgb(0, 247, 79);
}

@media (color-gamut: rec2020) {
p {
	color: oklch(20% 0.234 0.39 / 0.5);
}
}

@media (color-gamut: p3) {
p {
	border-color: color(display-p3 0 1 0);
}
}

Usage

Add PostCSS Gamut Mapping to your project:

npm install postcss @csstools/postcss-gamut-mapping --save-dev

Use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssGamutMapping = require('@csstools/postcss-gamut-mapping');

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

Current Tags

  • 2.0.5                                ...           latest (13 days ago)

18 Versions

  • 2.0.5                                ...           13 days ago
  • 2.0.4                                ...           22 days ago
  • 2.0.3                                ...           a month ago
  • 2.0.2                                ...           3 months ago
  • 2.0.1                                ...           3 months ago
  • 2.0.0                                ...           3 months ago
  • 1.0.11                                ...           4 months ago
  • 1.0.10                                ...           5 months ago
  • 1.0.9                                ...           6 months ago
  • 1.0.8                                ...           6 months ago
  • 1.0.7                                ...           7 months ago
  • 1.0.6                                ...           7 months ago
  • 1.0.5                                ...           8 months ago
  • 1.0.4                                ...           8 months ago
  • 1.0.3                                ...           9 months ago
  • 1.0.2                                ...           10 months ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None
Dependents (1)

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