jss-default-unit
JSS plugin that adds default custom unit to numeric values where needed
Last updated 9 years ago by kof .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install jss-default-unit 
SYNC missed versions from official npm registry.

JSS plugin that adds units to numeric values

Gitter

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).

Make sure you read how to use plugins in general.

Setup

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

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

jss.use(defaultUnit(options))

Example

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

Compiles to:

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

Demo

Simple

Issues

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

Run tests

npm i
npm run test

License

MIT

Current Tags

  • 8.0.2                                ...           latest (7 years ago)

27 Versions

  • 8.0.2                                ...           7 years ago
  • 8.0.1                                ...           7 years ago
  • 8.0.0                                ...           7 years ago
  • 7.0.0                                ...           7 years ago
  • 6.1.2                                ...           7 years ago
  • 6.1.1                                ...           8 years ago
  • 6.1.0                                ...           8 years ago
  • 6.0.0                                ...           8 years ago
  • 5.0.3                                ...           8 years ago
  • 5.0.2                                ...           8 years ago
  • 5.0.1                                ...           8 years ago
  • 5.0.0                                ...           8 years ago
  • 4.1.4                                ...           8 years ago
  • 4.1.3                                ...           8 years ago
  • 4.1.2                                ...           8 years ago
  • 4.1.1                                ...           8 years ago
  • 4.1.0                                ...           8 years ago
  • 4.0.1                                ...           8 years ago
  • 4.0.0                                ...           8 years ago
  • 3.0.1                                ...           8 years ago
  • 3.0.0                                ...           8 years ago
  • 2.2.0                                ...           9 years ago
  • 2.1.2                                ...           9 years ago
  • 2.1.1                                ...           9 years ago
  • 2.1.0                                ...           9 years ago
  • 2.0.1                                ...           9 years ago
  • 2.0.0                                ...           9 years ago
Maintainers (1)
Downloads
Total 3
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (15)

© 2010 - cnpmjs.org x YWFE | Home | YWFE