Skip to content

sbodi10/react-modal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@sbodi/react-modal

A modal created using react for react

NPM JavaScript Style Guide GitHub forks

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have installed React with a version that supports hooks

Install

npm install --save @sbodi/react-modal

Example

 <Modal
   displayModal={displayModal}
   closeModalFunction={() => setDisplayModal(false)}
   headerContent={'Header'}
   mainContent={<div>Testing this</div>}
   footerContent={<button>Button</button>}
 />

Usage

import React, { useState } from 'react';
import Modal from '@sbodi/react-modal';

function App() {
  const [displayModal, setDisplayModal] = useState(false);

  return (
    <div>
      <button onClick={() => setDisplayModal(true)}>Open modal</button>
      <Modal
        headerContent={'Header content'}
        mainContent={<textarea rows='8' placeholder={'Enter some text'} />}
        footerContent={
          <React.Fragment>
            <button
              onClick={() => setDisplayModal(false)}
            >Cancel</button>
            <button
              onClick={() => setDisplayModal(false)}
            >Confirm</button>
          </React.Fragment>
        }
        displayModal={displayModal}
        closeModalFunction={() => setDisplayModal(false)}
      />
    </div>
  );
}

Contributors

Thanks to the following people who have contributed to this project:

License

MIT © sbodi10

About

A modal created using react for react

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published