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


Howdy folks,

I’m also working on something that uses filters to adjust classes, but I’m using blocks.getBlockDefaultClassName. Any clues on the cleanest way to get attributes (attributes.bgType) from the block passed through to this function? I tried a few different ways but haven’t been able to tap into them yet since it runs outside of the block’s render where attributes are defined. Thanks in advance for any tips!


function abCustomClassName( className, name ) {
	if ( 'atomic-blocks/ab-columns' === name ) {
		return classnames(
			'ab-has-bg-' + attributes.bgType
	return className;