@tim-jn/react-modal

2.1.0 • Public • Published

@Tim-jn/react-modal

Responsive modal dialog component for React.

Installation

To install, you can use npm or yarn:

$ npm install @tim-jn/react-modal
$ yarn add @tim-jn/react-modal
  • Use <Modal> tag inside your React app.

Exemple

import { Modal } from '@tim-jn/react-modal/dist'
import React from 'react'

export default function Form() {
  window.React = React

  const [isValid, setIsValid] = useState(false)
  
  const handleModalResponse = () => {
    setIsValid(false)
  }

  const handleAddFormSubmit = (e) => {
    e.preventDefault()
    setIsValid(true)
  }

  return (
    <section className="formContent">
      <h2 className="formTitle">Create Employee</h2>
      <form className="form" onSubmit={handleAddFormSubmit}>
        (...)
      </form>
      {isValid ? <Modal text="Employee Created !" handleResponse={handleModalResponse} /> : ''}
    </section>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i @tim-jn/react-modal

Weekly Downloads

1

Version

2.1.0

License

MIT

Unpacked Size

12.4 kB

Total Files

13

Last publish

Collaborators

  • tim-jn