Skip to main content

Modal

v.2.0.1

Installation

yarn add @mercell/modal-react

Usage

To render Modal in your project you just simply import it

import {
Modal,
ModalTitle,
ModalButtonsSection,
ModalContent,
} from '@mercell/modal-react';
Live Editor
Result

Types, definitions, etc.

ModalProps
interface ModalProps {
isModalVisible: boolean;
onCloseCallback: () => void;
shouldCloseOnOutsideClick?: boolean;
parent?: HTMLElement;
parentClassName?: string;
closeCrossButtonAriaLabel?: string;
ignoreOutsideClickClassName?: string;
} & JSX.IntrinsicElements['div']
NameTypeDefaultRequiredDescription
isModalVisibleboolean-yesToggle modal visibility based on value
onCloseCallbackfunction - () => void-yesCallback function to change visibility of modal
shouldCloseOnOutsideClickbooleantruenoBool responsible for checking if modal should be closed if user would click on outside of modal scope
parentHTMLElement | undefineddocument.bodynoHTML tag to mount portal of modal, by default will be document.body
parentClassNamestring-noClassName which will be passed to the parent element
oncloseCrossButtonAriaLabelExpandstring'Close'noAria name for close button to support other languages
ignoreOutsideClickClassNamestring'ignore-outside-click'noClass name to prevent close onClick e.g. on button which should invoke the modal when the shouldCloseOnOutsideClick is set to true
ModalTitle
  ModalTitle has type JSX.IntrinsicElements['h2'].
ModalContent
ModalContent has type JSX.IntrinsicElements['div'].
ModalButtonsSection
  ModalButtonsSection has type JSX.IntrinsicElements['div'].