Overview
The Accordion plugin creates collapsible content sections. Each item has a heading (click to expand/collapse) and content area. It uses native<details> / <summary> in the default render and supports HTML serialization from those elements.
Installation
Basic Usage
Pass the plugin tocreateYooptaEditor; do not pass plugins to <YooptaEditor>.
Features
- Expand/Collapse: Each item can be expanded or collapsed via
isExpandedprop - Keyboard: Enter toggles expansion when in heading, or inserts a new item; Backspace removes empty items or the block
- HTML: Deserializes from
<details>/<summary>/<p>; serializes to the same - Email: Serializes to table-based layout for email clients
- Shortcuts: Type
accordionto insert
Structure
The Accordion block consists of nested elements:Configuration
Options
Keyboard shortcuts to trigger the plugin in slash menu
Element props
Commands
Accordion commands are available via the plugin’scommands and through the editor. Use editor.blocks for block-level operations and the Accordion commands for structure.
insertAccordion
Insert a new Accordion block.Number of accordion items to create initially
Initial expanded state for each item
Index or path where to insert the block
Whether to focus the new block after insert
buildAccordionElements
Build the accordion element structure (used internally byinsertAccordion).
deleteAccordion
Remove an Accordion block by id.Block operations
You can also use the generic Blocks API:Element operations
To toggle an item’s expanded state or add/remove items, use the Elements API:Keyboard behavior
- Enter in heading: toggles the item’s expanded state
- Enter in content: inserts a new accordion item after the current one
- Backspace in empty heading: removes the item (or deletes the block if it’s the only item)
- Backspace in empty content (when focus is in content): prevented so structure is preserved
Theme (Shadcn)
The@yoopta/themes-shadcn package provides styled accordion elements. Apply the theme so the Accordion block uses Shadcn UI:
accordion-list→AccordionListaccordion-list-item→AccordionListItem(useselement.props.isExpandedfordata-state)accordion-list-item-heading→AccordionItemHeadingaccordion-list-item-content→AccordionItemContent
Parsers
HTML
- Deserialize:
<details>with<summary>and<p>children - Serialize: Accordion block →
<div>containing<details>/<summary>/<p>; block metaalignanddepthare stored indata-meta-alignanddata-meta-depthon each<details>
- Serialize: Table-based layout for compatibility with email clients; headings and content in table rows with inline styles.
Related
- Tabs — Tabbed content
- Steps — Step-by-step instructions
- Blockquote — Quote blocks

