Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Repository files navigation

⚠️ PostCSS Lab Function was moved to @csstools/postcss-plugins. ⚠️
Read the announcement

PostCSS Lab Function PostCSS Logo

npm versionCSS Standard StatusBuild Statussupport chat

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

:root {
--firebrick: lab(40%56.639);
--firebrick-a50: lch(40%68.834.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 postcss-lab-function --save-dev

Use it as a PostCSS plugin:

constpostcss=require('postcss');constpostcssLabFunction=require('postcss-lab-function');postcss([postcssLabFunction(/* pluginOptions */)]).process(YOUR_CSS/*, processOptions */);

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

NodePostCSS CLIWebpackCreate React AppGulpGrunt

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.639);
--firebrick-a50: lch(40%68.834.5/50%);
}
/* becomes */
:root {
--firebrick: rgb(178, 34, 34);
--firebrick: lab(40%56.639);
--firebrick-a50: rgba(178, 34, 34, .5);
--firebrick-a50: lch(40%68.834.5/50%);
}

About

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

Resources

Code of conduct

Contributing

Stars

46 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages