How to Create and Use Custom supports in Gutenberg Blocks #71012
-
|
Hello Gutenberg Team 👋, I'm exploring the extensibility of the supports API in Gutenberg and I have a question regarding the creation and usage of custom block supports. From the documentation (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/), I understand how core-supported features like align, color, or typography work. However, I want to go a step further and define my own custom support, for example:
I’d like to:
Could you please guide me on:
A code example or reference to any internal implementation would be incredibly helpful. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
|
I think similar types of questions are more suitable for GitHub discussions. |
Beta Was this translation helpful? Give feedback.
-
|
@theaminuli I think it is possible for you to implement custom supports, but unfortunately I'm not aware of any guides. My understanding is that most of the block supports features are implemented in this folder: So looking at the source code might be the best way of learning. In the past, a lot of these have used regular editor block filters (https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#editor) like:
And probably others too, so there's no reason you can't do the same. I think there might be a slightly newer API now, I don't know it as well or whether it's available for extenders. Maybe others can help answer. |
Beta Was this translation helpful? Give feedback.
-
|
@theaminuli Core blocks and custom blocks are essentially the same. This also applies to block support, and it's possible to add your own support. However, to make your custom block support work properly in the same way as core blocks, you need to take advantage of a wide range of APIs and hooks, which requires deep knowledge of the block architecture, and, as far as I know, no tutorials exist. You'll need to understand the sources and documentation presented in this comment. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much @talldan and @t-hamano for your valuable guidance and explanations 🙌 After exploring the Gutenberg internals, hooks, and support architecture deeply, I successfully completed a full custom block support implementation and documented the entire process as a complete development guide/tutorial. This guide covers the full workflow — from registering custom supports to editor integration, UI controls, front-end rendering, and animation handling. Task: Repository: Special thanks again to both of you for pointing me in the right direction. Your comments helped me understand the Gutenberg architecture much more deeply ❤️ I would really appreciate it if you could review the task and share your feedback. |
Beta Was this translation helpful? Give feedback.
@theaminuli I think it is possible for you to implement custom supports, but unfortunately I'm not aware of any guides.
My understanding is that most of the block supports features are implemented in this folder:
https://github.com/WordPress/gutenberg/tree/trunk/packages/block-editor/src/hooks
So looking at the source code might be the best way of learning.
In the past, a lot of these have used regular editor block filters (https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#editor) like:
blocks.registerBlockTypeto add extra attributes to a block (https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#blocks-registerblocktype)