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

tailwind-named-group-modifiers

v0.1.0

Published

Tailwind CSS 3 plugin for using multiple instances of the same group (a/k/a parent) modifiers on the same page. Themable via the config file.

Downloads

731

Readme

Named Group Modifiers for Tailwind CSS

A Tailwind CSS (>= 3.0.0) plugin for using multiple themable group modifiers.

Use as many group interlocking group modifiers as you wish by configuring them in your tailwind.config.js like so:

module.exports = {
    ...
    theme: {
        groups: {
            hover: ['card', 'section'],
            focusWithin: ['form'],
        },
    }
}

Requirements

Tailwind CSS >= v3.0.0

Installation

Install via NPM:

$ npm i tailwind-named-group-modifiers

Install via Yarn:

$ yarn add tailwind-named-group-modifiers

Why this Plugin?

Tailwind 3 offers group-* variants that allow styling an element based on a parent's state (read from pseudo-classes), so applying group on a parent and group-hover:opacity-100 on a child would result in CSS like this, making the child opaque when the parent is hovered over:

.group:hover .group-hover:opacity-100 {
    opacity: 1
}

This is great for simpler views, but it runs into problems when we need more than one group modifers downstream from each other in a branch of the DOM. Every element we apply group to will trigger all the group-* children further down the DOM, causing unexpected behaviour. We can only use group once on a given branch of the DOM.

This plugin conveniently handles these use cases by giving you the option of adding named groups to your tailwind.config.js.

You can also just use the plugin if you want to have a better overview of your group modifier usage.

Features

  • As of Tailwind 3, the group-* pattern can be applied to all 25(!) pseudo-class modifiers shipped with the new JIT compiler, this plugin includes all of them.

  • Using the config keeps you organized and maximally flexible with regards to other Tailwind features.

  • Follows Tailwind naming conventions whereever possible.

About the Configuration

Modifier names are the same as with the built-in group features, so group-focus e.g. becomes group-card-focus. Note that Tailwind e.g. shortens the :last-child pseudo-class to last:. We follow core as much as possible here.

The plugin is configured under the groups key in tailwind.config.js. In keeping with a Tailwind convention to have the config keys point to the actually used CSS more than the class naming, subkeys for the different pseudo-classes in the Tailwind config are usually the actual pseudo-class rendered in camelCase (e.g. last: must be configured under lastChild).

The exception to this are odd: and even:, which can be configured under oddChild and evenChild, respectively. Aside from the fact that nthChild(odd) (nthChild(Odd)?) seems kind of hard to remember, this also keeps greater consistency with first:, last: and only:.