Dialog

Dialog is a box that overlay on the current page which force user interact with.

Basic

Basic usage of Dialog.

Size

Dialog allow us to input width & height to adjust the size of Dialog.

Disable Escape & backdrop click

We can disable escape key & backdrop click close by setting shouldCloseOnOverlayClick & shouldCloseOnEsc props.

Internal Scroll

Example of Dialog internal scroll.

Lock Scroll

We can lock window scroll by passing 'overflow-hidden to bodyOpenClassName

Custom dialog style

Example of Dialog custom style

Closable

Set closeable to false will hide Dialog close icon.

API

Dialog
PropDescriptionTypeDefault
widthDialog widthstring | number520
heightDialog heightstring | number-
isOpenWhether to display dialogbooleanfalse
styleStyle for dialog & backdropobject: { content: object, overlay: object }<-
contentClassNameClass name that append to Dialog contentstring-
portalClassNameClass name that append to Dialog portalstring-
bodyOpenClassNameClass name that append to body while Dialog is openstring-
htmlOpenClassNameClass name that append to html while Dialog is openstring-
overlayClassNameClass name for Dialog backdropstring-
appElementSetting external node to Dialog contentSafeHTMLElement | SafeHTMLCollection | SafeNodeList | SafeHTMLElement[]-
onAfterOpenCallback function after Dialog open(overlayElement: HTMLElement, contentElement: HTMLElement) => void-
closableWhether show Dialog close iconbooleantrue
onCloseCallback function after click on Dialog close icon(event: Event) => void-
onRequestCloseCallback function after Dialog close(event: Event) => void-
closeTimeoutMSTimeout speed during Dialog close(event: Event) => void150
shouldFocusAfterRenderBoolean indicating if the dialog should be focused after renderbooleantrue
shouldReturnFocusAfterCloseBoolean indicating if the dialog should restore focus to the element that had focus prior to its displaybooleantrue
preventScrollBoolean indicating if the dialog should use the preventScroll flag when restoring focus to the element that had focus prior to its displaybooleanfalse
shouldCloseOnOverlayClickWhether to close Dialog when the backdrop is clickedbooleantrue
shouldCloseOnEscWhether to close Dialog when esc key pressedbooleantrue
parentSelectorFunction that will be called to get the parent element that the dialog will be attached to() => document.body() => document.body
overlayRefDialog backdrop ref(node: Node) => void-
contentRefDialog content ref(node: Node) => void-