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

css-tint-filter

v0.1.1

Published

Tint elements by an RGB color with CSS filters.

Readme

CSS Tint filter

Tint elements by an RGB color with CSS filters.

Multiplying an element by a color, like a sprite tint, has no CSS filter. This package fits a chain of standard filter functions that approximates it, so it works on any element and animates with plain CSS.

Live demo

npm install css-tint-filter
import { multiplyFilter } from "css-tint-filter";

const { css, error } = multiplyFilter([1, 0.45, 0.35]);
element.style.filter = css;
// brightness(..) hue-rotate(..rad) sepia(..) hue-rotate(..rad) saturate(..) brightness(..)

You may not need this

A tint that doesn't animate is exact with an SVG filter, filter: url(#tint):

<svg width="0" height="0">
  <filter id="tint" color-interpolation-filters="sRGB">
    <feColorMatrix values="1 0 0 0 0  0 0.45 0 0 0  0 0 0.35 0 0  0 0 0 1 0" />
  </filter>
</svg>

This package is for tints that animate, alone or alongside other filters.

API

| Export | Description | | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | multiplyFilter(rgb, { near, minPrescale }) | Fits the chain for an sRGB color in 0-1. Returns css, its six arguments and error, the RMS difference from an exact multiply. near continues from a neighboring fit; minPrescale (default 0.05) trades accuracy for less 8 bit banding. | | multiplyKeyframes(from, to) | Keyframes { offset, filter }[] from one color to another, with keys where the browser's interpolation would drift off color. Play with linear timing. |

Accuracy and cost

  • On muted texture colors a fit is off by about 5/255 RMS, up to 15/255 for strong blues. Saturated pixels fare worse: sepia, the only filter that colors gray, first reduces each pixel to roughly its luminance.
  • A fit takes about 20 ms (2 ms with near), keyframes up to 0.2 s. Cache the results rather than fitting per frame.
  • Firefox and WebKit keep 8 bits between filter functions, Chromium uses float. Fits are scored by the worse of the two.

Prior art

This Stack Overflow answer, its CodePen and hex-to-css-filter fit filters that turn black into a color, which flattens images. This package fits a multiply instead, so images keep their detail, and adds keyframes for animation.

Development

npm run dev serves the demo. npm test runs the unit and Chromium tests, after npx playwright install chromium.