Modal

A customizable modal component with support for headers, footers, and animations.

Installation

1. Dependencies

npm install clsx tailwind-merge

2. Paste inside @/lib/utils.ts

import { clsx } from "clsx";
import { twMerge } from "tailwind-merge";

export function cn(...inputs: Parameters<typeof clsx>) {
  return twMerge(clsx(...inputs));
}

3. Copy Modal Code

Loading...

Copy Modal Code

Modal Props

NameTypeRequiredDefaultDescription
isOpenbooleanYesfalseControls the visibility of the modal.
onClose() => voidYesundefinedCallback function triggered when the modal is closed.
childrenReact.ReactNodeYesundefinedContent to be displayed inside the modal.
classNamestringNoundefinedAdditional class names for styling the modal container.
overlayClassNamestringNoundefinedClass names for styling the modal overlay.
closeOnOutsideClickbooleanNotrueDetermines if the modal should close when clicking outside of it.
closeOnEscbooleanNotrueDetermines if the modal should close when the Escape key is pressed.

ModalHeader Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedContent to be displayed in the modal header.
classNamestringNoundefinedAdditional class names for styling the modal header.

ModalTitle Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedThe title text to display in the modal header.
classNamestringNoundefinedAdditional class names for styling the modal title.

ModalDescription Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedThe description text to display in the modal body.
classNamestringNoundefinedAdditional class names for styling the modal description.

ModalBody Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedContent to be displayed in the modal body.
classNamestringNoundefinedAdditional class names for styling the modal body.

ModalFooter Props

NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesundefinedContent to be displayed in the modal footer.
classNamestringNoundefinedAdditional class names for styling the modal footer.

ModalClose Props

NameTypeRequiredDefaultDescription
onClick() => voidNoundefinedCallback function triggered when the close button is clicked.
classNamestringNoundefinedAdditional class names for styling the close button.