Open
Description
Allow registering new block variations and style them without leaving the editor.
Idea:
A theme can register new buttons variations such as pill
, rounded
, circular
and style them to be used in the editor.
Pill | Rounded | Circular |
---|---|---|
![]() |
![]() |
![]() |
Currently it is not possible to create such variations from the editor.
A block variations can be registered with javascript
const { registerBlockStyle } = wp.blocks;
registerBlockStyle('core/button', {
name: 'pill',
label: _x('Pill', 'block style', 'theme-name'),
});
this creates a new button variations and adds a css class wp-block-button is-style-pill
which can be styled from the editor global styles.
Proposal:
Create block theme can have a UI to create a new block variation, (which adds the required javascript code and enqueues is safely).