Passing the name of selected color from the custom component to `render_callback`

If you just want to get the selected color name, then you can use the getColorObjectByColorValue() function in the @wordpress/block-editor package, which is wp.blockEditor.getColorObjectByColorValue in the browser. The function accepts two parameters: a color list (each is an object with color and name as the properties), and the color (a HEX code, e.g. #17a2b8) that … Read more

Conditional save return on Gutenberg Block

You should define your btntype attribute as type boolean and set its default to false (maybe better rename it to download then ;). And change it to true when the user selects the download option. If you want to conditionally add the download attribute in your save functions’ JSX use this syntax: <a href={ btnurl … Read more

UnitControl – Block has encountered an error

The problem in your code is that UnitControl is not actually defined anywhere: If you look at the example in the documentation, the UnitControl is defined as follows: import { __experimentalUnitControl as UnitControl } from ‘@wordpress/components’; I.e. It uses the __experimentalUnitControl component in wp.components and not wp.blockEditor, and secondly, it imports the component as UnitControl. … Read more