Overview

What It's For

The Accordion block lets you present content in a vertically stacked series of collapsible rows. Visitors see a list of titled headers; clicking a header expands that row to reveal its body content, and clicking again collapses it. Each collapsible row is managed as an inner Accordion Item block, so you build the accordion's content entirely inside the block editor without touching any code.

When to Use It

Reach for the Accordion block whenever you need to condense a large amount of content — FAQs, feature details, policy sections, step-by-step instructions — into a compact, scannable format. It's the right choice over a generic columns or group layout because it ships with all the interaction logic built in: animated expand/collapse, keyboard navigation, URL-hash deep-linking (a visitor can link directly to a specific open row), and CLS-prevention skeletons so the page doesn't jump as JavaScript loads. You don't need a separate plugin or custom JavaScript to get any of that.

Key Capabilities

  • Single Open mode — optionally enforce that only one row can be open at a time, automatically closing the previously open item when another is clicked
  • Toggle icon control — show or hide the expand/collapse icon in each row header; optionally display a text label alongside the icon
  • Configurable heading tag and style — independently set the HTML heading tag (H1–H6, p, or span) and the visual heading class (H1–H6, strong variants, caption variants, or Sub Title) for all item titles at once from the parent block, with the ability to override per item
  • URL hash deep-linking — a specific accordion item opens automatically when a visitor arrives via a URL that includes that item's anchor as the hash fragment
  • HTML Anchor — assign a unique page anchor to the entire accordion block for same-page navigation links
  • Block-level padding control — fine-tune top, bottom, left, and right padding using theme-relative spacing increments (Quarter, Half, Base, Double, Triple) or inherit from the theme default
  • Z-index control — set a custom stacking order for the block
  • Hide Block — suppress the entire accordion from rendering on the front end without deleting it
  • Accessible keyboard navigation — Tab and Shift+Tab move through accordion headers and open content predictably; Enter opens and closes items
  • CLS prevention — a server-rendered skeleton placeholder matches the height of accordion headers before the interactive component mounts, preventing layout shift on page load

DOM Structure

<div id="{anchor}" class="fc-accordion outer-wrapper vue-instance" style="{spacing-and-other-styles}">
  <!-- id is empty string when no HTML Anchor is set -->
  <!-- 'unmounted' class added when skeleton CLS prevention is active; removed by Vue on mount -->
  <!-- 'display:none' inline style added when 'Hide Block' is checked in Other Settings -->
  <!-- 'z-index:{n}' inline style added when Z-Index is set in Other Settings -->
  <!-- spacing padding styles appended when Spacing controls are configured -->

  <div class="accordion"> <!-- See DOM Notes: accordion expand/collapse interaction -->
    <!-- one per accordion-item inner block -->
    <slot></slot>
    <!-- slot renders fc-blocks/accordion-item inner blocks here -->
    <!-- when 'Single Open' is checked, clicking one item closes all others -->
    <!-- when 'No Toggle Icon' is checked, toggle icons inside each item are hidden via display:none -->
    <!-- accordion items opened via URL hash anchor are scrolled into view and expanded automatically -->
  </div>

</div>

<!-- when skeleton CLS prevention is active (block visible and has at least one visible accordion-item) -->
<div id="{block-id}" class="accordion-skeleton"> <!-- See DOM Notes: skeleton CLS prevention -->
  <!-- one per visible accordion-item inner block -->
  <div class="accordion-skeleton__item">
    <div class="accordion-skeleton__heading {heading-class}"></div>
    <!-- heading-class reflects 'Title Heading Class' from Heading panel (default: h5) -->
    <!-- overridden per-item if the accordion-item sets its own Title Heading Class -->
    <!-- toggle icon placeholder included when 'No Toggle Icon' is NOT checked -->
  </div>
  <!-- repeated for each visible accordion-item -->
</div>
<!-- skeleton receives 'visually-hidden' class and is hidden once Vue mounts -->

DOM Notes

Interactive Regions

Accordion Item Open/Close

Each accordion item's heading row is clickable (and keyboard-activatable via Enter). When a visitor clicks or presses Enter on a heading, the item's body panel animates open or closed by setting its inline height style to the panel's measured scrollHeight (to open) or 0 (to close). The accordion__item--active class is added to the item when open and removed when closed. If content inside an open item changes size (e.g. a nested tab block switches panels), any subsequent click or Enter keypress inside that item recalculates and updates the body height to match the new content size.

Single Open Mode

When the Single Open setting is enabled (Controls panel, "Single Open" checkbox), only one accordion item may be open at a time. Clicking or pressing Enter on any heading closes every other currently-open item (sets their body height to 0, removes accordion__item--active) before opening the selected one. When Single Open is off (the default), each item toggles independently and multiple items can be open simultaneously.

Hash / Anchor Link Auto-Open

On page load, if the URL contains a fragment identifier (e.g. #my-item) that matches the id attribute of an accordion item, the Vue component automatically opens that item and smoothly scrolls it into view after a 300 ms delay. The same behavior fires whenever the URL hash changes while the page is loaded (e.g. the visitor clicks an anchor link elsewhere on the page). If Single Open is active, all other items are closed before the targeted item opens; in multi-open mode only the targeted item is opened.

Skeleton / CLS Prevention (Mount Transition)

The PHP renderer outputs a skeleton placeholder — one row per visible accordion item — alongside the real <fc-accordion> component. The outer wrapper starts with the unmounted class applied, which keeps it visually hidden until Vue mounts. On mount the Vue component immediately removes the unmounted class from the real accordion wrapper (making it visible) and adds visually-hidden to the skeleton element (hiding it). This swap prevents layout shift during the Vue hydration delay: visitors see a size-matched placeholder, then the live interactive accordion replaces it without a visible jump.

Keyboard Focus Management

The accordion implements custom Tab and Shift+Tab focus routing so keyboard users skip over the hidden body content of closed items. When tabbing forward through a closed item, focus jumps directly to the next item's heading rather than entering the invisible body. When tabbing backward, focus lands on the correct preceding heading. When the last item is closed and the user tabs forward, focus moves to the next focusable element outside the accordion entirely. This logic runs entirely client-side via keydown listeners attached on mount.

Technical Documentation

Block Settings

Single Open

  • Attribute: singleOpen
  • Type: Checkbox
  • Default: Unchecked (false)
  • Panel: Controls

What it controls — When checked, opening one accordion item automatically collapses any currently open item, so only one row is expanded at a time. When unchecked, any number of rows may be open simultaneously.

Options

  • Unchecked — Multiple accordion items can be open at the same time (default).
  • Checked — Only one item can be open at a time; clicking a new item closes the previously open one.

No Toggle Icon

  • Attribute: noToggleIcon
  • Type: Checkbox
  • Default: Unchecked (false)
  • Panel: Controls

What it controls — Hides the expand/collapse icon that appears in each accordion row's header. When checked, the icon is removed from the rendered accordion; the heading text alone acts as the clickable trigger.

Options

  • Unchecked — Toggle icon is visible in each accordion header (default).
  • Checked — Toggle icon is hidden; the Toggle Text field also disappears from the inspector.

Notes — Enabling this also hides the Toggle Text field below, since that text is positioned relative to the icon.

Toggle Text

  • Attribute: toggleText
  • Type: Text field
  • Default: Empty string
  • Panel: Controls

What it controls — Sets a short label that appears to the left of the toggle icon in every accordion item header within this block. Useful for prompting users with text like "Expand" or "Read more."

Conditional Logic — This field is only visible when No Toggle Icon is unchecked.

Notes — The value entered here is pushed down to all child Accordion Item blocks automatically; editors do not need to set it per item.

Title Heading Tag

  • Attribute: titleHeadingTag
  • Type: Single-select dropdown
  • Default: h3
  • Panel: Heading

What it controls — Sets the HTML element used for the title/heading in every accordion item within this block. Choosing the appropriate tag level ensures correct document outline and SEO heading hierarchy.

Options

  • H1, H2, H3 (default), H4, H5, H6, P, Span

Notes — This setting propagates to all child Accordion Item blocks as their default heading tag. Individual items may override this at the item level.

Title Heading Class

  • Attribute: titleHeadingClass
  • Type: Single-select dropdown
  • Default: h5
  • Panel: Heading

What it controls — Sets the visual style applied to accordion item titles across the entire block, independently of the semantic HTML tag chosen above. For example, you can use an h3 tag styled to look like an h5, or apply a bold or caption variant.

Options

  • H1, H2, H3, H4, H5 (default), H6
  • H1 – Strong, H2 – Strong, H3 – Strong, H4 – Strong, H5 – Strong, H6 – Strong
  • H1 Caption, H2 Caption, H3 Caption, H4 Caption, H5 Caption, H6 Caption
  • Sub Title
  • Inherit

Notes — Propagates to all child Accordion Item blocks as the default heading class. Individual items may override it. "Inherit" causes each item to inherit the parent block's styling without applying an explicit class.

Z-Index

  • Attribute: otherSettings[3]
  • Type: Number field
  • Default: Empty (no z-index applied)
  • Panel: Other Settings

What it controls — Sets the CSS z-index property on the accordion wrapper, controlling its stacking order relative to other elements on the page.

Options — Accepts any integer. Shift-click increments/decrements by 10.

HTML Anchor

  • Attribute: otherSettings[1]
  • Type: Text field
  • Default: Empty
  • Panel: Other Settings

What it controls — Adds an id attribute to the accordion's outer wrapper element, creating a named anchor on the page. Visitors or links can jump directly to this accordion using a URL fragment (e.g. https://example.com/page#my-accordion).

Notes — Enter a word or two without spaces. The accordion also supports hash-based deep linking: if the URL fragment matches an Accordion Item's anchor, that item will automatically open and scroll into view on page load.

Hide Block

  • Attribute: otherSettings[2]
  • Type: Checkbox
  • Default: Unchecked (false)
  • Panel: Other Settings

What it controls — When checked, adds display: none to the accordion wrapper, hiding the entire block from view on the front end. The block remains in the editor and in the page source.

Spacing (Padding)

  • Attribute: spacing
  • Type: Composite spacing control
  • Default: Inherits from theme
  • Panel: Spacing

What it controls — Controls the padding applied to the accordion's outer wrapper. Margin controls (top, bottom, left, right) are disabled for this block; only padding is available.

Options — Each padding side (or all sides globally) can be set to one of:

  • Inherit from theme — Uses the theme's default spacing variable (default).
  • None — Sets padding to zero.
  • Quarter — calc(var(--base-spacing) * 0.25)
  • Half — calc(var(--base-spacing) * 0.5)
  • BASE — calc(var(--base-spacing))
  • Double — calc(var(--base-spacing) * 2)
  • Triple — calc(var(--base-spacing) * 3)

A Fine Tune Padding toggle reveals individual controls for Padding Top, Padding Bottom, Padding Left, and Padding Right. When the toggle is off, a single global padding value applies to all four sides.

Cross-Block Relationships

The Accordion block accepts only Accordion Item (fc-blocks/accordion-item) blocks as children. A default Accordion Item is inserted automatically when the Accordion is added to the page. Additional items are added via the "Edit Items" lightbox affordance in the editor canvas.

Settings configured at the Accordion level — Toggle Text, Title Heading Tag, and Title Heading Class — are automatically propagated to all child Accordion Item blocks and serve as their defaults. Individual Accordion Items may override the heading tag and heading class at the item level.