New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

postcss-theme-variables

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-theme-variables

A [postcss](http://postcss.org/) plugin to override variables specified in options. An unobtrusive way to create themes.

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
27
increased by440%
Maintainers
1
Weekly downloads
 
Created
Source

postcss-theme-variables

A postcss plugin to override variables specified in options. An unobtrusive way to create themes.

Usage

yarn add postcss postcss-theme-variables --dev

{
  plugins: [require('postcss-theme-variables')(/* options */)]
}

# And in your postcss source files, use variables as you wish.

⚠️ Plugin orders are important in postcss, make sure this plugin comes after any import related plugins(like postcss-easy-import) and before any other plugins(like precss).

Example Usage with postcss-easy-import and precss
// PostCSS config
const themeVariables = require('postcss-theme-variables');
const easyImport = require('postcss-easy-import');
const precss = require('precss');

const vars = {
  'padding-size': '10px'
};

postcss([
  easyImport({ prefix: '_' }),
  themeVariables({ vars, prefix: '$' }),

  // Imports are inlined by postcss-easy-import so precss won't see them
  precss()
])
.process(...);
/* _colors.css */
$padding-size: 5px;

/* in.css */
@import './_colors.css';

ul li {
  padding: $padding-size;
}
/* out.css */

ul li {
  padding: 10px;
}
Example Usage with precss
// PostCSS config
const themeVariables = require('postcss-theme-variables');
const precss = require('precss');

const vars = {
  'padding-size': '10px'
};

postcss([
  themeVariables({ vars, prefix: '$' }),
  precss({
    import: {
      // This is required to process any variables inside dependencies
      plugins: [themeVariables({ vars })]
    }
  })
])
.process(...);
/* in.css */
$padding-size: 5px;

ul li {
  padding: $padding-size;
}
/* out.css */

ul li {
  padding: 10px;
}

Options

OptionTypeDescriptionDefault ValueRequired
varsObjectVariables to override{}No
prefixstringVariable prefix, it's '$' if you use SCSS. You can omit prefix in vars map.''No

License

MIT license.

FAQs

Package last updated on 20 Sep 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc