Skip to content

Instantly share code, notes, and snippets.

@ethereumdegen
Created March 27, 2023 01:52
Show Gist options
  • Save ethereumdegen/ba71392f62d5b502f4c95796d2b63b00 to your computer and use it in GitHub Desktop.
Save ethereumdegen/ba71392f62d5b502f4c95796d2b63b00 to your computer and use it in GitHub Desktop.
react tailwind modal
import { useState } from 'react';
import { observer } from "mobx-react";
function Modal({isOpen, closeModal, title, children}) {
return (
<>
{isOpen && (
<div className="fixed z-10 inset-0 overflow-y-auto">
<div className="flex items-center justify-center min-h-screen">
<div className="bg-white w-11/12 sm:w-8/12 lg:w-6/12 xl:w-4/12 rounded-lg shadow-lg overflow-hidden">
<div className="bg-blue-500 text-white px-4 py-3">
<h3 className="font-bold text-lg"> {title} </h3>
<button onClick={closeModal} className="float-right focus:outline-none">
<span className="text-lg">&times;</span>
</button>
</div>
<div className="p-4">
{children}
</div>
</div>
</div>
</div>
)}
</>
);
}
export default observer(Modal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment