MethodColorControls

 
 
 
 

Overview

Color and gradient pickers for text, links, backgrounds, and shade overlays, using WordPress’s native PanelColorGradientSettings.

  • File: lib/blocks/components/MethodColorControls.js
  • Panel label: “Color Settings” (customizable via title prop)

Props

PropTypeDefaultDescription
attributesobject(required)The block’s full attributes object
setAttributesfunction(required)WordPress setAttributes function
titlestring'Color Settings'Panel heading text
includestring[]['textColor', 'linkColor', 'linkHoverColor', 'linkActiveColor', 'bgColor', 'bgShadeColor']Which color controls to render

Controls

Unlike other Method components, MethodColorControls does not use responsiveSettings. This is due to limitations with the PanelColorGradientSettings component and may change in future releases.

Color values are stored as top‑level block attributes and apply globally (not per‑breakpoint).

Control KeyAttribute(s)Supports GradientLabel
textColortextColorNo“Text”
linkColorlinkColorNo“Link”
linkHoverColorlinkHoverColorNo“Link (Hover)”
linkActiveColorlinkActiveColorNo“Link (Active)”
bgColorbgColor, bgGradientYes“Background”
bgShadeColorbgShadeColor, bgShadeGradientYes“Background Shade”

Gradient Support

The bgColor and bgShadeColor controls expose both solid color and gradient pickers. When a gradient is selected, it’s stored in the companion *Gradient attribute (e.g., bgGradient), and MethodStyleTag prioritizes the gradient over the solid color when generating CSS.

Alpha Support

All color pickers have enableAlpha={true}, allowing transparency values.


Rendering

The component uses PanelColorGradientSettings from @wordpress/block-editor with __experimentalIsRenderedInSidebar={true} for proper Inspector integration.


Usage by Blocks

BlockIncluded ControlsNotes
SectiontextColor, linkColor, bgColor, bgShadeColorFull set
ContainertextColor, bgColor, bgShadeColor + conditional linkColorlinkColor hidden when block is itself a link
Advanced Grid ColumntextColor, linkColor
BreadcrumbtextColor, linkColor
ButtontextColor, bgColor
Fitted ImagebgColor, bgShadeColor
Social NavDynamic based on style variantlinkColor always; bgColor for enclosed; textColor for with‑text
Swiper GallerybgColor, bgShadeColor