Skip to content

A PostCSS plugin to enable CSS Custom Properties (CSS variables)

License

Notifications You must be signed in to change notification settings

colinmeinke/postcss-custom-props

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostCSS custom props

A PostCSS plugin to enable CSS Custom Properties (CSS variables).

Features

Limitations

This will only work as the spec sets out if you define your custom properties on :root. See the following discussions on pre-processing CSS properties from the postcss-custom-properties plugin repository:

Installation

npm install postcss-custom-props

Usage

Webpack

...
import atImport from 'postcss-import';
import colorFunction from 'postcss-color-function';
import customProps from 'postcss-custom-props';

export default {
  ...
  postcss: [
    atImport(),
    customProps(),
    colorFunction(),
  ],
};

Input

/* config.css */
:root {
  --brand-color: #f05;
}

/* component.css */
@import "./config.css";

:root {
  --compoment-bg-color: var( --brand-color );
  --component-font-color: color( var( --brand-color ) lighten( 30% ));
}

.component {
  background-color: var( --compoment-bg-color );
  color: var( --component-font-color );
}

Output

.component {
  background-color: #f05;
  color: #fcd;
}

About

A PostCSS plugin to enable CSS Custom Properties (CSS variables)

Resources

License

Stars

Watchers

Forks

Packages

No packages published