<dialog open onClose={onClose}>
<h1>Modal</h1>
<p>This is a modal</p>
<button onClick={onClose}>Close</button>
</dialog>
);
function App() {
const [showModal, setShowModal] = useState(false);
return (
<>
<button onClick={() => setShowModal(true)}>Show Modal</button>
{showModal ? <Modal onClose={() => setShowModal(false)} /> : null}
</>
);
}
dialog element have two feature. 1. backdrop filter that change color of background without need of any element and style. 2. block every element in ui so that you can;t click outside of modal. and for that to happen it's must be open with js.
Обсуждают сегодня