Skip to content

Latest commit

 

History

History

block-supports-6aa4dd

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Block Supports Implementation

This example demonstrates how to leverage WordPress block supports to enhance your blocks with standard WordPress features. Block supports provide a declarative way to add common functionality like alignment controls, color settings, and typography options without writing custom code.

Key concepts covered:

  • Block supports configuration in block.json
  • Integration with WordPress core features
  • Automatic UI controls generation
  • Standard block behaviors implementation
  • Property handling in Edit and Save components
Example Description Tags Download .zip Live Demo
Block Supports Showcases how to use WordPress block supports to add standard features like alignment, colors, and typography to blocks. supports featured 📦

Understanding the Example Code

Block Supports Configuration

  1. Core Support Features

    • align: Controls block alignment options
    • color: Enables background and text color settings
    • typography: Provides font size and other text controls
    • spacing: Allows margin and padding adjustments
  2. Implementation Details

    • Supports defined in block.json metadata
    • Properties automatically added via useBlockProps
    • Generated UI controls in block sidebar
    • Consistent behavior in editor and frontend

Technical Implementation

  1. Block Registration

    {
    	"supports": {
    		"align": true,
    		"color": {
    			"background": true,
    			"text": true
    		},
    		"typography": {
    			"fontSize": true
    		}
    	}
    }
  2. Component Integration

    • useBlockProps handles support properties
    • Automatic class generation
    • Proper attribute management
    • Consistent rendering between editor and frontend

Related Resources


Note Check the Start Guide for local development with the examples