npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

postcss-modular-scale-unit

v0.3.6

Published

PostCSS plugin to create a modular scale unit

Readme

PostCSS Modular Scale Unit

Build Status npm

This plugin transforms CSS declaration values using a custom msu unit. Instances of this unit are replaced with numbers from a modular scale.

Installation

npm install postcss-modular-scale-unit

Setup

The ratio and base parameters of your modular scale can be supplied with the --modular-scale custom property:

--modular-scale: [ratio] [...bases]

Ratio can be supplied as a:

  • number greater than one (for example, 1.5)
  • fraction greater than one (for example, 3/2)
  • keyword alias (for example, perfectfifth)

The following are all equivalent:

:root {
  --modular-scale: 1.5;
  --modular-scale: 3/2;
  --modular-scale: perfectfifth;
}

Bases are optional, and can be supplied as one or more numbers greater than or equal to one, defaulting to 1 when omitted. The following results in a scale that looks like this:

:root {
  --modular-scale: perfectfifth 1 1.125 1.25;
}

Using the custom unit

With the --modular-scale property set, simply append the custom unit to positive or negative integers that correlate with the steps of your scale. The output will be a plain number.

Input:

:root {
  --modular-scale: 3/2;
}

.Example {
  line-height: 1msu;
  font-size: calc(1msu * 1em);
  width: calc(-1msu * 100%);
}

Output:

.Example {
  line-height: 1.5;
  font-size: calc(1.5 * 1em);
  width: calc(0.667 * 100%);
}

If needed, see postcss-cssnext or postcss-calc for calc() handling.

PostCSS integration

var fs = require('fs')
var postcss = require('postcss')
var modularScaleUnit = require('postcss-modular-scale-unit')

var output = postcss()
  .use(modularScaleUnit())
  .process(fs.readFileSync('input.css', 'utf8'))
  .css

See the PostCSS usage docs docs for more examples.

Inspiration

This plugin is inspired by postcss-modular-scale and postcss-vertical-rhythm. The goal is to provide a way to use modular scale values as if they were native CSS units.