Elevation Edit

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

Elevation is a core component that renders shadow, using the component system’s shadow system.

Usage Usage

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>
    );
}

Top ↑

Props Props

Top ↑

active: number active: number

Size of the shadow value when active (see the value and isInteractive props).

  • Required: No

Top ↑

borderRadius: CSSProperties[ 'borderRadius' ] borderRadius: CSSProperties[ 'borderRadius' ]

Renders the border-radius of the shadow.

  • Required: No
  • Default: inherit

Top ↑

focus: number focus: number

Size of the shadow value when focused (see the value and isInteractive props).

  • Required: No

Top ↑

hover: number hover: number

Size of the shadow value when hovered (see the value and isInteractive props).

  • Required: No

Top ↑

isInteractive: boolean isInteractive: boolean

Determines if hover, active, and focus shadow values should be automatically calculated and rendered.

  • Required: No
  • Default: false

Top ↑

offset: number offset: number

Dimensional offsets (margin) for the shadow.

  • Required: No
  • Default: 0

Top ↑

value value

Type: number

Size 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>
    );
}