JavaScript for WordPress Forums Gutenberg Development Add class to container div? Reply To: Add class to container div?

#104493
Zac Gordon
Keymaster

Hey Mike!

This should be possible with the blocks.getSaveContent.extraProps filter. It let’s you get the props, which includes the attributes, as well as return a new props, which includes the className, so you should be able to update classname using attributes, if that is what you are after.

Not exact solutions, but examples that should get you there:

https://wordpress.org/gutenberg/handbook/designers-developers/developers/filters/block-filters/#blocks-getsavecontent-extraprops
https://github.com/zgordon/advanced-gutenberg-course/blob/master/filters/getSaveContentExtraProps.js

Let me know if you need a hand tweaking this to your need or if I’m missing something!