
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
postcss-theme-variables
Advanced tools
A [postcss](http://postcss.org/) plugin to override variables specified in options. An unobtrusive way to create themes.
A postcss plugin to override variables specified in options. An unobtrusive way to create themes.
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
).
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;
}
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;
}
Option | Type | Description | Default Value | Required |
---|---|---|---|---|
vars | Object | Variables to override | {} | No |
prefix | string | Variable prefix, it's '$' if you use SCSS. You can omit prefix in vars map. | '' | No |
MIT license.
FAQs
A [postcss](http://postcss.org/) plugin to override variables specified in options. An unobtrusive way to create themes.
The npm package postcss-theme-variables receives a total of 29 weekly downloads. As such, postcss-theme-variables popularity was classified as not popular.
We found that postcss-theme-variables demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600Ă faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.