npm.io
1.0.0 • Published 5 years ago

postcss-theme-fallback

Licence
MIT
Version
1.0.0
Deps
2
Size
7 kB
Vulns
6
Weekly
0

postcss-theme-fallback PostCSS

NPM Version github (ci)

A postcss plugin to adding fallback values for css-variables.

Install

npm i -DE postcss-theme-fallback

Usage

// postcss.config.js
module.exports = {
  plugins: [
    require('postcss-theme-fallback')({
      // Use variables from object:
      variables: {
        '--var-a': '10px',
        '--var-b': '20px',
      },
      // Or load variables from theme:
      // themeSource: './src/theme/acme.css',
    }),
  ],
}
Options
Name Description Default
variables Record<string, string> Object with theme variables
themeSource string A source path to theme, uses for extract css-variables
silent? boolean Disable warnings output false

Example

/* input.css */
.component {
  width: var(--var-a);
}

/* output.css */
.component {
  width: var(--var-a, 10px);
}

License

Project is MIT licensed.

Keywords