JGuang

Mask

Mask · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Mask

Dark background layer.

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.

Dark background layer.

When to Use

Often used in the background layer of a modal window to make the visual focus stand out on the modal window itself.

Demos

Mask

Props

NameDescriptionTypeDefault
afterCloseTriggered when completely closed() => void-
afterShowTriggered after fully displayed() => void-
colorColor of the mask'black' | 'white' | string'black'
destroyOnCloseDestroy dom when not visiblebooleanfalse
disableBodyScrollWhether to disable body scrollingbooleantrue
forceRenderRender content forcelybooleanfalse
getContainerTo get the specified mounted HTML node, if null returned, it would be rendered to the current nodeHTMLElement | () => HTMLElement | nullnull
onMaskClickTriggered when the mask is clicked(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
opacityOpacity'default' | 'thin' | 'thick' | number'default'
stopPropagationStop the propagation of some events.PropagationEvent[]['click']
visibleWhether to show or hidebooleantrue

CSS Variables

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