Dialog

Designer doc
Dialog component displays a modal window to communicate important information or prompt users for input, typically requiring user interaction before they can proceed with other tasks.

Example

Basic usage
Any tabbable element in DialogContent and DialogActions will be autofocused when dialog opens. The recommended width is 480px, 600px, 840px and 1200px.
View code
Alert Dialog
Use props type to display alert dialog icons in front of the dialog title.
View code
WAI-ARIA Keyboard Interactions Note
When a dialog closes, focus returns to the element that invoked the dialog unless either:
  • The invoking element no longer exists. Then, focus is set on another element that provides logical work flow.
  • The work flow design includes the following conditions that can occasionally make focusing a different element a more logical choice:
    • It is very unlikely users need to immediately re-invoke the dialog.
    • The task completed in the dialog is directly related to a subsequent step in the work flow.
    For example, a grid has an associated toolbar with a button for adding rows. the Add Rows button opens a dialog that prompts for the number of rows. After the dialog closes, focus is placed in the first cell of the first new row.
Obtaining this behaviour
It will be too difficult for Coral’s Dialog to predict and implement this behaviour. Instead, you can provide transitionFrom and returnFocusTo to customise the animation and return focus target. By default both values are the last focused element before dialog opens.
View code
Multi-steps Dialog
It is recommended to use multi-steps dialog when you need dialog to open while another dialog is active. Some examples are discard input confirmation or inputs verification.
View code
Uncontrolled
By default, Dialog will be open if isOpen prop not provided.
View code
Immediate
As you can see in Uncontrolled section, Dialog is not animated when going to “Page with Dialog”. This is because Dialog by default will only animate after first render. However, you can override this behaviour with immediate prop.
This is slightly different from transitionFrom = null because this does not even slide animate.
View code
Top and Bottom Shadows
When the content overflows, shadows will appear if DialogContent is scrollable to top or bottom. Internally, it uses IntersectionObserver instead of scroll listener, so that it can also handle content size changes.
View code
Render components with negative tabIndex
By default, react-focus-lock will always focus to components with negative tabIndex. Hence, this behavior is overridden using custom FocusLock component.
View code

References

API

Dialog
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
autoFocusboolean
containerHTMLElement
disableFocusLockboolean
disableScrollLockboolean
immediateboolean
initialIsOpenboolean
isOpenboolean
onClose() => void
onOutsideClickMouseEventHandler<HTMLDivElement>
overlayPropsOmit<DialogOverlayProps, "id" | "immediate" | "container" | "onClose" | "isOpen" | "initialIsOpen" | "onOutsideClick" | "transitionFrom" | "returnFocusTo">
returnFocusToElement
transitionFromElement
typeDialogTypes
DialogActions
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
DialogBox
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
autoFocusbooleantrue
disableFocusLockboolean
disableScrollLockboolean
typeDialogTypes
DialogClose
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
colorTypeColorTypesneuFore2nd
Set color based on theme. If color is specified, that prop is used instead of this.
disabledboolean
Equivalent to button's disabled property.
keyboardClickKeysstring[]
loadingboolean
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
radiusstring
sizeIconButtonSizes
tooltipReactNode
tooltipPropsOmit<TooltipProps, "title" | "children">
variantIconButtonVariants
DialogContent
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
DialogOverlay
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
containerHTMLElementconfigs.getPortalContainer('DialogOverlay', 'container')
elevationLevelnumber3
immediateboolean
initialIsOpenbooleantrue
isOpenboolean
onClose() => void
onOutsideClickMouseEventHandler<HTMLDivElement>
returnFocusToElement
transitionFromElement
DialogTitle
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
    Example
    Example
    Basic usage
    Basic usage
    Alert Dialog
    Alert Dialog
    WAI-ARIA Keyboard Interactions Note
    WAI-ARIA Keyboard Interactions Note
    Obtaining this behaviour
    Obtaining this behaviour
    Multi-steps Dialog
    Multi-steps Dialog
    Uncontrolled
    Uncontrolled
    Immediate
    Immediate
    Top and Bottom Shadows
    Top and Bottom Shadows
    Render components with negative tabIndex
    Render components with negative tabIndex
    References
    References
    API
    API
    Dialog
    Dialog
    DialogActions
    DialogActions
    DialogBox
    DialogBox
    DialogClose
    DialogClose
    DialogContent
    DialogContent
    DialogOverlay
    DialogOverlay
    DialogTitle
    DialogTitle
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs