Modal dialog
A modal dialog displays content that requires user interaction, in a layer above the page.Installation
| Install | yarn add @atlaskit/modal-dialog |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/modal-dialog, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Props
Modal dialog props
| Description | Pass an element |
|---|---|
| Type | RefObject<HTMLElement> |
| Description | Contents of the modal dialog. |
|---|---|
| Type | string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
| Description | Callback function which lets you allowlist nodes so they can be interacted with outside of the focus lock.
Return |
|---|---|
| Type | (element: HTMLElement) => boolean |
| Description | Height of the modal dialog. When unset the modal dialog will grow to fill the viewport and then start overflowing its contents. |
|---|---|
| Type | string | number |
| Description | Will remove the blanket tinted background color. |
|---|---|
| Type | boolean |
| 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
|
|---|---|
| Type | string |
| Description | Callback function called when the modal dialog is requesting to be closed. |
|---|---|
| Type | (e: KeyboardOrMouseEvent, analyticEvent: UIAnalyticsEvent) => void |
| Description | Callback function called when the modal dialog has finished closing. |
|---|---|
| Type | (element: HTMLElement) => void |
| Description | Callback function called when the modal dialog has finished opening. |
|---|---|
| Type | (node: HTMLElement, isAppearing: boolean) => void |
| Description | Callback function called when the modal changes position in the stack. |
|---|---|
| Type | (stackIndex: number) => void |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | Ref<HTMLElement> |
| Description | Calls 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 |
|---|---|
| Type | boolean |
| Description | Calls |
|---|---|
| Type | boolean |
| 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. |
|---|---|
| Type | boolean | RefObject<HTMLElement> |
| Description | Will set the scroll boundary to the viewport. If set to false, the scroll boundary is set to the modal dialog body. |
|---|---|
| Type | boolean |
| 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 |
|---|---|
| Type | number |
| Description | A
|
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | boolean |
| Description | Width of the modal dialog. The recommended way to specify modal width is using named size options. |
|---|---|
| Type | string | number |
Modal body props
| Description | Children of modal dialog footer. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Determines whether inline padding will be applied. Defaults to true. |
|---|---|
| Type | boolean |
| Description | A |
|---|---|
| Type | string |
Modal header props
| Description | Children of modal dialog header. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Shows a close button at the end of the header. |
|---|---|
| Default | false |
| Type | boolean |
| Description | A |
|---|---|
| Type | string |
Modal title props
| Description | Appearance of the modal that changes the color of the primary action and adds an icon to the title. |
|---|---|
| Type | "danger" | "warning" |
| Description | Children of modal dialog header. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | When |
|---|---|
| Type | boolean |
| Description | A |
|---|---|
| Type | string |
Hooks
useModal
useModal will return an object of type ModalAttributes.
| Description | A boolean for if the onClose is provided. We define a |
|---|---|
| Type | boolean |
| Description | Whether or not the modal is fullscreen (when |
|---|---|
| Type | boolean |
| 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 |
| Description | Test ID passed to the modal dialog. |
|---|---|
| Type | string |
| Description | Id referenced by the modal dialog's |
|---|---|
| Type | string |