postcss-default-unit

1.1.0 • Public • Published

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.

/postcss-default-unit/

    Package Sidebar

    Install

    npm i postcss-default-unit

    Weekly Downloads

    282

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    6.41 kB

    Total Files

    6

    Last publish

    Collaborators

    • antyakushev