-
|
Release: 3.0.18 Hello everyone, example : So in CSS it would look like: body.open-menu .child {
margin: 0.75rem
}For now, I'm using @apply in a CSS file for this type of use. Thanks for your help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
|
I don't think there is currently a built-in solution for this. You would need to write custom plugin for that purpose. There is an open PR for a plugin(function({ addVariant }) {
addVariant("open-menu", ".open-menu &");
})And you can use the variant on the child: <div class="child open-menu:m-[0.75rem]"></div>However, for this particular use case of yours, it's probably better to just use CSS, since there is not much reuse, unless you have multiple children that behave differently when the menu is open. |
Beta Was this translation helpful? Give feedback.
-
|
If you have control over the parent's class names, this works without a plugin: <div class="[--child-opacity:1]">
<div class="opacity-[var(--child-opacity,0)]">Child Element</div>
</div> |
Beta Was this translation helpful? Give feedback.
-
|
You could use arbitrary groups in Tailwind to set a class on a child if parent has a certain class. |
Beta Was this translation helpful? Give feedback.
I don't think there is currently a built-in solution for this. You would need to write custom plugin for that purpose.
There is an open PR for a
childrenvariant that may help. But for your particular case, you can write a simple plugin like this:And you can use the variant on the child:
However, for this particular use case of yours, it's probably better to just use CSS, since there is not much reuse, unless you have multiple children that behave differently when the menu is open.