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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@neupauer/tailwindcss-plugin-filter

v1.0.2

Published

A Tailwind CSS plugin for controlling filter & backdrop-filter behaviour.

Downloads

15

Readme

Tailwind CSS Plugin – Filter & Backdrop Filter

Utilities for controlling filter & backdrop-filter behaviour.

Install

  1. Install the plugin:
# Using npm
npm install @neupauer/tailwindcss-plugin-filter

# Using Yarn
yarn add @neupauer/tailwindcss-plugin-filter
  1. Add it to your tailwind.config.js file:
// tailwind.config.js
module.exports = {
  // ...
  plugins: [require("@neupauer/tailwindcss-plugin-filter")],
};

Configuration

// tailwind.config.js
module.exports = {
  theme: {
    // default
    filterFunctions: {
      blur: {},
      brightness: {},
      contrast: {},
      dropShadow: {},
      grayscale: {},
      hueRotate: {},
      invert: {},
      saturate: {},
      sepia: {},
    },
  },
  variants: {
    // default
    filterFunctions: ["responsive", "hover"],
  },
};

Usage

Filter & Backdrop Filter

To enable filters you have to add the .filter or .backdrop utility. (Similar to the native Tailwind transform utility)

None

If you want to disable filters, then you can use the .filter-none or .backdrop-none utility.

Responsive

To enable or disable filters at a specific breakpoint, add a {screen}: prefix to any of the filter utilities. For example, use md:filter or md:backdrop to apply the filter or backdrop utility at only medium screen sizes and above.

Available Filter Functions

By default, no values are provided for any filter

  • .blur-{value}
  • .brightness-{value}
  • .contrast-{value}
  • .drop-shadow-{value}
  • .grayscale-{value}
  • .hue-rotate-{value}
  • .invert-{value}
  • .saturate-{value}
  • .sepia-{value}

Utility for filter: opacity() or backdrop-filter: opacity() is not provided because according to MDN this function is similar to the more established opacity property. The difference is that with filters, some browsers provide hardware acceleration for better performance.

So, you can use Tailwind's native opacity utility.

Example Usage

// tailwind.config.js
module.exports = {
  theme: {
    filterFunctions: {
      blur: {
        1: "1px",
        2: "2px",
        3: "3px",
      },
      saturate: {
        40: "40%",
      },
    },
  },
};
<!-- filter: blur(2px) saturate(40%); -->
<div class="filter blur-2 saturate-40"></div>

<!-- backdrop-filter: blur(2px) saturate(40%); -->
<div class="backdrop blur-2 saturate-40"></div>

<!--
  filter: blur(2px) saturate(40%);
  backdrop-filter: blur(2px) saturate(40%);
-->
<div class="filter backdrop blur-2 saturate-40"></div>

<!-- filter: none; -->
<div class="filter-none"></div>

<!-- backdrop-filter: none; -->
<div class="backdrop-none"></div>