admin管理员组文章数量:1296463
I can't find any useful information in Gutenberg Handbook. Here is information about adding gradients, but it only works for some core blocks.
I use ColorPalette
to create colors (or to use the color picker) but still don't know how to use gradients. I also found PanelColorSettings
but still without success.
I am looking for instructions/documentation on how to add this component:
I can't find any useful information in Gutenberg Handbook. Here is information about adding gradients, but it only works for some core blocks.
I use ColorPalette
to create colors (or to use the color picker) but still don't know how to use gradients. I also found PanelColorSettings
but still without success.
I am looking for instructions/documentation on how to add this component:
Share Improve this question asked Nov 3, 2020 at 17:51 kanlukaszkanlukasz 5448 silver badges24 bronze badges2 Answers
Reset to default 2The documentation for that control does not exist at this time. Instructions have not been written yet. It is an experimental component.
You need to use an appropriate control in your blocks Edit component.
Note that these are very new components, their design will likely change, it should be considered experimental and unstable.
There is the GradientPicker
component, https://github/WordPress/gutenberg/blob/master/packages/components/src/gradient-picker/index.js
And ColorGradientControl
https://github/WordPress/gutenberg/blob/26e4d59e6fd3ed78d0213d60abca31c6dc1fa9cb/packages/block-editor/src/components/colors-gradients/control.js
<ColorGradientControl
{ ...otherProps }
onColorChange={ onChange }
colorValue={ value }
gradients={ [] }
disableCustomGradients={ true }
/>
I found support for custom block, it really helps.
supports: {
color: {
// This also enables text and background UI controls.
gradients: true; // Enable gradients UI control.
}
}
https://developer.wordpress/block-editor/reference-guides/block-api/block-supports/
本文标签: plugin developmentHow to add a gradient component to a custom block
版权声明:本文标题:plugin development - How to add a gradient component to a custom block 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741611963a2388311.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论