import React from 'react'; import { createPortal } from 'react-dom'; import { FaTimes } from 'react-icons/fa'; // Assuming you have react-icons installed // Added size prop to control modal width const Modal = ({ isOpen, onClose, title, children, size = 'lg' }) => { if (!isOpen) return null; // Determine max-width class based on size prop let maxWidthClass = 'max-w-lg'; // Default size if (size === 'md') { maxWidthClass = 'max-w-md'; } else if (size === 'xl') { maxWidthClass = 'max-w-xl'; } else if (size === '2xl') { maxWidthClass = 'max-w-2xl'; } else if (size === 'full') { maxWidthClass = 'max-w-full'; // Use with caution, might need padding adjustments } // Use createPortal to render the modal outside the main app div return createPortal(
{/* Use maxWidthClass here */}
{/* Modal Header */}

{title}

{/* Modal Body */}
{children}
, document.body // Render into the body ); }; export default Modal;