0.1.1 • Published 1 year ago

react-modal-custom-component v0.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

React Modal Custom Component

A customizable React modal component

Prerequisites

  • npm
  • react >=18.2.0
  • styled-components >=5.3.6

Installation

    npm install react-modal-custom-component

Example

In this example, a button call the toggle modal function onClick that display the modal to the user.

import React from 'react';
import { Modal, useModal } from "react-modal-custom-component";


function App() {

  const { isShowing: showModal, toggle: toggleModal } = useModal();

  return (
    <div className="App">
      <button type="button" onClick={toggleModal}>Open the modal</button>
      <Modal
                isShowing={showModal}
                hide={toggleModal}
                text="Employee Created!"
                title="HRnet - Create Employee" />
    </div>
  );
}

ReactDOM.render(<App />, appElement);

Custom

Props
Prop nameDescriptionExample values
isShowingDefine if the modal is shown or notBoolean: true
hideDefine the function that is called to turn on/off the modalFunction: toggleModal
titleContent of the titleString: This is the title
textContent of the bodyString: This is the body text
primarySetup the main color for the component (header & button background)String: white / rgb(125,12,89) / #FF0000