JGuang

Space

Space · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

Space

Keep the same width in the arrangement of elements.

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.

Keep the same width in the arrangement of elements.

When to Use

Useful for multiple elements to maintain the same spacing horizontally or vertically.

Demos

Space

Props

NameDescriptionTypeDefault
alignAlign the items on the cross axis.'start' | 'end' | 'center' | 'baseline'-
blockShould render as block element.booleanfalse
directionThe spacing direction.'vertical' | 'horizontal''horizontal'
justifyAlign the items on the main axis.'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' | 'stretch'-
onClickThe click event of the Space(event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void-
wrapShould line break automatically, work only with horizontal.booleanfalse

CSS Variables

NameDescriptionDefault
--gapThe gap between items.8px
--gap-horizontalThe horizontal gap between items.var(--gap)
--gap-verticalThe vertical gap between items.var(--gap)