1.0.2 • Published 7 months ago

@cymard/simple-react-modal-component v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

simple-react-modal-component

A simple react modal component

Prerequisites

These are the dependencies along with their recommended versions:
Npm Node React React-DOM Sass

Install

npm i @cymard/simple-react-modal-component

Usage

import React, { useState } from 'react';
import { Modal } from '@cymard/simple-react-modal-component';

function App() {
    const [isOpen, setIsOpen] = useState(false);
    
    return (
        <div>
          <button onClick={() => setIsOpen(true)}>Click to open</button>
          <Modal
                isOpen={isOpen}
                onClose={() => setIsOpen(false)}
                onExternalClick={() => setIsOpen(false)}
            >
                Modal message !
            </Modal>
        </div>
    );
}

export default App;

Properties

  • isOpen (boolean): State of the modal's visibility.
  • onClose (function): Function to call to close the modal.
  • onExternalClick (function): Function to call when clicking outside the modal and its close button when it is open.
  • children (string): Text to display when the modal is open.

License

MIT © cymard

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago