JSPM

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

JSS plugin that adds default custom unit to numeric values where needed

Package Exports

  • jss-default-unit

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 (jss-default-unit) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JSS logo

JSS plugin that adds units to numeric values

Provide plain numeric values in your JSS style definitions, and the plugin will insert the apposite units. Defaults to px for sizes, ms for durations, and % for transform origins, and these can be customized easily (see Usage Example).

Demo - JSS

![Gitter](https://badges.gitter.im/Join Chat.svg)

Usage example

import jss from 'jss'
import defaultUnit from 'jss-default-unit'

// Optionally customize default units.
const options = {
  'line-height': 'rem',
  'font-size': 'rem'
}

jss.use(defaultUnit(options))

// Define styles.
const styles = {
  container: {
    'line-height': 3,
    'font-size': 1.7,
    'height': 200,
    'z-index': 1
  }
}

let sheet = jss.createStyleSheet(styles)

console.log(sheet.toString())

Generates the following stylesheet:

.container-0-0 {
  line-height: 3rem;
  font-size: 1.7rem;
  height: 200px;
  z-index: 1;
}

Issues

File a bug against jsstyles/jss prefixed with [jss-default-unit].

Run tests

npm i
npm run test

License

MIT