Skip to content
This repository has been archived by the owner on Oct 2, 2023. It is now read-only.

JIT mode #2

Open
GENL opened this issue Jul 25, 2022 · 1 comment
Open

JIT mode #2

GENL opened this issue Jul 25, 2022 · 1 comment

Comments

@GENL
Copy link

GENL commented Jul 25, 2022

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

@onmax
Copy link
Owner

onmax commented Jul 26, 2022

Yes, you can do that without this plugin if you are using Tailwind 3.1+.

You need to use an arbitrary variation as follows:

<a href="#" class="group-my-custom">
  <p class="[.group-my-custom:hover_&]:text-pink-800">Lorem ipsum</p>
</a>

This will generate the following CSS:

/* Base CSS... */

.group-my-custom:hover .\[\.group-my-custom\:hover_\&\]\:text-pink-800 {
  --tw-text-opacity: 1;
  color: rgb(157 23 77 / var(--tw-text-opacity));
}

This means you can use any class name for the group. For example you could use banana and in the child [.banana:hover_&]:bg-pink-800.

This solution is cool if you don't want to change the Tailwind config, but it does the drawback that you have to use your own selector which can make you code less readable.

Examples:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants