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)
insetbooleanfalseWhether 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