Skip to content

Instantly share code, notes, and snippets.

@chadmuro
Created November 1, 2021 14:34
Show Gist options
  • Save chadmuro/d2c1743eb74fb174dafca1c19daad456 to your computer and use it in GitHub Desktop.
Save chadmuro/d2c1743eb74fb174dafca1c19daad456 to your computer and use it in GitHub Desktop.
Headless UI Dialog
import { Dialog } from '@headlessui/react';
const ModalDialog = ({ isOpen, setIsOpen }) => {
return (
<Dialog open={isOpen} onClose={() => setIsOpen(false)}>
<div className="flex items-center justify-center min-h-screen">
<Dialog.Overlay className="fixed inset-0 bg-black opacity-30" />
<div className="relative bg-white rounded max-w-sm mx-auto p-8">
<Dialog.Title className="text-xl">Title of dialog</Dialog.Title>
<Dialog.Description>
Description of dialog contents.
</Dialog.Description>
<button
className="border-black border-solid border rounded mx-2 mt-8 py-1 px-2"
onClick={() => setIsOpen(false)}
>
Cancel
</button>
<button
className="border-black border-solid border rounded mx-2 mt-8 py-1 px-2"
onClick={() => setIsOpen(false)}
>
Confirm
</button>
</div>
</div>
</Dialog>
);
};
export default ModalDialog;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment