Spacer


目录

This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.

Spacer is a primitive layout component that providers inner (padding) or outer (margin) space in-between components. It can also be used to adaptively provide space within an HStack or VStack.

Usage

Spacer comes with a bunch of shorthand props to adjust margin and padding. The values of these props work as a multiplier to the library’s grid system (base of 4px).

import {
    __experimentalSpacer as Spacer,
    __experimentalHeading as Heading,
    __experimentalView as View,
} from '@wordpress/components';

function Example() {
    return (
        <View>
            <Spacer>
                <Heading>WordPress.org</Heading>
            </Spacer>
            <Text>Code is Poetry</Text>
        </View>
    );
}

Props

children: ReactNode

The children elements.

margin: number

Adjusts all margins.

marginBottom: number

Adjusts bottom margin, potentially overriding the value from the more generic margin and marginY props.

marginLeft: number

Adjusts left margin, potentially overriding the value from the more generic margin and marginX props.

marginRight: number

Adjusts right margin, potentially overriding the value from the more generic margin and marginX props.

marginTop: number

Adjusts top margin, potentially overriding the value from the more generic margin and marginY props.

marginX: number

Adjusts left and right margins, potentially overriding the value from the more generic margin prop.

marginY: number

Adjusts top and bottom margins, potentially overriding the value from the more generic margin prop.

padding: number

Adjusts all padding.

paddingBottom: number

Adjusts bottom padding, potentially overriding the value from the more generic padding and paddingY props.

paddingLeft: number

Adjusts left padding, potentially overriding the value from the more generic padding and paddingX props.

paddingRight: number

Adjusts right padding, potentially overriding the value from the more generic padding and paddingX props.

paddingTop: number

Adjusts top padding, potentially overriding the value from the more generic padding and paddingY props.

paddingX: number

Adjusts left and right padding, potentially overriding the value from the more generic padding prop.

paddingY: number

Adjusts top and bottom padding, potentially overriding the value from the more generic padding prop.


版本号 #2
由 壳壳虫 创建于 2026-10-31 18:15:46 UTC
由 壳壳虫 更新于 2026-10-31 18:15:48 UTC