Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating/registering block variations from the UI #698

Open
madhusudhand opened this issue Aug 9, 2024 · 0 comments
Open

Allow creating/registering block variations from the UI #698

madhusudhand opened this issue Aug 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@madhusudhand
Copy link
Member

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
image image image

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).

@mikachan mikachan added the enhancement New feature or request label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants