Elevation 是一个实验性的 WordPress 核心组件,用于渲染阴影效果,基于组件系统的阴影系统实现。它通过 props 控制阴影大小、交互状态和样式,适用于增强界面深度感。
import {
__experimentalElevation as Elevation,
__experimentalSurface as Surface,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Surface>
<Text>Code is Poetry</Text>
<Elevation value={ 5 } />
</Surface>
);
}由于是实验性功能,开发者在使用时需注意潜在的破坏性更新风险。
Elevation is a core component that renders shadow, using the component system’s shadow system.
The shadow effect is generated using the value prop.
import {
__experimentalElevation as Elevation,
__experimentalSurface as Surface,
__experimentalText as Text,
} from '@wordpress/components';
function Example() {
return (
<Surface>
<Text>Code is Poetry</Text>
<Elevation value={ 5 } />
</Surface>
);
}
active: numberSize of the shadow value when active (see the value and isInteractive props).
borderRadius: CSSProperties[ 'borderRadius' ]Renders the border-radius of the shadow.
inheritfocus: numberSize of the shadow value when focused (see the value and isInteractiveprops).
hover: numberSize of the shadow value when hovered (see the value and isInteractive props).
isInteractive: booleanDetermines if hover, active, and focus shadow values should be automatically calculated and rendered.
falseoffset: numberDimensional offsets (margin) for the shadow.
0value: numberSize of the shadow, based on the Style system’s elevation system. The value determines the strength of the shadow, which sense of depth.
In the example below, isInteractive is activated to give a better sense of depth.
import { __experimentalElevation as Elevation } from '@wordpress/components';
function Example() {
return (
<div>
<Elevation isInteractive value={ 200 } />
</div>
);
}
0