Surface 是 WordPress 核心组件库中的一个实验性组件,用于渲染主要背景颜色,支持多种变体和边框控制。该组件目前处于早期阶段,可能发生重大变更。
import {
__experimentalSurface as Surface,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Surface>
<Text>Code is Poetry</Text>
</Surface>
);
}Surface is a core component that renders a primary background color.
In the example below, notice how the Surface renders in white (or dark gray if in dark mode).
import {
__experimentalSurface as Surface,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Surface>
<Text>Code is Poetry</Text>
</Surface>
);
}
backgroundSize: number12Determines the grid size for “dotted” and “grid” variants.
borderBottom: booleanfalseRenders a bottom border.
borderLeft: booleanfalseRenders a left border.
borderRight: booleanfalseRenders a right border.
borderTop: booleanfalseRenders a top border.
variant: stringfalseprimary, secondary, tertiary, dotted, gridModifies the background color of Surface.
primary: Used for almost all cases.secondary: Used as a secondary background for inner Surface components.tertiary: Used as the app/site wide background. Visible in dark mode only. Use case is rare.grid: Used to show a grid.dotted: Used to show a dots grid.