Skip to content

Modal

EModal is a modal window that appears momentarily on top of the main screen. It pauses the current app operation to request the user for a response.

The main screen is blocked while the modal is active. Returning to the main window requires a user action or confirmation. Demo Here

Import

jsx
import EModal from "@components/Elements/EModal";

Usage

jsx
const ModalExample = () => {
    const [isModalShown, setIsModalShown] = useState(false);

    const onBtnClick = () => {
        setIsModalShown(true)
    }

    const onBackdropClick = () => {
        setIsModalShown(false)
    }

    return (
        <Fragment>
            <EBtn onClick={onBtnClick}>
                Open Modal
            </Btn>
            <EModal
                status={isModalShown}
                toggleModal={onBackdropClick}
                title="Modal title"
            >
                Modal content
            </EModal>
        </Fragment>
    );
};

export default ModalExample;

Props

For EModal component, the following props are available:

PropTypeDefaultNote
footernode-Footer content.
portalBooleantrueEnables react portal.
blurEffectBooleantrueApplies background blur.
scrollableBooleanfalseActivates overflow-y-auto.
width[String, Number]-Sets the component's width. Default unit is px.
height[String, Number]-Sets the component's height. Default unit is px.
squareBooleanfalseRemoves rounded corners of the element.
closeIconBooleanfalseAdds close icon to modal header.
titlenode-Adds a title to the EModal element.
maxHeight[String, Number]-Sets the component's max height. Default unit is px.
statusBooleanfalseControls the visible/hidden state of modal.
disablePageScrollBooleantrueDisables page scrolling when modal is open.
classNameString-Overrides or extends the component's wrapper styles.
persistentBooleanfalsePersistent EModal is not discarded when touching outside.
sizeString"md"The EModal element has three predefined sizes: sm, md, lg.
animationString"component-pop-out"The EMenu element can be animated in many ways. Defined animations here.
positionString"center-center"The EModal element can appear from the center-center, center-right, center-left, top-center, top-right, top-left, bottom-center, bottom-right, bottom-left, edge of the viewport.

Callback Functions

The EModal component contains following callback functions.

FunctionDescription
toggleModalToggles modal active state. function(event: React.SyntheticEvent, isOpen: Boolean) => void 👇

event: The event source of the callback.
isOpen: visible/hidden state of modal

Children

The EModal component provides a children props that enable you to customize the content.

ChildrenDescription
✔️Component's content.

COPYRIGHT