Modal() → {JSX.Element}
Component that displays a modal with the content in props
Name | Type | Description |
---|---|---|
setModalIsOpen | Object | State function used to close the modal. |
content | String | Content to display in the modal |
Returns:
A JSX.Element that contains the modal.
- Type:
- JSX.
Element
Example
import { Modal } from 'modal-nextjs'
import { useState } from 'react'
const Example = () => {
const [modalIsOpen, setModalIsOpen] = useState(false)
const handleclick = () => {
setModalIsOpen(true)
}
return (
<main>
<h1>Hello world</h1>
<button onClick={handleclick}>Click to open modal</button>
{modalIsOpen && (
<Modal
setModalIsOpen={setModalIsOpen}
content={
<div>
<p className="p-class-example">Modal is open !</p>
</div>
}
/>
)}
</main>
)
}
export default Example