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

color-contrast-sass

v0.0.5

Published

library that helps manage color contrast for accessibility purposes

Readme

Sass Contrast Functions

A lightweight Sass library providing WCAG-compliant color contrast calculation functions for accessible web development.

Features

  • 🎯 WCAG Compliant: Calculate contrast ratios according to Web Content Accessibility Guidelines
  • 🧮 Precise Calculations: Uses scientific relative luminance formulas for accurate results
  • 🎨 Color Accessibility: Ensure your color combinations meet accessibility standards
  • 📦 Zero Dependencies: Pure Sass implementation with no external dependencies
  • Customizable: The library returns the contrast ratio, you decide at which threshold to apply changes

Installation

npm install color-contrast-sass

Usage

Basic Import

@use 'color-contrast-sass' as contrast; //remember that every project and framework will require a different import style. 
//Most likely, you will need to go to the node_modules folder and navigate to color-constrast-sass/index.scss

Practical Examples

Accessibility-First Button Mixin

@mixin accessible-button($bg-color, $min-contrast: 5) {
  background-color: $bg-color;
  
  // Choose text color based on contrast ratio
  @if contrast.colour-difference($bg-color, #ffffff) >= $min-contrast {
    color: #ffffff;
  } @else {
    color: #000000;
  }
  
  // Ensure border has sufficient contrast too
  @if contrast.colour-difference($bg-color, #000000) < 3 {
    border: 1px solid #666666;
  }
}

.primary-button {
  @include accessible-button(#0066cc); // Blue background
}

.warning-button {
  @include accessible-button(#ffcc00); // Yellow background
}

WCAG Contrast Standards

| Level | Normal Text | Large Text (18pt+) | |-------|-------------|-------------------| | AA | 4.5:1 | 3:1 | | AAA | 7:1 | 4.5:1 |

Understanding Contrast Ratios

  • 21:1 - Maximum contrast (black on white)
  • 7:1 - WCAG AAA standard for normal text
  • 4.5:1 - WCAG AA standard for normal text
  • 3:1 - WCAG AA standard for large text
  • 1:1 - No contrast (same color)

Browser Support

This library uses standard Sass functions and is compatible with:

  • Dart Sass 1.23.0+
  • Any build tool that supports modern Sass (Webpack, Vite, Parcel, etc.)

Contributing

You are free and encouraged to contribute or open an issue. The purpose of this library is not to show off but to offer a tool. The more people contribute to making it usable, the better!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

For further information, read the CONTRIBUTING file.

License

MIT License - see LICENSE file for details.

Transparency & AI

Some of this code was fixed by AI. I relied on AI mostly for testing and to add docs over functions, but I also used a chat bot to rubber duck problems I enounctered along the way.


Made with 💖 for accessible web development