Revisiting Gutenberg blocks part 2: More ways to customize blocks
The previous post ([Revisiting Gutenberg blocks part 1: Building and Styling the blocks](https://publishing-project.rivendellweb.net/revisiting-gutenberg-blocks-part-1-building-and-styling-the-blocks/)) discussed how to build a block and reviewed both old and new techniques for creating Gutenberg blocks. This post will revisit related areas of block development in more detail. ## Block variations Some times it may be easier to create additional styles for an existing core element than create your own. Gutenberg calls this block variations. Authors can also choose whether they want to incorporate core blocks. It is highly likely that you will need to customize the block styles to match the core blocks with the theme but that will always be easier than creating matching blocks from scratch. Gutenberg calls this [block style variations](https://developer.wordpress.org/block-editor/developers/filters/block-filters/#block-style-variations). The following core blocks are available: - Text - Paragraph - List - Heading - Subhead - Table - Button - Classic (HTML) Block - Text Columns - Media - Image - Cover Image - Image Gallery - Audio - Video - Embeds - Shortcodes - Quotes - Quote - Pullquote - Verse - Code - Code - Preformatted - Custom HTML - Shortcodes - Embeds - Layout - Columns - Text Columns - Separator - Read More See [Gutenberg Blocks](https://gogutenberg.com/blocks/) for more information about core blocks and how to use them. The variations plugin doesn't require a build step, it's a combination of PHP and CSS. The PHP script enqueues the script that defines the variations and the stylesheet that holds the actual CSS for the variations we create. ```php __( 'Video with text description', 'rivendellweb-blocks' ), 'description' => __( 'Youtube video with text to the right.', 'Block pattern description', 'rivendellweb-blocks' ), 'content' => $template_string, 'categories' => array( 'Rivendellweb Patterns' ), ); } } add_action( 'init', 'rivendellweb_register_block_patterns' ); ``` The function can register multiple patterns at the same time. ### 4\. (Optional) Create custom categories for the pattern Rather than put our custom patterns in the default categories, we can create one or more custom categories for our patterns that will share space with the default ones (although not in alphabetical order). The callback function, `rivendellwebr_register_pattern_categories()` allows us to register one or more pattern categories using [register\_block\_pattern\_category()](https://developer.wordpress.org/reference/functions/register_block_pattern_category/) ```php __( 'Journal', 'Block pattern category', 'rivendellweb-blocks' ) ) ); } } add_action( 'init', 'rivendellweb_register_pattern_categories' ); ``` So now we have as many custom patterns in as many custom pattern categories as our project needs. ### Additional resources Rich Tabor's [How to Build Block Patterns for the WordPress Block Editor](https://richtabor.com/build-block-patterns/) provides an in-depth look at building patterns.