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 🙏

© 2025 – Pkg Stats / Ryan Hefner

postcss-pxv

v2.0.0

Published

A PostCSS plugin that converts pxv units into fluid, viewport-scaled values using clamp().

Readme

postcss-pxv

A PostCSS plugin that introduces a new CSS unit: pxv — a pixel that scales with the viewport.

Sometimes layouts need the precision of pixels but the flexibility of viewport units. That’s where pxv comes in: it’s like a pixel that flexes with the viewport.

Input:

.box {
  width: 300pxv;
  margin-bottom: 16pxv;
}

Output:

.box {
  width: calc(300 * var(--pxvUnit));
  margin-bottom: calc(16 * var(--pxvUnit));
}

Which looks like this when computed (note actual code is much trimmer):

:root {
  --siteBasis: 375;
  --siteMax: 600;
  --pxvUnit: clamp(0px, calc((100 / 375) * 1vw), calc(1px * 600 / 375));
}

.box {
  width: clamp(0px, calc(300vw * (100 / 375)), calc(300px * 600 / 375));
  margin-bottom: clamp(0px, calc(16vw * (100 / 375)), calc(16px * 600 / 375));
}

Using pxv means:

  • Layout values stay proportional as screens get bigger or smaller
  • One shared formula in :root replaces hundreds of repeated clamp() calls
  • Adjusting scaling is as simple as tweaking two variables

⚙️ Configuration

** Note:** v2.x has configuration changes

Add postcss-pxv to your PostCSS pipeline, then configure it in your postcss.config.js file.

// postcss.config.js
module.exports = {
  plugins: [
    require('postcss-pxv')({
      // 🔧 Main settings
      siteMin: 0,               // Minimum viewport width in px
      siteBasis: 375,           // Reference design width
      siteMax: 767,             // Maximum viewport width in px
      writeVars: false,         // Automatically injects CSS variables into :root

      // 🎛 Optional variable overrides (use if your CSS tokens differ)
      vars: {
        min: '--siteMin',       // default: --site-min
        basis: '--siteBasis',   // default: --site-basis
        max: '--siteMax',       // default: --site-max
        unit: '--pxvUnit'       // default: --pxv-unit
      }
    })
  ]
}

Then add this line to your code:

--pxvUnit: clamp(0px, calc((100 / 375) * 1vw), calc(1px * 600 / 375));

🚀 What’s new in v2.0

Version 2 outputs cleaner, smaller CSS by centralizing the clamp() logic into a shared --pxvUnit variable.
The plugin automatically injects the needed variables (--siteBasis, --siteMax, --pxvUnit) if they’re not already defined, so it should just work out of the box.

Previously, every use of pxv generated a full clamp() expression inline, leading to significant repetition and larger CSS files. The improved approach now references a shared --pxvUnit variable, drastically reducing repetition and file size—often by up to ~75% for projects with many pxv values.

/* v1 output */
h1 {
  font-size: clamp(0px, calc(24vw * (100 / 375)), calc(24px * 600 / 375));
}

In v2, the same value references a central variable:

/* v2 output */
:root {
  --siteBasis: 375;
  --siteMax: 600;
  --pxvUnit: clamp(
    0px,
    calc((100 / var(--siteBasis)) * 1vw),
    calc(1px * var(--siteMax) / var(--siteBasis))
  );
}

h1 {
  font-size: calc(24 * var(--pxvUnit));
}

📦 Installation

npm install -D postcss-pxv
# or
pnpm add -D postcss-pxv

🛠️ Contributing

  1. Install dependencies: npm install or pnpm install
  2. Edit index.js
  3. Test locally with node process-css.js or link into a project
  4. Open a PR 🚀