react-portal-drawer
v1.0.1
Published
Drawer modal using React portal
Downloads
1
Maintainers
Readme
react-portal-drawer
Installation
$ npm i react-portal-drawer
$ yarn add react-portal-drawer
Examples
Minimal
<body>
<div id="root"></div>
</body>
import React from "react";
import PortalDrawer from "react-portal-drawer";
const App = () => <PortalDrawer selectors="#root" />;
General
<body>
<div id="root"></div>
<div id="modal-root"></div>
</body>
import React, { useState } from "react";
import PortalDrawer from "react-portal-drawer";
const App = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const openModal = () => {
setIsModalOpen(true);
};
const closeModal = () => {
setIsModalOpen(false);
};
return (
<>
<button onClick={openModal}>open</button>
{isModalOpen && (
<PortalDrawer selectors="#modal-root" requestClose={closeModal}>
<div>Any content</div>
<button onClick={closeModal}>close</button>
</PortalDrawer>
)}
</>
);
};