Heyy is it possible to add an accordion block? I would like to do an FAQ where you have the questions and you can expand to see the answer. Would be very awesome!
Welcome to the community, and thanks for the suggestion!
Yes, this is already possible in DatoCMS using Modular Content blocks. Since DatoCMS is a headless CMS, the accordion open/close behavior is usually handled by your frontend, while DatoCMS stores the editable content structure.
A simple setup would be to create a block model called “FAQ item” or “Accordion item”, then add a “Question” field as a single-line string and an “Answer” field as Structured Text or multi-paragraph text. After that, on the page or model where you want the FAQ to appear, add a Modular Content field and allow that FAQ item block in the field validations. Editors will then be able to add as many FAQ items as they need, reorder them, remove them, and edit each question and answer from the DatoCMS editor.
If you already have a page-builder style Modular Content field, you could also create an “FAQ section” block. Inside that block, you can add another Modular Content field that accepts “FAQ item” blocks. That way, the editor adds one FAQ section to the page, and then manages all the accordion rows inside it. Nested blocks are supported, so this works very well for this kind of pattern.
On the frontend, you would query the Modular Content field and map the FAQ block to your accordion component. DatoCMS provides the structured content, and your frontend decides how to render it, including whether each answer is collapsed or expanded, animations, icons, and accessibility attributes.
These docs should help you get started:
https://www.datocms.com/docs/content-modelling/modular-content
https://www.datocms.com/docs/content-modelling/blocks
https://www.datocms.com/docs/content-delivery-api/modular-content-fields
You can also see this exact use case (an FAQ using modular content blocks) in our demo right here:
Let me know if that is what you were looking for!