MethodTypographyControls

 
 
 
 

Overview

Font size (with theme presets), line height, and text alignment controls, wrapped in a ToolsPanel.

  • File: lib/blocks/components/MethodTypographyControls.js
  • Panel label: “Typography”

Props

PropTypeDefaultDescription
breakpointstring(required)The responsive breakpoint: base, mobile, tablet, or wide
attributesobject(required)The block’s full attributes object
setAttributesfunction(required)WordPress setAttributes function

This component does not accept an include prop — all three controls are always rendered.


Controls

Font Size

  • UI: FontSizePicker — WordPress’s native font size picker with optional preset sizes.
  • Settings key: responsiveSettings.{breakpoint}.fontSize
  • Value type: string (CSS value, e.g., "1.25rem", "18px")

Font size presets are pulled from window.methodGlobalData.fontSizePresets, which is localized from the theme’s method_get_font_size_presets() function. This gives editors a curated set of sizes while still allowing custom values.


Line Height

  • UI: RangeControl with decimal step increments.
  • Settings key: responsiveSettings.{breakpoint}.lineHeight
  • Value type: number
ParameterValue
Min0.75
Max2
Step0.05
Initial position1.55
Marks1, 1.5, 2

Text Alignment

  • UI: SelectControl dropdown.
  • Settings key: responsiveSettings.{breakpoint}.textAlign
OptionValue
Inherit"" (empty string)
Leftstart
Centercenter
Rightend
Justifyjustify

ToolsPanel Behavior

  • Font Size: onSelect sets fontSize to empty string; onDeselect removes the key
  • Line Height: onSelect sets lineHeight to 1.55; onDeselect removes the key
  • Text Alignment: hasValue checks for both undefined and empty string; onDeselect removes the key
  • resetAll: Removes fontSize, lineHeight, and textAlign from the breakpoint

Usage by Blocks

BlockBreakpoints
Sectionbase only
Containerbase, mobile, tablet, wide
Advanced Grid (grid + row + col)base, mobile, tablet, wide
Buttonbase, mobile, tablet, wide
Core Extensions (paragraph, heading, list)mobile, tablet, wide only