Giter VIP home page Giter VIP logo

tailwindcss-labeled-groups's Introduction

Warning

Since TailwindCSS v3.3, you can handle nested groups natively. See the official documentation .

Tailwind Labeled Groups

A plugin that allows to create multiple groups utilities such as group-card or group-1 and works with Tailwind 3 features and all variations.


Installation

Install the plugin:

# npm
npm install -D tailwindcss-labeled-groups
# yarn
yarn add -D tailwindcss-labeled-groups

Then add the plugin to your tailwind.config.js file:

module.exports = {
  theme: {
    // ...
  },
  plugins: [
    // This plugin allows you to create custom Tailwind groups.
    // e.g. if you use ['custom'], you could use it as follows:
    //      In the parent: group-custom
    //      In the child:  group-custom-hover:
    require('tailwindcss-labeled-groups')(['custom', '1', /* RENAME ME! */ ])
    // ...
  ],
}

Remember to rename your custom groups!

You are ready to use it

Usage

Assuming we have registered the plugin as follows

require('tailwindcss-labeled-groups')(['custom', '1'])

We now can use:

  • group (default Tailwind value)
  • group-custom and group-1 (registered in the plugin) with every possible combination of variation
<div class="group-custom">
    <div class="group-1">
        <div class="group-1-active:text-slate-500"></div>
    </div>
    <div class="group-custom-focus:bg-pink-200"></div>
</div>

Demo

You can see how it works here: https://play.tailwindcss.com/SMCKXsGYsg

Acknowledgement

Inspired by: tailwindcss-named-groups

tailwindcss-labeled-groups's People

Contributors

onmax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

stxapps

tailwindcss-labeled-groups's Issues

Using group names without state?

I'd love to use the labeled groups without a state.

I'd use JavaScript to toggle the necessary group classes and then reference that group in child elements.

<ul>
  <li class="group-active-item">
     <div class="group-active-item:text-blue-500">Title</div>
     <div class="hidden group-active-item:block">Content</div>
  </li>
</ul>

JIT mode

Can you add the possibility of adding a labeled group in the code?

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.