Socket
Socket
Sign inDemoInstall

postcss-lab-function

Package Overview
Dependencies
14
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-lab-function

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


Version published
Maintainers
1
Install size
1.64 MB
Created

Readme

Source

PostCSS Lab Function PostCSS Logo

NPM Version CSS Standard Status Build Status Windows Build Status Support Chat

PostCSS Lab Function lets you use lab, lch, and gray 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%);
  --gray-40: gray(40);
  --gray-40a50: gray(40 / .5);
}

/* becomes */

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

Usage

Add PostCSS Lab Function to your build tool:

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

Use PostCSS Lab Function to process your CSS:

import postcssLabFunction from 'postcss-lab-function';

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

Add PostCSS to your build tool:

npm install postcss --save-dev

Use PostCSS Lab Function as a plugin:

import postcss from 'gulp-postcss';
import postcssLabFunction from 'postcss-lab-function';

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

Add PostCSS Loader to your build tool:

npm install postcss-loader --save-dev

Use PostCSS Lab Function in your Webpack configuration:

import postcssLabFunction from 'postcss-lab-function';

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'style-loader',
          { loader: 'css-loader', options: { importLoaders: 1 } },
          { loader: 'postcss-loader', options: {
            ident: 'postcss',
            plugins: () => [
              postcssLabFunction(/* pluginOptions */)
            ]
          } }
        ]
      }
    ]
  }
}
Gulp

Add Gulp PostCSS to your build tool:

npm install gulp-postcss --save-dev

Use PostCSS Lab Function in your Gulpfile:

import postcss from 'gulp-postcss';
import postcssLabFunction from 'postcss-lab-function';

gulp.task('css', () => gulp.src('./src/*.css').pipe(
  postcss([
    postcssLabFunction(/* pluginOptions */)
  ])
).pipe(
  gulp.dest('.')
));
Grunt

Add Grunt PostCSS to your build tool:

npm install grunt-postcss --save-dev

Use PostCSS Lab Function in your Gruntfile:

import postcssLabFunction from 'postcss-lab-function';

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
  postcss: {
    options: {
      use: [
       postcssLabFunction(/* pluginOptions */)
      ]
    },
    dist: {
      src: '*.css'
    }
  }
});

Options

preserve

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

postcssImageSetFunction({ 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%);
}

Keywords

FAQs

Last updated on 25 Jul 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc