An API for State-Aware Block Styling Controls

An API defining state-aware styling controls for blocks, with visual presentation varying according to each block’s current state.
An API for State-Aware Block Styling Controls
Editorial Note: This article is an analytical summary inspired by the original piece published on November 18, 2026

WordPress 7.2 exposes a public API for custom block controls to edit styles in the responsive viewport and pseudo states selected in the block editor. Controls can use getSelectedBlockStyleState to identify the active state, then getStyleForState and setStyleForState to read and update the corresponding portion of the block’s style attribute. This lets an update, such as setting a minimum height, apply to the selected state rather than the default style.

Custom inspector controls are normally hidden while a style state is active. The style-state slot makes it possible to show controls in the inspector for viewport and pseudo states, and in the block toolbar for viewport states. Default toolbar slots are not currently hidden for pseudo states, an important distinction when designing custom interfaces.

Viewport integrations can obtain matching CSS media queries through getViewportMediaQueries in @wordpress/global-styles-engine or the PHP helper wp_get_viewport_media_queries. Both use core breakpoints of 480px for mobile and 782px for tablet by default; custom values are supported, while PHP can optionally include a desktop query, disabled by default. These shared helpers allow editor controls and PHP integrations to use consistent breakpoint definitions.

Bring the latest industry updates to life. Download and test the most popular premium tools and extensions driving today’s WordPress innovations – fully accessible and ready for your next project.

Expand your technical knowledge. Browse our latest articles, performance head-to-heads, and essential workflows designed for modern creators.

Free Wordpress Builders