nuxt / ui

A UI Library for Modern Web Apps, powered by Vue & Tailwind CSS.
https://ui.nuxt.com
MIT License
4.11k stars 542 forks source link

Using Headless UI CSS modifiers inside Nuxt app #2715

Closed sergeykorobeynikov closed 22 hours ago

sergeykorobeynikov commented 1 day ago

For what version of Nuxt UI are you asking this question?

v2.x

Description

Is there any way to use Headless UI CSS modifiers in a Nuxt app, ui-open, to control the set of css classes?

<script setup lang="ts">
import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue';
</script>

<template>
  <div>
    <Disclosure>
      <DisclosureButton>
        <div class="text-red-500 ui-open:text-cyan-700">Button</div>
      </DisclosureButton>
      <DisclosurePanel>Text</DisclosurePanel>
    </Disclosure>
  </div>
</template>
benjamincanac commented 22 hours ago

We're registering the @headlessui/tailwind plugin already: https://github.com/nuxt/ui/blob/dev/src/tailwind.ts#L47 so you should be able to use those ui-open modifiers.

sergeykorobeynikov commented 22 hours ago

Yes, it works! I apologize, I wrote a question with an example and did not check it, but it works!

In fact, the problem was in the following set:

<div class="rounded-xl ui-open:rounded-none ui-open:rounded-t-xl">...</div>