MethodShadowControl

 
 
 
 

Overview

Multi‑layer box shadow editor with per‑layer controls for offset, blur, spread, color, and inset.

  • File: lib/blocks/components/MethodShadowControl.jsx
  • Panel label: “Shadow”
  • Base breakpoint only — this component returns null for non‑base breakpoints.

Props

PropTypeDefaultDescription
breakpointstring(required)Must be base; returns null otherwise
attributesobject(required)The block’s full attributes object
setAttributesfunction(required)WordPress setAttributes function

Controls

Shadow Layers

  • Settings key: responsiveSettings.base.shadows
  • Value type: array of shadow layer objects

Each shadow layer has the following properties:

PropertyTypeDefaultRangeDescription
xnumber0-125 to 125Horizontal offset in pixels
ynumber4-125 to 125Vertical offset in pixels
blurnumber80 to 200Blur radius in pixels
spreadnumber0-64 to 64Spread radius in pixels
colorstring'rgba(0,0,0,0.15)'—Shadow color (supports alpha via ColorPicker)
insetbooleanfalse—Whether the shadow is inset

Each property is controlled by its own RangeControl (with labeled marks) or a ColorPicker. The inset toggle is a CheckboxControl.


Adding/Removing Layers

  • Add Shadow Layer: A “Add Shadow Layer” button appends a new layer with default values.
  • Remove: Each layer (when more than one exists) shows a “Remove” button.
  • Last layer removal: When the last layer is removed, the shadows key is deleted entirely from the breakpoint settings.
  • Multiple layers: Shadow layers are rendered with visual dividers between them and “Shadow {n}” labels.

CSS Output

MethodStyleTag processes the shadows array into a comma‑separated box-shadow CSS value:

CSS
box-shadow: 0px 4px 8px 0px rgba(0,0,0,0.15), inset 2px 2px 4px 0px rgba(0,0,0,0.1);

ToolsPanel Behavior

  • Box Shadow onSelect: Initializes shadows to a single‑element array with default values
  • Box Shadow onDeselect: Removes the shadows key entirely
  • resetAll: Same as onDeselect

Usage by Blocks

BlockNotes
SectionBase breakpoint only
ContainerBase breakpoint only
ButtonBase breakpoint only
Fitted ImageBase breakpoint only
Fluid VideoBase breakpoint only
Mapbox MapBase breakpoint only

Changelog

VersionDescription
2.0.0-alpha4Introduced (eae3263).
2.0.0-beta21Reworked so that stacks of several shadows stay manageable in the inspector (collapsible layers); storage in responsiveSettings.base.shadows and the generated box-shadow are unchanged (141450d, f5a5d28, 75910d2).