I think the most simple approach (if you’re able to add some JS) is to use custom classes for your buttons and blocks that can be settled through advanced settings in block editor. Then a really basic JS snippet can do the trick.
Here’s an example in vanilla JS with an IFFE that takes care of waiting for DOM to be loaded : https://codepen.io/liqueurdetoile/pen/dyjEYEP
Obviously class names have to be chosen wisely to avoid any trouble.
EDIT – You can also use any accordion block for Gutenberg to achieve a similar result. There’s plenty available as plugins.
Related Posts:
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- Enqueue Scripts / Styles when shortcode is present
- How to save a shortcode in a Gutenberg custom block?
- Alternate text if shortcode returns no data
- gutenberg widget outputting paragraph marks
- is_admin() returns false in save_post hook with Gutenberg editor
- Wrap shortcode inside custom block
- Instagram URL is converted into oEmbed
- Gutenberg Block with Select from JSON-File
- add action only if gallery shortcode attribute is equal to?
- How To Conditionally Include A Short Code Depending On The HTTP_REFERER [closed]
- Adding a template part as part of a shortcode
- Gutenberg Shortcode Fail
- If else with shortcodes
- Gutenberg Shortcode Chooser Block
- Gutenberg Shortcode will turn html to html entity
- Gutenberg running code only available in front end within shortcode
- Shortcode, vs blocks, vs templates – what would you do for choosing or creating custom post data in editor?
- How to use code in an editor block?
- Pass boolean value in shortcode
- Implement If-ElseIf-Else-EndIf with short codes
- using html as shortcode attribute
- shortcode outputs first before the page content [duplicate]
- Are php template shortcodes ok?
- Extract attribute values from every shortcode in post
- How to make shortcode to hide selection of text from post or page?
- how to get shortcodes to work inside the text of custom fields
- Shortcode attribute value with dash (hyphen)
- Shortcode content does not show in feed discription/excerpt
- How do I create shortcodes for my wordpress themes?
- Execute shortcode only in another shortcode
- Adding shortcode inside Visual Composer raw HTML [closed]
- Shortcode not working inside html input
- Multiple loops on page only show taxonomy name of first loop
- Add attribute to existing Shortcode
- How to link to a alternative page in CSS
- How to handle a shortcode function directly?
- manipulate a plugins shortcode
- Shortcodes output in the wrong order
- How to link to a page that has a shortcode?
- Adding short codes from a page’s content on header and hiding the same from page’s content
- Should I cache default WordPress gallery shortcode output?
- Audio and video shortcodes not working properly
- How to load shortcode sooner
- Tinymce list of shortcodes button
- Add page title as a javacript variable to specific posts
- How to create a shortcode for custom page template
- Pass javascript array to shortcode
- Shortcode: display list of created shortcode in popup
- Shortcode return $content vs do_shortcode($content)
- Duplicating Table of Contents for Paginated Post
- Shortcode not working with WordPress updated
- WordPress Shortcode callback function with a plugin
- Conditional Shortcode image display
- Problem with multiple shortcode in page template
- Saving post content to database with do_shortcode?
- Get page content and execute shortcodes on a page
- Shortcode Function not working
- Using shortcode to display array in array
- Custom recent-posts shortcode’s thumbnail image not in line with rest of code
- How can i share codes on my blog?
- Why does WP display the actual shortcode not the string that’s meant to replace it?
- Getting error on submitting form using Ajax with shortcode
- Using the title of the post in a shortcode
- Hijack WordPress Shortcode attribute
- How to find specific shortcodes in a post or in a widget and pass them to a variable?
- AJAX and do_shortcode
- FontAwesome Shortcode isn’t working properly
- Change variable value for different shortcode attributes?
- Call Shortcode on wp_footer
- How to copy [gallery] shortcode between posts using polylang [closed]
- Shortcode not displaying video as expected
- Adding shortcode of “Random Content” Plugin in the post after the title
- How to Display Shortcode’s Content after Short Product Description?
- From a shortcode I want to pass a value to display a different page
- Jetpack gallery shortcode with slideshow
- Shortcode atts for WP Query args
- return an array with a shortcode
- wp.blocks.registerBlockType not showing what I want on the frontend
- PHP not outputting the onclick in anchor tag
- Create Button for Shortcode in Text Editor
- Send Mail with link to current_user
- shortcode atts not working
- do_shortcode for is_page(slug)
- Custom Login in Shortcode got error
- Nested WordPress Shortcodes of Different Types
- Access Shortcode in ajax code?
- WordPress Not rendering short code properly?
- Initialize add_action() for every copy of a specific shortcode
- WP_Editor Shortcode Issue
- Shortcodes that are created based on user input information
- Remove some tags from shortcodes output? Trying to fix autop
- do_shortcode & render custom field won’t work
- shortcodes inside shortcode to sum values
- is_mobile as shortcode
- How to attach sidebar to shortcode’s output?
- Is it possible to change a shortcode parameter based on a media query?
- Shortcode append to the the_content()
- Wrapping a function in html tag and return?
- 3 shortcodes 2 won’t render [closed]