npm install tailwind-redux-modal
import React from 'react';
import { Modal } from 'react-modal-tailwind'
const ModalExample = () => {
const { close } = useModal();
return (
<Modal>
<Modal.Trigger>Open Modal</Modal.Trigger>
<Modal.Content>
<Modal.Header>Modal Header</Modal.Header>
<Modal.Body>Modal Body Content</Modal.Body>
<Modal.Footer>
<button onClick={close}>Close Modal</button>
</Modal.Footer>
</Modal.Content>
</Modal>
);
};
export default ModalExample;
import React from 'react';
import { Modal } from 'react-modal-tailwind'
export const ModalExample = () => {
const { close, resize } = useModal()
return (
<Modal fullscreen {...props}>
<Modal.Trigger className="bg-blue-500 text-white p-3 rounded-sm">
Modal Trigger
</Modal.Trigger>
<Modal.Content>
<Modal.Header>
<h3 className='w-full text-center'>Modal Header</h3>
</Modal.Header>
<Modal.Body className='w-full text-center py-10'>
<h3>Modal body</h3>
</Modal.Body>
<Modal.Footer>
<div className='w-full justify-center flex gap-3'>
<button
onClick={close}
className="bg-blue-500 flex-1 max-w-[250px] text-white px-3 py-2 rounded-sm"
>
Close
</button>
<button
onClick={resize}
className="bg-blue-500 flex-1 max-w-[250px] text-white px-3 py-2 rounded-sm"
>
Resize
</button>
</div>
</Modal.Footer>
</Modal.Content>
</Modal>
);
};
The <Modal />
component accepts the following props:
Prop | Type | Description |
---|---|---|
open |
boolean |
Determines if the modal is open. |
onOpenChange |
(nextOpen: boolean) => void |
Callback function triggered when the open state changes. |
children |
React.ReactNode |
The content to render inside the modal. |
open |
boolean |
Controlled prop to manage the modal's open state. |
fullscreen |
boolean |
Enables full-screen mode for the modal. |
isResizable |
boolean |
Allows resizing the modal if set to true . |
isClosable |
boolean |
Enables closing the modal via a close button or other actions. |