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 styling custom styles registered via register_block_style in theme.json #49550

Open
mrleemon opened this issue Apr 3, 2023 · 6 comments
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks [Type] Enhancement A suggestion for improvement.

Comments

@mrleemon
Copy link
Contributor

mrleemon commented Apr 3, 2023

Since WP 6.2, one can style core block style variations via the "variations" key in theme.json that can be added under styles.blocks.blockname. Right now, this does not work with custom styles registered via register_block_style.

Can you add this feature, please?

@mrfoxtalbot mrfoxtalbot added [Type] Enhancement A suggestion for improvement. [Feature] Block Variations Block variations, including introducing new variations and variations as a feature labels Apr 3, 2023
@t-hamano
Copy link
Contributor

t-hamano commented Apr 3, 2023

@mrleemon

Thanks for the report.

Currently, #49396 has been submitted to add custom CSS to elements and variations. I believe this PR will solve your problem.

@mrleemon
Copy link
Contributor Author

mrleemon commented Apr 3, 2023

Sorry, I didn't see that PR. Thanks!

@mrleemon mrleemon closed this as completed Apr 3, 2023
@mrleemon mrleemon reopened this Apr 4, 2023
@mrleemon
Copy link
Contributor Author

mrleemon commented Apr 4, 2023

Reopening because the linked PR is about adding support for the "css" property to elements and variations, and my issue is about adding simple styling support (color, margin, padding, typography, etc.) to variations.

@t-hamano
Copy link
Contributor

t-hamano commented Apr 5, 2023

Regarding adding styling support to block variations, I think this was implemented in #46343. The example code can be found in this section, which is part of the WordPress 6.2 Field Guide.

@mrleemon
Copy link
Contributor Author

mrleemon commented Apr 5, 2023

Regarding adding styling support to block variations, I think this was implemented in #46343. The example code can be found in this section, which is part of the WordPress 6.2 Field Guide.

Yes, I know, but it only works for CORE styles (for example, the "rounded" style in the image block), not custom styles registered via register_block_style

@tellthemachines
Copy link
Contributor

Thanks for bringing this up!

it only works for CORE styles (for example, the "rounded" style in the image block), not custom styles registered via register_block_style

Correct, the initial implementation only included core style variations, with the standard design tools. Because existing custom style variations are styled via a classic stylesheet, which depending on specificity might not be overridable with the core design tools such as color, typography etc.., custom styles were excluded then.

I'm thinking that the custom CSS field could be leveraged to solve that problem, and also that it should be possible to add new custom variations from theme.json. I opened an issue in #49602 suggesting some next steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Style Variations Issues or PRs that are related to the style variations for blocks [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

5 participants