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

a11y-color-scaler

v1.1.0

Published

A SCSS utility that automatically adjusts text color for accessible contrast based on WCAG 2.1.

Readme

a11y-color-scaler 🎨️♿️

A lightweight SCSS utility that automatically adjusts text color for better contrast against any background — while preserving your brand palette.

  • ✅ WCAG 2.1 compliant
  • ✅ SCSS-only (no JS)
  • ✅ Design-system friendly
  • ✅ Works with any color palette

🚀 Installation

You can use a11y-color-scaler in two ways:

📦 Option 1: Install via npm

npm install a11y-color-scaler

Then import it in your SCSS:

@use 'a11y-color-scaler' as *;

📁 Option 2: Manual copy

Copy _contrast.scss into your SCSS project and import it using:

@use 'path/to/_contrast.scss' as *;

🧪 Live Demo

Try it live: CodePen Demo


🔧 Usage

$text: #83b2b2;
$bg: #d4ffff;

.block {
	background-color: $bg;
	color: adjust-contrast-color($text, $bg);
}

The function will automatically adjust the text color to ensure it meets the WCAG contrast ratio threshold (4.5:1 by default) by gradually darkening or lightening it.


📀 Accessibility thresholds

This utility follows official WCAG 2.1 contrast guidelines:

| Text type | Minimum contrast | | --------------- | ---------------- | | Regular text | 4.5:1 | | Large/bold text | 3:1 |

You can control the threshold via the optional third parameter:

// Default (4.5:1)
color: adjust-contrast-color($text, $bg);

// For large or bold text (3:1)
color: adjust-contrast-color($text, $bg, 3);

🛠 Function Signature

adjust-contrast-color(
  $text-color,
  $bg-color,
  $threshold: 4.5,
  $step: 3%,
  $max-steps: 10
)

Parameters

| Name | Type | Default | Description | | ------------- | ------ | ------- | ------------------------------------------ | | $text-color | Color | – | Initial color you want to use | | $bg-color | Color | – | Background color to check contrast against | | $threshold | Number | 4.5 | Desired contrast ratio | | $step | % | 3% | Adjustment step for each iteration | | $max-steps | Number | 10 | Max iterations to prevent infinite loops |


📊 Based on WCAG 2.1


♿️ Bonus: respects system-level contrast preferences

Some users enable “Increased Contrast” in their operating system for better readability.
You can respond to this setting using the built-in mixin prefers-strong-contrast.

.block {
	background-color: $bg;
	color: adjust-contrast-color($text, $bg); // WCAG 4.5

	@include prefers-strong-contrast(
		color,
		$text,
		$bg
	); // Boost to WCAG 7 if user prefers it
}

This mixin uses the CSS media query @media (prefers-contrast: more) to apply stronger contrast only when requested by the user’s system.

Mixin signature

@mixin prefers-strong-contrast(
	$property,
	$text-color,
	$bg-color,
	$threshold: 7
);

| Parameter | Type | Description | | ------------- | ------ | --------------------------------------------------------- | | $property | String | CSS property to apply (e.g., color, background-color) | | $text-color | Color | The original color you want to use | | $bg-color | Color | The background color for contrast comparison | | $threshold | Number | Contrast ratio to meet (default 7) |

You can use this for any property, including color, background-color, border-color, etc.


🎖️ How is this different from other contrast tools?

While other tools like a11y-color-contrast only validate whether a color pair meets accessibility standards (WCAG),
a11y-color-scaler actively adjusts the text color to meet those standards — without breaking your design.

| Tool | Type | Purpose | | --------------------- | ---------- | ---------------------------------- | | a11y-color-contrast | JS Library | Checks contrast between colors | | a11y-color-scaler | SCSS Tool | Dynamically adjusts color for WCAG |

This means you can focus on design, and let the utility do the contrast correction for you.


📄 License

MIT – free for personal and commercial use.


🙌 Author

Created by Serhii Ivcheko (@JAZzmiX)

Inspired by real needs in design system development.