Modal

Modal UI Component

The Modal component provides a flexible and customizable way to display modal dialogs in your React applications. It offers various options and configurations to control the appearance and behavior of the modal dialogs.

Demo

Installation

Install the Modal component using npm:

npm install @synerise/ds-core

Deprecated Features

Some features of the Modal component have been deprecated. Please refer to the API and FOOTER section for more information on deprecated features.

API

(Deprecated) type Props is deprecated - recommended is using ModalProps

ModalProps

PropertyDescriptionTypeDefaultVersion
descriptionThe modal dialog's descriptionstring-
headerActionsAppend additional content to header actions spaceReact.ReactNode-
sizeThe modal sizesmall / medium / large / extraLarge/ fullSize.-
bodyBackgroundSet color for body of modalwhite / greywhite
blankModal with header which contains only close buttonBooleanfalse
titleContainerStyleThe modal title's container styles objectReact.CSSProperties / undefined-
settingButtonTextText of the setting buttonstringSetting
textsLabels to render{ okButton: string; cancelButton: string }{ okButton: 'Apply', cancelButton: 'Cancel' }
childrenChildren element to render{ okButton: string; cancelButton: string }-
visibleWhether the modal dialog is visible or notbooleanfalse
confirmLoadingWhether to apply loading visual effect for OK button or notbooleanfalse
titleThe modal dialog's titlestring / ReactNode-
closableWhether a close (x) button is visible on top right of the modal dialog or notbooleantrue
onOkSpecify a function that will be called when a user clicks the OK buttonfunction(e)-
onCancelSpecify a function that will be called when a user clicks mask, close button on top right or Cancel buttonfunction(e)-
afterCloseSpecify a function that will be called when modal is closed completely.function-
centeredCentered ModalBooleanfalse
widthWidth of the modal dialogstring / number520
footerFooter content, set as footer={null} when you don't need default buttonsReactNodeOK and Cancel buttons
okTextText of the OK buttonstring / ReactNodeOK
okTypeButton type of the OK buttonstringprimary
cancelTextText of the Cancel buttonstring / ReactNodeCancel
maskClosableWhether to close the modal dialog when the mask (area outside the modal) is clickedbooleantrue
forceRenderForce render Modalbooleanfalse
okButtonPropsThe ok button propsButtonProps-
cancelButtonPropsThe cancel button propsButtonProps-
destroyOnCloseWhether to unmount child components on onClosebooleanfalse
styleStyle of floating layer, typically used at least for adjusting the position.object-
wrapClassNameThe class name of the container of the modal dialogstring-
getContainerReturn the mount node for ModalHTMLElement / () => HTMLElement / Selectors /falsedocument.body
zIndexThe z-index of the ModalNumber1000
bodyStyleBody style for modal body element. Such as height, padding etc.object{}
maskWhether show mask or not.Booleantrue
closeIconcustom close iconReactNode-
maskStyleStyle for modal's mask element.object{}

and it is extended by props for ModalFooterBuilder:

PropertyDescriptionTypeDefaultVersion
prefixElement in footer, before Cancel ButtonReactNode-
infixElement in footer between Cancel Button nad before Ok ButtonReactNode-
suffixElement in footer, after Ok ButtonReactNode-
okButtonCustom OK button in footerReactNode-
cancelButtonCustom Cancel button in footerReactNode-

ModalTitle

type ModalTitleProps = Pick<
ModalProps,
| 'headerActions'
| 'onCancel'
| 'titleContainerStyle'
| 'blank'
| 'description'
| 'title'
>;

ModalFooter

export type ModalFooterProps = Pick<
ModalProps,
| 'prefix'
| 'infix'
| 'suffix'
| 'okButton'
| 'cancelButton'
| 'CustomFooterButton'
| 'DSButton'
| 'texts'
| 'onOk'
| 'onCancel'
| 'cancelText'
| 'okText'
| 'cancelButtonProps'
| 'okType'
| 'okButtonProps'
>;

(Deprecated) method buildModalFooter - use ModalFooter Component instead