1.0.3 • Published 2 years ago

react-modal-hooks-styled-component v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-modal-hooks-styled-components

A simple Modal that can be closed by clicking outside and "Esc" button as well as the cross button inside the modal. This component is made by using styled component and react hooks.

Basic Demo Modified Demo

NPM Link

Props NameDescription
customBackgroundStyleobject that contains styled property for the overlay background of the modal
customWrapperStyleobject that contains styled property for the wrapper component of the modal
closeModalButtonStyleobject that contains styled property for the close icon of the modal
showModal (required)boolean value to show modal or not
setShowModal (required)function to toggle the value of show modal
modalCloseButtonboolean to decide if the cross icon of the modal should be showed or not

Bacic Code

import React, { useState } from "react";
import Modal from "react-modal-hooks-styled-component";

export default function App() {
  const [showModal, setShowModal] = useState(false);
  return (
    <div className="App">
      <button onClick={() => setShowModal(!showModal)}>Click Me</button>
      <Modal showModal={showModal} setShowModal={setShowModal}>
        <h1>Modal</h1>
      </Modal>
    </div>
  );
}