CardFooter 是 WordPress 组件库中的一个 React 组件,用于在 Card 内渲染可选页脚。它基于 Flex 布局组件构建,支持灵活的子项对齐。
import { Card, CardFooter } from '@wordpress/components';
const Example = () => (
<Card>
<CardBody>...</CardBody>
<CardFooter>...</CardFooter>
</Card>
);size 属性可接受单个尺寸令牌(如 'medium')或对象形式,以分别设置不同方向的内边距。建议参考 Flex 组件文档以了解更多布局细节。
CardFooter renders an optional footer within a Card.
import { Card, CardFooter } from '@wordpress/components';
const Example = () => (
<Card>
<CardBody>...</CardBody>
<CardFooter>...</CardFooter>
</Card>
);
Underneath, CardFooter uses the Flex layout component. This improves the alignment of child items within the component.
import {
Button,
Card,
CardFooter,
FlexItem,
FlexBlock,
} from '@wordpress/components';
const Example = () => (
<Card>
<CardBody>...</CardBody>
<CardFooter>
<FlexBlock>Content</FlexBlock>
<FlexItem>
<Button>Action</Button>
</FlexItem>
</CardFooter>
</Card>
);
Check out the documentation on Flex for more details on layout composition.
Note: This component is connected to Card‘s Context. The value of the size and isBorderless props is derived from the Card parent component (if there is one). Setting these props directly on this component will override any derived values.
isBorderless: booleanRenders without a border.
falseisShady: booleanRenders with a light gray background color.
falsejustify: CSSProperties[ 'justifyContent' ]See the documentation for the justify prop for the Flex component
size: string | objectDetermines the amount of padding within the component. Can be specified either as a single size token or as an object.
mediumnone, xSmall, small, medium, large{
blockStart: 'none' | 'xSmall' | 'small' | 'medium' | 'large';
blockEnd: 'none' | 'xSmall' | 'small' | 'medium' | 'large';
inlineStart: 'none' | 'xSmall' | 'small' | 'medium' | 'large';
inlineEnd: 'none' | 'xSmall' | 'small' | 'medium' | 'large';
}