Grid 是 WordPress 组件库中的一个实验性布局组件,用于以网格配置排列内容。它提供灵活的 CSS Grid 属性控制,但处于早期开发阶段,可能发生重大变更。
import {
__experimentalGrid as Grid,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Grid columns={ 3 }>
<Text>Code</Text>
<Text>is</Text>
<Text>Poetry</Text>
</Grid>
);
}Grid is a primitive layout component that can arrange content in a grid configuration.
import {
__experimentalGrid as Grid,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Grid columns={ 3 }>
<Text>Code</Text>
<Text>is</Text>
<Text>Poetry</Text>
</Grid>
);
}
align: CSS['alignItems']Adjusts the block alignment of children.
alignment: GridAlignmentAdjusts the horizontal and vertical alignment of children.
columnGap: CSSProperties['gridColumnGap']Adjusts the grid-column-gap.
columns: numberAdjusts the number of columns of the Grid.
2gap: numberGap between each child.
3isInline: booleanChanges the CSS display from grid to inline-grid.
justify: CSS['justifyContent']Adjusts the inline alignment of children.
rowGap: CSSProperties['gridRowGap']Adjusts the grid-row-gap.
rows: numberAdjusts the number of rows of the Grid.
templateColumns: CSS['gridTemplateColumns']Adjusts the CSS grid template-columns.
templateRows: CSS['gridTemplateRows']Adjusts the CSS grid template-rows.