Skip to content

Custom states for blocks - iteration for WP 7.2 #79283

Description

@MaggieCabrera

Overall Goal

Let users style the active item in interactive blocks—for example, the current page in Navigation or the selected tab in Tabs—without writing custom CSS or editing theme.json by hand.

This builds on the existing style-state work:

  • Pseudo states, such as :hover and :focus.
  • Responsive states, such as tablet and mobile.
  • Custom states, such as the current menu item.

Prior art: #57719.

Tasks

  • Navigation Link: Add color, border, and spacing supports
    Make state styling useful beyond typography.

  • Global Styles: Add pseudo-state controls for Navigation Link
    Expose hover, focus, focus-visible, and active.

  • Block Style States: Add a custom-state axis to editor controls
    Support custom states alongside the existing viewport and pseudo-state axes.

  • #78769Navigation Link: Add -current state to editor controls
    Support -current in Global Styles and individual Navigation Link blocks.

  • Tabs: Add -current state to editor controls
    Style the active tab using [aria-selected="true"].

Nice to Have

  • Make custom states available to third-party blocks
    Define a public registration API across PHP and JavaScript, including labels, selectors, editor controls, and theme.json handling. Document and validate selectors.states in the block.json schema as part of this work.

  • #76367Navigation Submenu: Support independent current-item styling
    Allow links inside submenu dropdowns to be styled separately.

Metadata

Metadata

Assignees

Labels

Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Feature] Style StatesRelated to block style states (currently viewport and pseudo-states)[Type] IterationScoped iteration of an effort from a tracking issue or overview issue ideally for a major release.

Type

No type

Projects

Status
📋 Iteration/Tracking Issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions