Git Product home page Git Product logo

tailwindcss-named-groups's Introduction

TailwindCSS named groups

TailwindCSS plugin that adds named groups to the group variant. This is handy if you have nested groups hovers.

idle foo-hover bar-hover

Installation

# npm
npm install tailwindcss-named-groups --save-dev

# yarn
yarn add --dev tailwindcss-named-groups

Add the plugin to the plugins array of the tailwind config file.

// tailwind.config.js
module.exports = {
  // ...

  plugins: [
    // ...
    require("tailwindcss-named-groups"),
  ],
};

Then create your named groups in the config (no need to type group-, that will be prepended for you).

// tailwind.config.js
module.exports = {
  theme: {
    // ...
    namedGroups: ["foo", "bar"],
    // will result in group-foo and group-bar being available in addition to the base group
  },
  // ...
};

Usage

Having the named groups as foo and bar:

<div class="group-foo bg-white hover:bg-blue-500 ...">
  <p class="text-gray-900 group-foo-hover:text-white ...">
    New Project
  </p>
  <div class="group-bar bg-gray-100 hover:bg-green-500 ...">
    <p class="text-gray-500 group-bar-hover:text-white ...">
      Create a new project from a variety of starting templates.
    </p>
  </div>
</div>

Will result into this:

in-action

Extra

group-focus is also supported.

This plugin respects the group-hover and group-focus variants, so you must have them enabled where you want to use named groups:

// tailwind.config.js
module.exports = {
  // ...
  variants: {
    // Now you can use named groups in textColor for hover and focus
    textColor: ["responsive", "hover", "focus", "group-hover", "group-focus"],
  },
};

tailwindcss-named-groups's People

Contributors

andrewkfiedler avatar ericktamayo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.