Block Supports Subsystem

The block supports subsystem provides server-side rendering of block-level design features (colors, typography, spacing, etc.) by registering attributes, generating CSS classes/inline styles, and injecting them into block markup.

Source: wp-includes/block-supports/
Since: 5.6.0 (earliest files)


Architecture

Each block support file follows a common pattern:

  1. Register — A register_attribute callback adds block attributes (e.g. style, backgroundColor) to block types that declare support.
  2. Apply — An apply callback reads block attributes and returns CSS classes/inline styles to merge into the block wrapper.
  3. Render — Some supports use render_block or render_block_data filters to inject styles via WP_HTML_Tag_Processor for non-server-rendered blocks.

All supports register themselves via WP_Block_Supports::get_instance()->register().


Files Overview

FileSupport Key(s)SinceRegistration Method
align.phpalign5.6.0register_attribute + apply
aria-label.phpariaLabel6.8.0register_attribute + apply
background.phpbackground, background.backgroundImage6.4.0register_attribute + render_block filter
block-style-variations.phpblock-style-variation6.6.0render_block_data + render_block filters
block-visibility.phpvisibility6.9.0render_block filter
border.php__experimentalBorder5.8.0register_attribute + apply
colors.phpcolor (text, background, gradients, link, button, heading)5.6.0register_attribute + apply
custom-classname.phpcustomClassName5.6.0register_attribute + apply
dimensions.phpdimensions (minHeight, aspectRatio)5.9.0register_attribute + apply + render_block filter
duotone.phpduotone (via WP_Duotone class)5.8.0register_attribute + multiple filters/actions
elements.phpElement styles (button, link, heading colors)5.8.0render_block_data + render_block filters
generated-classname.phpclassName5.6.0apply only
layout.phplayout, __experimentalLayout5.8.0register_attribute + render_block filter
position.phpposition6.2.0register_attribute + render_block filter
settings.php__experimentalSettings6.2.0render_block + pre_render_block filters
shadow.phpshadow6.3.0register_attribute + apply
spacing.phpspacing (padding, margin)5.8.0register_attribute + apply
typography.phptypography (fontSize, fontFamily, lineHeight, textAlign, etc.)5.6.0register_attribute + apply + render_block filter
utils.phpUtility functions6.0.0N/A

Common Patterns

Serialization Skipping

Blocks can opt out of server-side serialization of specific support features via __experimentalSkipSerialization in their supports definition. The utility function wp_should_skip_block_supports_serialization() (in utils.php) checks this flag. Nearly every apply/render function checks it before generating output.

Style Engine Integration

Most supports delegate CSS generation to wp_style_engine_get_styles(), which returns both classnames and css (inline styles). Supports that generate layout or position CSS use wp_style_engine_get_stylesheet_from_css_rules() to store styles in the style engine for later enqueuing.

WP_HTML_Tag_Processor

Supports that use render_block filters inject classes and inline styles into block markup using WP_HTML_Tag_Processor, targeting the first tag (presumed wrapper element).


Hook Summary

Filters

HookFileDescription
block_default_classnamegenerated-classname.phpFilters the default block class name
render_blockbackground, block-style-variations, block-visibility, dimensions, elements, layout, position, settings, typographyModifies rendered block content
render_block_datablock-style-variations, elements, layoutModifies parsed block data before rendering
pre_render_blocksettingsAdds block-level preset styles before rendering
render_block_core/grouplayoutRestores inner container for classic themes
render_block_core/imageduotone, layoutImage-specific rendering
block_editor_settings_allduotoneAdds editor settings
block_type_metadata_settingsduotoneMigrates experimental duotone flag
wp_theme_json_get_style_nodesblock-style-variationsTemporarily removed/re-added during variation processing

Actions

HookFileDescription
wp_enqueue_scriptsblock-style-variations, duotoneEnqueues block style variation and duotone styles
wp_footerduotoneOutputs SVG filters and block styles