1.1.0 • Published 2 years ago

postcss-default-unit v1.1.0

Weekly downloads
83
License
MIT
Repository
github
Last release
2 years ago

PostCSS Default Unit

Build Status NPM version Dependency Status

PostCSS plugin that adds a default unit to numeric css properties.

.foo {
    width: 200;
    margin: 0 auto 20;
    z-index: 1;
}
.foo {
    width: 200px;
    margin: 0 auto 20px;
    z-index: 1;
}

Install

With npm do:

npm install postcss-default-unit --save

Usage

By default px is used.

postcss([ require('postcss-default-unit') ])

You can specify the desired unit.

postcss([ require('postcss-default-unit')({unit: '%'}) ])

This plugin must be set after the plugins that can modify the values (e.g. postcss-simple-vars). See PostCSS docs for examples for your environment.

Issues

Now postcss-default-unit ignores expressions in parentheses. It won't mess up your rgba or calc, but it won't also add a unit to your gradient.