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 # 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
Example Usage with // PostCSS configconst themeVariables = ;const easyImport = ;const precss = ; const vars = 'padding-size': '10px'; ;
/* _colors.css */$/* in.css */;
/* out.css */
precss
Example Usage with // PostCSS configconst themeVariables = ;const precss = ; const vars = 'padding-size': '10px'; ;
/* in.css */$
/* out.css */
Options
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 |
License
MIT license.