JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 50194
  • Score
    100M100P100Q159452F
  • License MIT

Convert style objects to style strings

Package Exports

  • to-style

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (to-style) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

toStyle

Converts style objects to strings. Can be used on node or in the browser.

Install

npm install toStyle

Usage

var toStyleString = require('to-style').string
var toStyleObject = require('to-style').object

toStyleString

toStyleString({
    border: {
        width: 1,
        color: 'red'
    },
    padding: 4,
    margin: {
        top: 5
    }
}) == 'border-width: 1px; border-color: red; padding: 4px; margin-top: 5px;'

toStyleObject

toStyleObject({
    padding: {
        top: 3,
        bottom: 2
    },
    border: '1px solid red',
    margin: 4
}) // =>
/*
{
    'padding-top': '3px',
    'padding-bottom': '2px',
    'border': '1px solid red',
    'margin': '4px'
}
 */