Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@csstools/postcss-gamut-mapping

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/postcss-gamut-mapping

Gamut map css colors to fit display specific gamuts

  • 1.0.9
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
858K
decreased by-4.24%
Maintainers
3
Weekly downloads
 
Created
Source

PostCSS Gamut Mapping PostCSS Logo

npm version Build Status Discord

Baseline Status CSS Standard Status

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 */);

PostCSS Gamut Mapping runs in all Node environments, with special instructions for:

Keywords

FAQs

Package last updated on 04 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc