Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress

Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress

Say we wanted to add a blue border style called image-blue-border.json.

{
	"$schema": "https://schemas.wp.org/trunk/theme.json",
	"version": 3,
	"title": "Blue Border",
	"slug": "blue-border",
	"blockTypes": [ "core/image" ],
	"styles": {
            "border": {
                    "color": "#00f9ff",
                    "style": "solid",
                    "width": "4px",
                    "radius": "15px"
                },
			"shadow": "var(--wp--preset--shadow--natural)"
		}
}

With theme.json v3, the metadata information for a block’s style is automatically registered within the WP_Block_Styles_Registry:

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

You May Have Missed