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

clamp-size

v1.0.1

Published

A lightweight SCSS utility for generating responsive sizes using the clamp() function.

Downloads

140

Readme

Clamp Size SCSS Utility

A lightweight SCSS utility for generating responsive sizes using the clamp() function. This package includes helper functions for dynamic sizing based on breakpoints or custom values.

Resulted clamp() would have rem, not px units. Please use csize() function to use cqi units to work with container queries.

Installation

Install the package via npm:

npm install clamp-size

Usage

Import the SCSS file into your project:

@use 'clamp-size/src/clamp' as clamp;

Or add in your scss file:

@forward 'clamp-size';

Functions

size($a, $b: null, $c: null, $d: null)

Generates a responsive size using the clamp() function. This function works with both breakpoints (defined in the $breakpoints map) and custom numeric values.

  • Parameters:

    • $a: Minimum size (required).
    • $b: Maximum size (optional).
    • $c: Minimum width (optional, can be a breakpoint key or a numeric value).
    • $d: Maximum width (optional, can be a breakpoint key or a numeric value).
  • Example:

Using breakpoints:

.my-class {
  font-size: clamp.size(16px, 24px, 'sm', 'lg');
}

Using numeric values:

.my-class {
  font-size: clamp.size(10px, 20px, 360px, 1400px);
}

csize($a, $b, $c, $d)

Similar to size, but uses container query units (cqi) instead of vw. This function is better suited for container queries and works best with numeric values for widths.

  • Parameters:

    • $a: Minimum size (required).
    • $b: Maximum size (required).
    • $c: Minimum width (required, should be a numeric value).
    • $d: Maximum width (required, should be a numeric value).
  • Example:

.my-class {
  font-size: clamp.csize(16px, 24px, 360px, 1400px);
}

px-to-rem($px)

Converts a pixel value to rem based on the global base size.

  • Example:
.my-class {
  margin: clamp.px-to-rem(16px);
}

Configuration

Breakpoints

The utility uses a default $breakpoints map:

$breakpoints: (
  'xs': 320,
  'sm': 576,
  'md': 768,
  'lg': 992,
  'xl': 1200
) !default;

You can override this map in your project:

$breakpoints: (
  'mobile': 360,
  'tablet': 768,
  'desktop': 1024
);

Base Rem Size

Define a $base-rem-size variable in your project to set the base size for px-to-rem conversions:

$base-rem-size: 16;

License

This project is licensed under the MIT License.