Socket
Socket
Sign inDemoInstall

css-to-object

Package Overview
Dependencies
10
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    css-to-object

Convert flat CSS rule to JavaScript style object


Version published
Weekly downloads
2.1K
decreased by-34.53%
Maintainers
1
Install size
0.969 MB
Created
Weekly downloads
 

Readme

Source

css-to-object

Convert flat CSS rules to JavaScript style objects

Useful for css-in-js libraries

npm i css-to-object
const cssToObject = require('css-to-object')

const style = cssToObject(`
  color: tomato;
  padding: 16px;
  @media (min-width: 40em) {
    paddingLeft: 32px;
    paddingRight: 32px;
  }
  &:hover: {
    color: black;
  }
  & h1 {
    font-size: 48px;
  }
`, {
  camelCase: true,
  numbers: true
})

// {
//   color: 'tomato',
//   padding: 16,
//   '@media (min-width: 40em)': {
//     paddingLeft: 32,
//     paddingRight: 32,
//   },
//   ':hover': {
//     color: 'black'
//   },
//   h1: {
//     fontSize: 48
//   }
// }

Options

  • numbers: Converts px values to numbers
  • camelCase: converts CSS properties to camelCased keys

MIT License

Keywords

FAQs

Last updated on 12 Aug 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc