Flutter docs
Default skin

Modal

Display a modal dialog box with a distinct accessible title, optional description, content area, and actions.

When to use

When requiring users to interact with the application, but without jumping to a new page and interrupting the user's workflow, you can use Modal to create a new floating layer over the current page to get user feedback or display information.

Additionally, if you need to show a simple confirmation dialog, you can use App.useApp hooks.

Use description for explanatory copy below the title. Do not place a subtitle inside title: assistive technology must receive a concise accessible name and a separate description. Focus returns to the opening control even when a controlled consumer unmounts the Modal immediately.

The positioning wrapper, backdrop and close control expose cb-modal, cb-modal__backdrop and cb-modal__close respectively. The close target and its focus indicator stay inset when text is resized. Use the upstream classNames semantic slots for additive styling.

Stacking

Most dialogs stay on the default --cb-z-modal rung. A dialog rendered by Drawer content automatically moves to the documented above-drawer rung, with its backdrop; pass layer="above-drawer" only to control an exceptional call chain deliberately. Popups the dialog itself opens — date pickers, selects, dropdowns — inherit the rung through Ant's own zIndex, so they resolve above the dialog rather than wedging underneath it.

A short follow-up Modal may open from a Modal without replacing the review behind it. Its backdrop paints above the parent panel and below its own panel, so the active task is visually distinct. Ancestry composes with elevated Drawer-backed dialogs and deeper modal parents; callers do not manually increment a z-index. The panel/backdrop separation is derived from the semantic layer Tokens. Styles supplied through the upstream semantic slots are retained; CeeBee owns the layer ordering. Keep only one focused task at a time and prefer an inline section or a page for a long workflow. The WAI-ARIA modal pattern describes the keyboard and focus expectations, including returning to the invoking dialog.

When an opener is removed, an enclosing FocusRecovery can supply an injected, ready-aware section destination. A connected opener retains ordinary return focus; an explicit return-focus opt-out disables the fallback too.

Keyboard

  • Tab and Shift+Tab move through focusable controls inside the modal.
  • Escape requests dismissal when keyboard dismissal is enabled.
  • After dismissal, focus returns to the control that opened the modal unless focusable.focusTriggerAfterClose is explicitly disabled.

Do / don't

  • Do pass a short title and supporting description as separate props.
  • Don't build a stacked title-and-subtitle React node and pass the whole block as title.
  • Do pass layer="above-drawer" only to control an exceptional overlay call chain deliberately.
  • Do keep a nested Modal focused on one short task and return to its parent when finished.
  • Don't build a long chain of dialogs, or put a Drawer inside a dialog, to work around page structure.

Examples

API

Modal, Modal.confirm, and Modal.useModal are exported from @ceebee/ui/client.

Modal

PropertyDescriptionTypeDefaultVersion
afterCloseSpecify a function that will be called when modal is closed completelyfunction-—
cancelButtonPropsThe cancel button propsButtonProps-—
cancelTextText of the Cancel buttonReactNodeCancel—
centeredCentered Modalbooleanfalse—
classNamesCustomize class for each semantic structure inside the Modal component. Supports object or function.Record<SemanticDOM, string> | (info: { props }) => Record<SemanticDOM, string>-—
closableWhether a close (x) button is visible on top right or notboolean | ClosableTypetrue-
closeIconCustom close icon. 5.7.0: close button will be hidden when setting to null or falseReactNode&lt;CloseOutlined />—
confirmLoadingWhether to apply loading visual effect for OK button or notbooleanfalse—
destroyOnCloseWhether to unmount child components on onClosebooleanfalse—
destroyOnHiddenWhether to unmount child components on onClosebooleanfalse5.25.0
focusTriggerAfterCloseWhether need to focus trigger element after dialog is closed. Please use focusable.focusTriggerAfterClose insteadbooleantrue4.9.0
footerFooter content, set as footer={null} when you don't need default buttonsReactNode | (originNode: ReactNode, extra: { OkBtn: React.FC, CancelBtn: React.FC }) => ReactNode(OK and Cancel buttons)renderFunction: 5.9.0
forceRenderForce render Modalbooleanfalse—
focusableConfiguration for focus management in the Modal{ trap?: boolean, focusTriggerAfterClose?: boolean }-6.2.0
getContainerThe mounted node for Modal but still display at fullscreenHTMLElement | () => HTMLElement | Selectors | falsedocument.body—
keyboardWhether support press esc to closebooleantrue—
maskMask effectboolean | {enabled?: boolean, blur?: boolean, closable?: boolean}truemask.closable: 6.3.0
maskClosableWhether to close the modal dialog when the mask (area outside the modal) is clicked. Please use mask.closable instead.booleantrue-
modalRenderCustom modal content render(node: ReactNode) => ReactNode-4.7.0
okButtonPropsThe ok button propsButtonProps-—
okTextText of the OK buttonReactNodeOK—
okTypeButton type of the OK buttonstringprimary—
styleStyle of floating layer, typically used at least for adjusting the positionCSSProperties-—
stylesCustomize inline style for each semantic structure inside the Modal component. Supports object or function.Record<SemanticDOM, CSSProperties> | (info: { props })=> Record<SemanticDOM, CSSProperties>-—
loadingShow the skeletonboolean—5.18.0
scrollLockWhether to lock body scroll when modal opensbooleantrue6.5.0
titleThe modal dialog's titleReactNode-—
openWhether the modal dialog is visible or notbooleanfalse—
widthWidth of the modal dialogstring | number | Breakpoint520Breakpoint: 5.23.0
wrapClassNameThe class name of the container of the modal dialogstring-—
zIndexThe z-index of the Modalnumber1000—
onCancelSpecify a function that will be called when a user clicks mask, close button on top right or Cancel buttonfunction(e)-—
onOkSpecify a function that will be called when a user clicks the OK buttonfunction(e)-—
afterOpenChangeCallback when the animation ends when Modal is turned on and off(open: boolean) => void-5.4.0

ClosableType

PropertyDescriptionTypeDefaultVersion
afterCloseSpecify a function that will be called when modal is closed completelyfunction--
closeIconCustom close iconReactNodeundefined-
disabledWhether disabled close iconbooleanfalse-
onCloseTrigger when modal closeFunctionundefined-