Compatability of gutenberg block in older WordPress version

I’m developing a Gutenberg block and have a doubt on using the latest gutenberg APIs.

My block contains a button. Referring the docs, there is a property called “variant” using which the button style can be changed.

I was testing this in WordPress 5.7.2 (the latest WP released as of now) and this property does not work.

https://developer.wordpress.org/block-editor/reference-guides/components/button/#variant
https://github.com/WordPress/gutenberg/pull/31713

enter image description here

Docs no where mentions that this applies to WP 5.8+. Being new to this ecosystem makes be doubt that if I’m doing things right.

So if I use this API, then users who use the plugin on older WP version will not get this working right ?

What are the best practises on this ? Shouldn’t the doc be updated after WP 5.8 is released ?

I do not want to change the minimum required WP version for my plugin, since this block is not the main feature in my case. Please advise.

1 Answer
1

I’m not sure that component is meant to be used on the front end, it looks as though that’s mainly there for creating buttons in the editor itself.

For block “variations”, there are block styles, which might be what you’re looking for: https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/. Block styles are the native way of having multiple ways of presenting a block, for example the core button block has a default solid style and an outline style.

Leave a Comment