[go: nahoru, domu]

Skip to content

tcarlsen/json-to-css-variables

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON to CSS Variables

image

I had a project where I needed to use a REST API to store CSS settings and fetching them in my frontend, so I came up with this idea to convert a JSON object into CCS Variables and thought I would share the code.

Installation

yarn add json-to-css-variables

Usage

  const options = {
    element: '.container',
    pretty: true
  }

  const cssString = jsonToCssVariables(json, options)

Options

Option Default What it does
offset 0 Use this to skip properties in the JSON object
element ':host' Where to apply the CSS variables
pretty false Should the output be prettified
unit 'px' If value is a number what unit should be applied

License

MIT © tcarlsen

About

converts JSON objects into CSS variables

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published