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

capquadrat

v0.1.0

Published

Responsive CSS grid system

Readme

capquadrat

Toolkit for writing responsive CSS styles in a concise, convenient manner. Aimed at being used in combination with CSS as Javascript libraries, such as Emotion or styled-components.

Requirements

This library requires ES6 and support for private class properties and methods.

Usage

Defining breakpoints

First, you must define the breakpoint sizes that make sense for your application. You do so by creating an instance of the Media class:

import {Media} from "capquadrat";

const media = new Media({
    breakpoints: [
        {name: "XS"},
        {name: "S", minWidth: 600},
        {name: "M", minWidth: 900},
        {name: "L", minWidth: 1200},
        {name: "XL", minWidth: 1500},
    ],
});

export default media;

Initializing the document

The second step is to include the necessary global CSS declarations in your document:

// Example using Emotion's GlobalStyles component; include something like this in your root component
<GlobalStyles styles={
[
    {}, // Other application styles
    media.globalStyles()
]/>

The globalStyles() method will generate the following CSS variables:

  • --cq-min-width: The minimum width in pixels of the active breakpoint
  • --cq-max-width: The maximum width in pixels of the active breakpoint
  • --cq-min-margin: The horizontal margin applied to the main content of the document, so that content does not reach the edges of the viewport. Note that the size of this margin can be configured via the minMargin parameter for the Media constructor (or disabled, by setting it to 0).
  • --cq-content-width: The minimum width in pixels of the active breakpoint, accounting for the minimum margin described above

Writing responsive styles

Finally, you can now make use of your defined breakpoints to write your responsive styles for different breakpoints:

// Example using emotion's `css` property and object notation
<div
    css={media
        .any({
            display: "grid",
            gridTemplateColumns: "repeat(var(--columns), 1fr)",
            gap: "1em",
        })
        .gt("L", {"--columns": 5})
        .is("L", {"--columns": 4})
        .lt("L", {"--columns": 3})}>
  <div>A</div>
  <div>B</div>
  <div>C</div>
  <div>D</div>
  <div>E</div>
</div>

As showcased in the above example, Media offers a set of methods to generate media queries based on the previously defined endpoints:

  • any(breakpoint): Applies the given properties to all breakpoints.
  • is(breakpoint): Apply the given properties only to the given breakpoint
  • is(Array<breakpoint>): As above, but with an array of multiple breakpoints; applies the given properties to all of the breakpoints included in the array
  • not(breakpoint): Apply the given properties to all the breakpoints except for the given one
  • gt(breakpoint): Apply the given properties only to breakpoints bigger than the given breakpoint
  • ge(breakpoint): Apply the given properties only to the indicated breakpoint and any bigger breakpoints
  • lt(breakpoint): Apply the given properties only to breakpoints smaller than the given breakpoint
  • le(breakpoint): Apply the given properties only to the indicated breakpoint and any smaller breakpoints
  • inRange(start, end): Apply the given properties to all the breakpoints contained within the given range (both ends included)

Utilities

The library also exposes a set of convenience methods:

  • horizontal(propertyName, value): Produces a CSS object with -left and -right declarations for the given CSS property. Useful to set margins, paddings and similar properties.
  • vertical(propertyName, value): Produces a CSS object with -top and -bottom declarations for the given CSS property. Useful to set margins, paddings and similar properties.
  • centerContent: A CSS object with rules to center an element's content according to the content width reserved to the active breakpoint (see --cq-content-width)