Code Monkey home page Code Monkey logo

Comments (10)

ycs77 avatar ycs77 commented on May 11, 2024 1

Now support the dialog in v0.11, can see the docs Dialog mode to use it, open a new issue if you have any problems.

And the demo has the example of dialog.

from headlessui-float.

ycs77 avatar ycs77 commented on May 11, 2024

Hi @WesleyKapow, I think the Headless UI Float is not made for Dialog (Modal); could you please explain how you intend to use both Dialog and Headless UI Float?

from headlessui-float.

WesleyKapow avatar WesleyKapow commented on May 11, 2024

In the same way it is used for Popover it'd be nice if it could also be used with headless Dialog.

from headlessui-float.

ycs77 avatar ycs77 commented on May 11, 2024

@WesleyKapow Can you please describe what kind of function you want to develop that will be used in this way?😅 and provide some sample code or screenshots.

from headlessui-float.

tienle avatar tienle commented on May 11, 2024

@ycs77 We are in the same situation. Dialog is controlled while Popover is not, so there is a case you may need it to emulate "Popover" with Dialog. Similar to Radix Popover:
https://www.radix-ui.com/docs/primitives/components/popover

from headlessui-float.

WesleyKapow avatar WesleyKapow commented on May 11, 2024

https://headlessui-float.vercel.app/vue/other-options.html shows how to use Float with a headless Menu. I'd like to do the same but for a headless Dialog. I need this in order to control the position of a Dialog. For now, I ended up using https://floating-ui.com/ directly to control the position of my headless Dialog.

from headlessui-float.

whitespacecode avatar whitespacecode commented on May 11, 2024

@WesleyKapow you need to understand menu and popover elements are positioned against a parent element (button or menu-item), that is why you can use float-ui to position the child elements around the parent element.
A Dialog or modal is just a popup inside a container. You don't need float-ui to position the dialog.

Vue example for Dialog:

<script setup>
import { ref } from 'vue'
import { Dialog, DialogPanel, DialogTitle, TransitionChild, TransitionRoot } from '@headlessui/vue'

const open = ref(true)
</script>

<template>
  <TransitionRoot as="template" :show="open">
    <Dialog as="div" class="relative z-10" @close="open = false">
      <TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in duration-200" leave-from="opacity-100" leave-to="opacity-0">
        <div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
      </TransitionChild>

      <div class="fixed inset-0 z-10 overflow-y-auto">
        <div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
          <TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enter-to="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leave-from="opacity-100 translate-y-0 sm:scale-100" leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
            <DialogPanel class="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6">
                <div class="mt-3 text-center sm:mt-5">
                  <DialogTitle as="h3" class="text-lg font-medium leading-6 text-gray-900">Payment successful</DialogTitle>
                  <div class="mt-2">
                    <p class="text-sm text-gray-500">Lorem ipsum dolor sit amet consectetur adipisicing elit. Consequatur amet labore.</p>
                  </div>
                </div>
              <div class="mt-5 sm:mt-6">
                <button type="button" class="inline-flex w-full justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-base font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:text-sm" @click="open = false">Go back to dashboard</button>
              </div>
            </DialogPanel>
          </TransitionChild>
        </div>
      </div>
    </Dialog>
  </TransitionRoot>
</template>

Just change the classes to position the dialog. No need for another package when using a Dialog.

from headlessui-float.

ycs77 avatar ycs77 commented on May 11, 2024

Ok, I have some ideas to support Dialog, but it will take a while.

from headlessui-float.

WesleyKapow avatar WesleyKapow commented on May 11, 2024

Just an FYI, I did end up using floating-ui directly in this case and not using headlessui-float.

from headlessui-float.

ycs77 avatar ycs77 commented on May 11, 2024

Just an FYI, I did end up using floating-ui directly in this case and not using headlessui-float.

Of course, floating-ui can be manipulated more freely than headlessui-float.

from headlessui-float.

Related Issues (20)

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.