Beautiful Step Cards in WordPress Using Only Core Blocks and CSS

Discover how to combine native WordPress blocks, CSS counters and block patterns to create flexible, automatically numbered step cards without developing a custom block.

Flexible and Reusable Design

Not every new design component needs a custom WordPress block.

Sometimes, a combination of existing core blocks, custom block styles and a few lines of CSS is all you need to achieve a beautiful, flexible and reusable design.

In this example, we’ll create automatically numbered step cards using only native WordPress blocks, without writing any JavaScript or introducing additional block dependencies.

The Anatomy of a Step Card

The structure is incredibly simple:

  • A core/group block with a vertical layout.
  • A core/heading block for the step title.
  • A core/paragraph block for the step description.

Each card uses a custom block style that takes care of the automatic numbering. The rest of the design (typography, colors, spacing, backgrounds, borders and rounded corners) can be managed directly through the native block controls.

<!-- wp:group {"className":"is-style-steps-card","style":{"spacing":{"padding":"var:preset|spacing|md","blockGap":"var:preset|spacing|sm"}},"layout":{"type":"flex","orientation":"vertical"}} --><div class="wp-block-group is-style-steps-card">
	<!-- wp:heading {"level":3,"placeholder":"Input card title…"} -->
		<h3 class="wp-block-heading" id="h-"></h3>
	<!-- /wp:heading -->
	<!-- wp:paragraph {"placeholder":"Input card text…"} -->
		<p></p>
	<!-- /wp:paragraph -->
</div>
<!-- /wp:group -->

Putting the Cards Together

To create a section of step cards, we simply place them inside another group block, this time using its native grid layout.

Beautiful Step Cards in WordPress Using Only Core Blocks and CSS
Beautiful Step Cards in WordPress Using Only Core Blocks and CSS

By defining a minimum column width, WordPress takes care of the responsive layout. There is no need to write custom media queries or maintain additional layout styles.

Automatic Numbering with CSS

The magic happens with CSS counters.

The parent group resets the counter, each step card increments it, and a pseudo-element displays the corresponding number.

This means that whenever a card is added, removed or rearranged, its visual number is automatically updated. There is nothing for the content editor to maintain manually.

// Example of steps card styles.
.wp-block-group:has(> .is-style-steps-card) {
	counter-reset: steps-card;
}

.is-style-steps-card {
	counter-increment: steps-card;
}

.is-style-steps-card::before {
	content: counter(steps-card, decimal-leading-zero);
}

That’s the entire automatic numbering mechanism. Everything else is handled by the native block layout and styling capabilities.

// Example of registering a block style.
register_block_style( 'core/group', [
	'name'         => 'steps-card',
	'label'        => 'Steps Card',
	'inline_style' => '...',
] );

Making it Reusable with Block Patterns

To make the component readily available to content editors, we register two block patterns: an individual steps card and a steps section containing three cards.

Editors can start with a complete section, add more cards as needed and customize their appearance using the familiar WordPress editor controls.

// Example of registering a pattern.
register_block_pattern( 'katla/steps-card', [
	'title'         => 'Steps Card',
	'description'   => 'Numbered step card description.',
	'categories'    => [ 'text' ],
	'keywords'      => [ 'card', 'step' ],
	'blockTypes'    => [ 'core/post-content' ],
	'viewportWidth' => 320,
	'content'       => '...',
] );

Keep it Simple

The beauty of this approach is not just in the visual result, but also in how little custom code is required to achieve it.

By building on the capabilities of core blocks, we retain the flexibility of the native editor, benefit from global styles and reduce the amount of custom code we need to maintain.

Visual Demo

Here is an example of how the same block structure could produce different designs using native styling controls, without changing the underlying implementation.

Discover

Explore the possibilities and define what you want to achieve.

Design

Bring your ideas together and shape the visual experience.

Deliver

Refine the details and bring your project to life.

Before building your next custom block, take a moment to explore what can already be achieved with the existing ones. You might be surprised by how much is possible with so little code.

Note: The article featured image was generated using Adobe Firefly AI technology.