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

sass-responsive-util

v2.0.0

Published

A modern Sass utility library for DPI-aware responsive design. Easily convert between px, pt, rem, vw, and clamp() with scalable typography support.

Readme

🧩 sass-responsive-util

npm version license GitHub stars Sass Compatibility Docs

sass-responsive-util is a modern Sass utility library for responsive web design.
It provides DPI-aware conversions between px, pt, rem, vw, and clamp() to simplify scaling across devices and design tools.

sass-responsive-utilは、レスポンシブWebデザインとデザインシステム構築を強力に支援するモダンなSassユーティリティ集です。
pxptなどの値をremvwclamp()などへ変換し、DPI差によるズレを解消します。


✨ Features / 特徴

  • Modern module structure: Built with @use and @forward for clean namespace-based imports.
  • DPI-aware pt conversion: Perfect for Canva, Illustrator, and print design workflows.
  • Fluid Typography support: r-clamp() simplifies creating responsive clamp() values.
  • Viewport-based scaling: Generate vw values for both PC and mobile breakpoints.

⚠️ Important: This library does not support LibSass / Node Sass.
Please use Dart Sass (>=1.56.0).


⚠️ Breaking Changes in v2.0 / v2.0での破壊的変更

[!IMPORTANT] px-to-vw-pc() の挙動が変更されました

  • v1.x: デフォルトで上限付き(px値を上回らない)の値を返却していました。
  • v2.0: 上限なし(純粋なvw変換値)を返却するようになりました。

以前の「上限付き」の挙動(PCで一定以上の幅になった際に固定する挙動)を維持したい場合は、新しく導入された px-to-vw-pc-limited() を使用してください。


📦 Installation / インストール

npm

npm install sass-responsive-util

or clone via Git

git clone https://github.com/minori-003/sass-responsive-util.git

📂 File Structure / ファイル構成

sass-responsive-util/
├ package.json
├ README.md
├ LICENSE
├ _index.scss              # Entry point
│
├ setting/
│   ├ _index.scss          # Entry point
│   └ _variables.scss      # Global variables
│
├ functions/
│   ├ _index.scss          # Entry point
│   ├ _unit-helpers.scss
│   ├ _px-conversions.scss
│   ├ _pt-conversions.scss
│   ├ _viewport-conversions.scss
│   ├ _local-conversions.scss
│   └ _fluid-type.scss
│
└ mixin/
   ├ _index.scss          # Entry point
   ├ _font-space-block.scss
   ├ _font-space-line.scss
   ├ _apply-r-clamp.scss
   ├ _font-size-r-clamp.scss
   └ _width-size-r-clamp.scss

📘 Usage / 使用方法

Precautions / 注意事項

Note for Sass CLI users: If you are compiling directly with the Sass CLI, you may need to add the --load-path=node_modules option to your command to help the compiler find the package.

Sass CLIをお使いの方へ: コマンドラインで直接コンパイルする場合、--load-path=node_modules オプションを追加して、コンパイラがパッケージを見つけられるようにする必要がある場合があります。

npx sass <your-input-file>.scss <your-output-file>.css --load-path=node_modules

Note: If you're using build tools like Vite, Webpack, or Gulp, you can set includePaths: ["node_modules"] in your Sass configuration instead.

補足: Vite・Webpack・Gulpなどを使用している場合は、 Sass設定で includePaths: ["node_modules"] を追加することで同様の動作になります。

1️⃣ Customize settings (recommended)

@use "sass-responsive-util/setting" with (
  $root-font-size: 10,
  $default-dpi: 72
);
@use "sass-responsive-util/functions" as fn;

.my-element {
  font-size: fn.px-to-rem(20); // => 2rem
}

2️⃣ Use with default settings

@use "sass-responsive-util/functions" as fn;

3️⃣ Import all modules at once

@use "sass-responsive-util" as sru;

.title {
  font-size: sru.px-to-rem(24);
}

💡 Example Functions / 使用例

| px-to-rem() | pxremに変換 | font-size: px-to-rem(24); | font-size: 1.5rem; | | rem-to-px() | rempxに変換 | font-size: rem-to-px(1.5rem); | font-size: 24px; | | r-clamp() | pxに基づくclamp()生成 | font-size: r-clamp(16, 32); | font-size: clamp(1rem, ..., 2rem); | | px-to-vw-pc() | PC用vw生成(上限なし) | width: px-to-vw-pc(32); | width: 2.2222vw; | | px-to-vw-pc-limited() | 上限付きPC用vw生成 | width: px-to-vw-pc-limited(1200); | width: min(1200px, 83.3333vw); | | px-to-vw-sp() | スマホ用vwを生成 | width: px-to-vw-sp(300); | width: 80vw; | | pt-to-px() | ptpxに変換 | margin-top: pt-to-px(12pt); | margin-top: 16px; | | to-em() | 相対サイズをemに変換 | padding-top: to-em(24px, 16px); | padding-top: 1.5em; |

🎨 Mixin Examples / Mixin使用例

@use "sass-responsive-util/mixin" as mixin;
.text {
  @include mixin.m-font-space-block(8px, 16px);
  // => line-height: 2;
}

.heading {
  @include mixin.m-font-space-line(8px, 16px);
  // =>  letter-spacing: 0.5em;
}

.title {
  @include mixin.font-size-r-clamp(16px, 32px);
  // => font-size: clamp(1rem, ..., 2rem);
}

.box {
  @include mixin.width-size-r-clamp(100px, 200px);
  // => width: clamp(6.25rem, ..., 12.5rem);
}

⚙️ Variables / 設定変数

| 変数名 | デフォルト値 | 説明 | | --- | --- | --- | | $root-font-size | 16 | rem変換の基準フォントサイズ | | $default-min-bp | 375 | 最小ビューポート幅(px) | | $default-max-bp | 1440 | 最大ビューポート幅(px) | | $default-dpi | 96 | ptからpxへの変換比率(Web標準は96。デザイナーがCanvaやIllustrator(72dpi)を使用している場合は72に設定すると数値が一致します) |

例:設定変更

@use "sass-responsive-util/setting" with (
  $root-font-size: 10,
  $default-dpi: 72
);
@use "sass-responsive-util/functions" as fn;

.my-element {
  font-size: fn.px-to-rem(20); // => 2rem
}

📒 API Reference

| 関数名、mixin名 | 説明 | | --- | --- | | px-to-rem($px, $baseFontSize: $root-font-size) | pxをremに変換します。| | rem-to-px($rem, $baseFontSize: $root-font-size) | remをpxに変換します。| | pt-to-px($pt) | ptをpxに変換します。 | | pt-to-rem($pt, $baseFontSize: $root-font-size) | ptをremに変換します。 | | rem-to-pt($rem, $baseFontSize: $root-font-size) | remをptに変換します。 | | r-clamp($min, $max, ...) | pxに基づくレスポンシブclamp()生成。最小/最大値は自動でソートされます。 | | r-clamp-pt($minPt, $maxPt, ...) | ptに基づくレスポンシブclamp()生成。 | | r-clamp-rem($minRem, $maxRem, ...) | remに基づくレスポンシブclamp()生成。 | | r-clamp-em($minEm, $maxEm, $minViewport, $maxViewport, $baseFontSize, $contextFontSize) | emに基づくレスポンシブclamp()生成。 | | px-to-vw-sp($px, ...) | スマホ幅基準のvw値を生成。 | | px-to-vw-pc($px, ...) | PC幅基準のvw値を生成。 | | px-to-vw-pc-limited($px, ...) | 上限付きPC用vw値を生成(px値を上回らない)。 | | pt-to-vw-sp($pt, ...) | pt値をスマホ用のvw値に変換。 | | pt-to-vw-pc($pt, ...) | pt値をPC用のvw値に変換。 | | pt-to-vw-pc-limited($pt, ...) | pt値を上限付きPC用vw値に変換。 | | rem-to-vw-sp($rem, ...) | rem値をスマホ用のvw値に変換。 | | rem-to-vw-pc($rem, ...) | rem値をPC用のvw値に変換。 | | rem-to-vw-pc-limited($rem, ...) | rem値を上限付きPC用vw値に変換。 | | to-em($target-size, $context-size) | 相対サイズをemに変換。 | | to-percent($target-size, $context-size) | 相対サイズを%に変換。 | | @mixin apply-r-clamp($property, $min, $max) | 任意のプロパティにr-clampを適用。単位(px, pt, rem)を自動判別します。 | | @mixin font-size-r-clamp | font-sizeにr-clampを適用するmixin | | @mixin width-size-r-clamp | widthにr-clampを適用するmixin | | @mixin m-font-space-block | 文字の上下につけたい余白からline-heightを算出する | | @mixin m-font-space-line | 文字の横につけたい余白からletter-spacingを算出する |

🧠 Quick Example

@use "sass-responsive-util" as sru;

.title {
  font-size: sru.px-to-rem(24);
  margin-top: sru.pt-to-px(12pt);
  @include sru.m-font-space-block(8px, 16px);
}

🪪 License

Released under the MIT License.