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', 'bgColor', 'bgShadeColor']Which color controls to render; linkHoverColor and linkActiveColor are available but not in the default. May be empty when a block only has extras
labelsobject{}Per-key label overrides, e.g. { linkColor: 'Pagination' }
extraarray[]Block-specific colors appended after the included ones, as PanelColorGradientSettings settings: { colorValue, onColorChange, label, gradientValue?, onGradientChange? }

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 GallerytextColor, linkColor, bgColor, bgShadeColorLabelled Navigation Arrows, Pagination, Slide Background, Image Shade (since beta23)
SwipertextColor, linkColorLabelled Navigation Arrows, Pagination
Fluid VideolinkColor, linkHoverColor, bgColor, bgShadeColorLabelled Play Icon, Play Icon (Hover), Image Shade
ScrollspytextColor, linkColor, linkHoverColor, linkActiveColor—
MarqueetextColor, bgColor (+ bgShadeColor when linked)—
ModaltextColor, linkColor, bgColor—
Mapbox Mapnoneextra: Pin → pinColor

Changelog

VersionDescription
2.0.0-alpha4Introduced (e9bc082).
2.0.0-beta14labels prop, first used by Fluid Video (ba36676).
2.0.0-beta27extra prop for block-specific colors, first used by the Mapbox Map pin (fddeba0).