Modal dialog

A modal dialog displays content that requires user interaction, in a layer above the page.

Installation

Package installation information
Installyarn add @atlaskit/modal-dialog
SourceBitbucket.org, (opens new window)
npm@atlaskit/modal-dialog, (opens new window)
Bundleunpkg.com, (opens new window)

Props

autoFocus

Description

Pass an element ref to focus on a specific element on load. Default behavior is focus is moved to the first interactive element inside the modal dialog.

TypeRefObject<HTMLElement>

children

Description

Contents of the modal dialog.

Typestring | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal

focusLockAllowlist

Description

Callback function which lets you allowlist nodes so they can be interacted with outside of the focus lock. Return true if focus lock should handle element, false if not.

Type(element: HTMLElement) => boolean

height

Description

Height of the modal dialog. When unset the modal dialog will grow to fill the viewport and then start overflowing its contents.

Typestring | number

isBlanketHidden

Description

Will remove the blanket tinted background color.

Typeboolean

label

Description

The label of the modal dialog that is announced to users of assistive technology. This should only be used if there is no modal title being associated to your modal, either via using the modal title component or the titleId prop within the useModal context.

Typestring

onClose

Description

Callback function called when the modal dialog is requesting to be closed.

Type(e: KeyboardOrMouseEvent, analyticEvent: UIAnalyticsEvent) => void

onCloseComplete

Description

Callback function called when the modal dialog has finished closing.

Type(element: HTMLElement) => void

onOpenComplete

Description

Callback function called when the modal dialog has finished opening.

Type(node: HTMLElement, isAppearing: boolean) => void

onStackChange

Description

Callback function called when the modal changes position in the stack.

Type(stackIndex: number) => void

ref

Description

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}

Typestring | Ref<HTMLElement>

shouldCloseOnEscapePress

Deprecated
Description

Calls onClose when pressing escape.

This prop will be removed in a future major release. Closing on escape is standard modal behaviour and should not be disabled. If you need to prevent closing during an in-progress async action, instead handle the onClose callback to block the action conditionally.

Typeboolean

shouldCloseOnOverlayClick

Description

Calls onClose when clicking the blanket behind the modal dialog.

Typeboolean

shouldReturnFocus

Description

ReturnFocus controls what happens when the user exits focus lock mode. If true, focus returns to the element that had focus before focus lock was activated. If false, focus remains where it was when the FocusLock was deactivated. If ref is passed, focus returns to that specific ref element.

Typeboolean | RefObject<HTMLElement>

shouldScrollInViewport

Description

Will set the scroll boundary to the viewport. If set to false, the scroll boundary is set to the modal dialog body.

Typeboolean

stackIndex

Description

The stackIndex is a reference to the position (index) of the calling dialog in a modal dialog stack. New modals added to the stack receive the highest stack index of 0. As more modals are added to the stack, their index is dynamically increased according to their new position. Don't alter the modal stack position using stackIndex in implementations of third-party libraries (e.g. AUI modal), it may lead to unpredictable bugs, especially if the third party library has its own focus lock. Additionally, each modal in the stack gets a vertical offset based on stackIndex value.

Typenumber

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests. If not overridden using testId prop in the respective components, this will set data-testid on these elements when defined:

  • Modal dialog: {testId}
  • Modal header: {testId}--header
  • Close button: {testId}--close-button
  • Modal title: {testId}--title
  • Modal body: {testId}--body
  • Modal footer: {testId}--footer
  • Scrollable element: {testId}--scrollable
  • Blanket: {testId}--blanket
Typestring

UNSAFE_shouldDisableMotionUplift

Description

@internal NOT FOR PUBLIC USE. This prop is used to disable the new motion uplift. It is strictly only used for cases where the motion uplift is not working as expected.

@warning Use with caution. This prop will be removed in a future release.

Typeboolean

width

Description

Width of the modal dialog. The recommended way to specify modal width is using named size options.

Typestring | number

children

Required
Description

Children of modal dialog footer.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

hasInlinePadding

Description

Determines whether inline padding will be applied. Defaults to true.

Typeboolean

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

children

Description

Children of modal dialog header.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

hasCloseButton

Description

Shows a close button at the end of the header.

Defaultfalse
Typeboolean

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

Close button props

appearance

Description

Appearance of the modal that changes the color of the primary action and adds an icon to the title.

Type"danger" | "warning"

children

Description

Children of modal dialog header.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

isMultiline

Description

When true will allow the title to span multiple lines. Defaults to true.

Typeboolean

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

children

Description

Children of modal dialog footer.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests.

Typestring

Hooks

useModal

useModal will return an object of type ModalAttributes.

hasProvidedOnClose

Description

A boolean for if the onClose is provided. We define a noop as our onClose at the top level, but we need to know if one is provided for the close button to be rendered.

Typeboolean

isFullScreen

Required
Description

Whether or not the modal is fullscreen (when width="full" is passed to the modal).

Typeboolean

onClose

Required
Description

Callback function called when the modal dialog is requesting to be closed, wrapped in modal dialog's analytic event context.

Type(e: KeyboardOrMouseEvent, analyticEvent: UIAnalyticsEvent) => void

testId

Description

Test ID passed to the modal dialog.

Typestring

titleId

Required
Description

Id referenced by the modal dialog's aria-labelledby attribute. This id should be assigned to the modal title element.

Typestring
Was this page helpful?
We use this feedback to improve our documentation.
© 2026 AtlassianTrademark, (opens new window)Privacy, (opens new window)License