Skip to content

Block style for specific block variation #40621

@Humanify-nl

Description

@Humanify-nl

What problem does this address?

After using (custom) block variations in a larger scale project, block styles seem to miss fine-grained control over when they appear in relation to variations.

Use case:

  • I have added a new group variation called 'section'.
  • I want to add a block style for the section but not for the other variations of the group block.

This is possible with a few lines of CSS, but the block editor UI has no way to know and shows all block styles for each group variation.

By giving theme developers more fine-grained control over which block styles appear to the end-user, based on the type of block variation(s), we can extend possibilities in styling, and clean-up valuable UI space.

What is your proposed solution?

I propose some more options when registering block styles (in php).

  register_block_style(
    'core/group',
    [
      'name' => 'custom',
      'label' => 'custom',
      'variations' => [ 'section', 'stack', 'row' ],    // if empty, style will apply to all 
     ]
  );

Metadata

Metadata

Assignees

Labels

[Feature] Block APIAPI that allows to express the block paradigm.[Feature] Block VariationsBlock variations, including introducing new variations and variations as a feature[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Status] In ProgressTracking issues with work in progress[Type] EnhancementA suggestion for improvement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions