CSS-Variable-Generator
Generate CSS variables from a base HEX color. Useful for theming websites and creating color palettes.
Installation
npm install css-variable-generatoryarn add css-variable-generator
Usage
Add a style tag into the head of your project with the ID of 'root-style'
Document
Import the module into your project...
;
Initialise the function with your chosen arguments.
;
If you check the HTML element on your project you should now have 7 CSS Variables appended and ready to use in your project.
Naming Conventions
--${baseColor}-100 is the lightest variation and is 75% lighter than the base color. --${baseColor}-400 is the base color. --${baseColor}-700 is the darkest variation and is 75% darker than the base color. The variables will have the following names (where the argument 'variableName' is 'colorPrimary' and the 'baseColor' is '#45a59c'):
Compatibility
The module works in all major browsers. I have also tested it in IE11 and it works alongside the css-vars-ponyfill. The css-vars-ponyfill just needs to be initialised after the variables are created.
;; ;;