JGuang

FloatingBubble <Experimental></Experimental>

FloatingBubble <Experimental></Experimental> · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

FloatingBubble <Experimental></Experimental>

A clickable bubble that hovers at the edge of the page.

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.

A clickable bubble that hovers at the edge of the page.

When to Use

Suitable for providing extra functionality to the current page.

Demos

FloatingBubble

Props

NameDescriptionTypeDefault
axisThe direction in which the drag can be performed, 'xy' means free movement, 'lock' means movement is only allowed in the direction in which the drag started.'x' | 'y' | 'xy' | 'lock''y'
childrenContent of the bubble.ReactNode-----
magneticAutomatic magnetic attraction to the boundary.'x' | 'y'-
defaultOffsetDefault offset position{ x: number; y: number }{ x: 0, y: 0 }
offsetOffset position{ x: number; y: number }
onOffsetChangeCallback function when changing(offset:{ x: number; y: number }) => void-

CSS Variables

NameDescriptionDefault
--backgroundbackground of the bubble.var(--adm-color-primary)
--border-radiusborder-radius of the bubble.50%
--edge-distanceMinimum distance to the edge of the screen0
--initial-position-bottomInitial distance from the bottom side of the screen-
--initial-position-leftInitial distance from the left side of the screen-
--initial-position-rightInitial distance from the right side of the screen-
--initial-position-topInitial distance from the top side of the screen-
--sizeSize of the bubble.48px
--z-indexz-index of the bubble.1

You must either set --initial-position-top or --initial-position-bottom. Also, you must either set --initial-position-left or --initial-position-right.