Sage block context

I have been trying to figure out how to get parent data into child block.
I have a section block that holds background color and spaces. The child block placed in that section block should then use colors that is set in css variables. If section is white background. I want to pass background-color to child block to be able to set correct text color and button color and so on.
Any help? I read about:

And
https://www.advancedcustomfields.com/resources/whats-new-with-acf-blocks-in-acf-6/
I use ACF builder and tailwind for block building.

The linked ACF doc has fairly clear instructions on how to use ACF to pass and consume context. What have you tried so far? How is it failing, ie are you seeing errors or what? Can you provide your code?

1 Like

Since I’m using GitHub - StoutLogic/acf-builder: An Advanced Custom Field Configuration Builder
And documentation is a bit thin for acf-builder. There is no example how to add context from parent to child block.
Since all reference is to block.json for a block. With acf-builder it’s not clear how to pass context like an added color picker value from parent to child.
I want to set background color on a section block. That background color should then affect the background colors of buttons used in a richtext field so it will always show and work. So a button should have primary color for specific background colors.

block.json is a way of registering block settings, but you should be able to register most of the same settings in other ways, i.e. with register_block_type(). It’s been a real long time since I used acf-builder, and I don’t think I ever used it to make ACF Blocks, but however you register blocks should have a way for your to pass config arguments, and I would think you’d be able to pass the context key to those arguments in the way it’s described as working in the docs you linked.