JSPM

  • Created
  • Published
  • Downloads 6596585
  • Score
    100M100P100Q223899F
  • License CC0-1.0

Use lab() and lch() color functions in CSS

Package Exports

  • postcss-lab-function

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-lab-function) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

PostCSS Lab Function PostCSS Logo

npm version CSS Standard Status build status support chat

PostCSS Lab Function lets you use lab and lch color functions in CSS, following the CSS Color specification.

:root {
  --firebrick: lab(40% 56.6 39);
  --firebrick-a50: lch(40% 68.8 34.5 / 50%);
}

/* becomes */

:root {
  --firebrick: rgb(178, 34, 34);
  --firebrick-a50: rgba(178, 34, 34, .5);
}

Usage

Add PostCSS Lab Function to your project:

npm install postcss-lab-function --save-dev

Use PostCSS Lab Function to process your CSS:

const postcssLabFunction = require('postcss-lab-function');

postcssLabFunction.process(YOUR_CSS /*, processOptions, pluginOptions */);

Or use it as a PostCSS plugin:

const postcss = require('postcss');
const postcssLabFunction = require('postcss-lab-function');

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

PostCSS Lab Function runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

preserve

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

postcssLabFunction({ preserve: true })
:root {
  --firebrick: lab(40% 56.6 39);
  --firebrick-a50: lch(40% 68.8 34.5 / 50%);
}

/* becomes */

:root {
  --firebrick: rgb(178, 34, 34);
  --firebrick: lab(40% 56.6 39);
  --firebrick-a50: rgba(178, 34, 34, .5);
  --firebrick-a50: lch(40% 68.8 34.5 / 50%);
}