Modal component
The Modal component displays a simple modal with a title and content.
Basic usage
Example:
import { Page, Modal } from '@kottster/react';
export default () => {
const [isModalOpen, setIsModalOpen] = useState(false);
return (
<Page title='About Us'>
Hello, this is the content of the page.
{isModalOpen && (
<Modal
title='Modal Title'
onClose={() => setIsModalOpen(false)}
>
This is the content of the modal.
</Modal>
)}
</Page>
);
};Properties
title
string, optionalThe title displayed at the top of the modal.
subtitle
string, optionalThe subtitle displayed below the title in the modal.
titleWithMargin
boolean, optionalA boolean indicating whether to add margin below the title section.
isOpen
booleanA boolean indicating whether the modal is open or closed.
onClose
functionA callback function that is called when the modal is requested to be closed.
children
ReactNode, optionalThe content of the modal passed as children. This can be any valid React element.
width
string | number, optionalThe width of the modal. This can be specified in pixels or any valid CSS width value.
maxWidth
string | number, optionalThe maximum width of the modal. This can be specified in pixels or any valid CSS width value.
className
string, optionalAdditional CSS class names to apply to the modal for custom styling.
closeOnBackdropClick
boolean, optionalA boolean indicating whether the modal should close when the backdrop is clicked.
headerRightSection
ReactNode, optionalA custom component displayed on the right side of the modal header.
bottomSection
ReactNode, optionalA custom component displayed at the bottom of the modal, below the main content.