W3cubDocs

/WordPress

register_block_style( string|string[] $block_name, array $style_properties ): bool

Registers a new block style.

Parameters

$block_namestring|string[]required
Block type name including namespace or array of namespaced block type names.
$style_propertiesarrayrequired
Array containing the properties of the style name, label, style_handle (name of the stylesheet to be enqueued), inline_style (string containing the CSS to be added), style_data (theme.json-like array to generate CSS from).
See WP_Block_Styles_Registry::register().

Return

bool True if the block style was registered with success and false otherwise.

Source

function register_block_style( $block_name, $style_properties ) {
	return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties );
}

Changelog

Version Description
6.6.0 Added support for registering styles for multiple block types.
5.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/register_block_style