JGuang

Popup

Popup · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Popup

Slide or pop out a custom content area from the screen.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Slide or pop out a custom content area from the screen.

When to Use

It is suitable for displaying pop-up windows, information prompts, selection input, switching, etc., and supports multiple pop-up layer overlay display.

Demos

Props

NameDescriptionTypeDefault
afterCloseTriggered when completely closed() => void-
afterShowTriggered when completely showed() => void-
bodyClassNameContent section class namestring-
bodyStyleContent section styleReact.CSSProperties-
classNameContainer class namestring-
closeOnMaskClickWhether to close after clicking the mask layerbooleanfalse
closeIconCustom close button iconReactNode<CloseOutline/>
destroyOnCloseDestroy dom when not visiblebooleanfalse
disableBodyScrollMask Whether to disable body scrollingbooleantrue
forceRenderRender content forcelybooleanfalse
getContainerTo get the specified mounted HTML node, the default is body, if null returned, it would be rendered to the current nodeHTMLElement | () => HTMLElement | null() => document.body
maskWhether to display Maskbooleantrue
maskClassNameMask class namestring-
maskStyleMask styleReact.CSSProperties-
onClickTriggered when clicked, used to stop event bubbles usually(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
onCloseTriggered when closed() => void-
onMaskClickTriggered when the mask is clicked(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void-
positionThe specified location of the pop-up'bottom' | 'top' | 'left' | 'right''bottom'
showCloseButtonWhether to show a close icon buttonbooleanfalse
stopPropagationStop the propagation of some events.PropagationEvent[]['click']
styleContainer styleReact.CSSProperties-
visibleWhether visiblebooleanfalse
closeOnSwipeWhether to support closing by swiping up/downbooleanfalse

CSS Variables

NameDescriptionDefaultGlobal
--z-indexz-index of the popup element1000--adm-popup-z-index

CenterPopup

CenterPopup does not support the position property, and the default value of getContainer is null, other properties are the same as Popup.

Demos

Props

The props are the same with Popup expect for positon.

CSS Variables

NameDescriptionDefaultGlobal
--background-colorThe background color of the popup layer.#ffffff--adm-center-popup-background-color
--border-radiusThe border radius of the popup layer.8px--adm-center-popup-border-radius
--max-widthThe max width of the popup layer.75vw--adm-center-popup-max-width
--min-widthThe min width of the popup layer.280px--adm-center-popup-min-width
--z-indexz-index of the popup element1000--adm-center-popup-z-index