Accordion Block

  • Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nec lobortis nisi. Curabitur luctus pulvinar tincidunt. Sed faucibus magna nec velit consectetur, vel porta dolor eleifend. Cras quis ipsum in lacus pharetra aliquet a quis neque. Nullam facilisis commodo lorem, non facilisis nunc rutrum eget. Nam tempor placerat nulla sed rutrum. In imperdiet nunc at leo feugiat, rhoncus luctus tellus euismod. Quisque non ante magna.

  • Pellentesque ullamcorper sagittis mi tincidunt lobortis. Nullam commodo elit metus, ac tristique tortor vestibulum eu. Pellentesque posuere varius orci, vitae mattis neque ultricies eget. Aliquam feugiat, sapien at lacinia dignissim, orci risus tempus turpis, eu semper massa ligula non quam. Aenean gravida sapien in risus euismod blandit. Etiam convallis lacus sed ornare facilisis. In consectetur at lacus eleifend vulputate. Duis rutrum, felis vel pretium commodo, ante erat viverra nibh, sit amet pulvinar lectus turpis a mi.

  • Vivamus sodales vel sapien a cursus. Mauris rutrum sit amet leo non blandit. Mauris efficitur luctus eros. Suspendisse non vulputate ligula, vel ultricies risus. Curabitur in sagittis elit. Curabitur id tortor consequat ante tempor condimentum ac quis lectus. Fusce vel nisl eget purus scelerisque pulvinar. Integer scelerisque ligula gravida placerat egestas. Etiam placerat ipsum et lorem rhoncus, nec sagittis neque scelerisque. Cras nisl quam, accumsan ac urna et, ornare rhoncus arcu.

  • Ut placerat, nisi eu pellentesque hendrerit, neque dui sollicitudin augue, at consectetur ligula arcu nec neque. Aliquam ac ex pellentesque dolor viverra dapibus sed nec metus. Proin tellus elit, egestas sed sem sit amet, sollicitudin laoreet lacus. Phasellus nec nisl id purus facilisis hendrerit. Duis ac dignissim odio. Fusce id urna rhoncus tortor fermentum suscipit vitae ut eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra.

Description

Accordion Block adds an accessible and responsive Accordion block to the block editor inserter that can be added to display list items that expand and collapse to show and hide their associated sections of content.

Ideal for condensing longform or complex content, such as Frequently Asked Questions (FAQ). Also useful for reducing page scrolling.

Features

  • Accessible
  • Responsive
  • Inserter button for adding accordion items
  • Settings
    • Block alignment
    • Text alignment
    • Text formatting
    • Header element
    • Header icon [Pro]
    • Header icon position [Pro]
  • Styles
    • Color
      • Text
      • Background
      • Link
      • Header text [Pro]
      • Header text hover [Pro]
      • Header text active [Pro]
      • Header icon [Pro]
      • Header icon hover [Pro]
      • Header icon active [Pro]
      • Header background [Pro]
      • Header background hover [Pro]
      • Header background active [Pro]
      • Panel text [Pro]
      • Panel background [Pro]
    • Typography
      • Font family
      • Font size
      • Appearance
      • Line height
      • Letter spacing
      • Text decoration
      • Letter case
    • Dimensions
      • Padding
      • Margin
      • Item padding [Pro]
      • Item margin [Pro]
      • Header icon width [Pro]
      • Header padding [Pro]
      • Header margin [Pro]
      • Panel padding [Pro]
      • Panel margin [Pro]
    • Border
      • Item border [Pro]
      • Item border radius [Pro]
      • Header border [Pro]
      • Header border hover [Pro]
      • Header border active [Pro]
      • Header border radius [Pro]
      • Panel border [Pro]
      • Panel border radius [Pro]
  • Variations [Pro]
    • Lines [Pro]
    • Blocks [Pro]

HTML

Accordion Block will output an Accordion block with the following HTML structure:

<ul class="wp-block-tt-accordion ">
    <li class="wp-block-tt-accordion-item wp-block-tt-accordion-item-1">
        <p class="wp-block-tt-accordion-item-header">
            <button class="wp-block-tt-accordion-item-header-button" id="wp-block-tt-accordion-item-header-button-9515cb6e-8464-424b-a277-3102bd5202cf" type="button" aria-expanded="false" aria-controls="wp-block-tt-accordion-item-panel-9515cb6e-8464-424b-a277-3102bd5202cf">
                <span class="wp-block-tt-accordion-item-header-button-text">Title</span>
                <span class="wp-block-tt-accordion-item-header-button-icon-arrow" aria-hidden="true">
                    <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24px" height="24px" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
                        <polyline points="4.711,8 12,15.289 19.289,8" stroke="black" stroke-width="2" fill="none"></polyline>
                    </svg>
                </span>
            </button>
        </p>
        <div class="wp-block-tt-accordion-item-panel" id="wp-block-tt-accordion-item-panel-9515cb6e-8464-424b-a277-3102bd5202cf" role="region" aria-labelledby="wp-block-tt-accordion-item-header-button-9515cb6e-8464-424b-a277-3102bd5202cf" hidden="">
            <p>Panel</p>
        </div>
    </li>
</ul>

Support

If you need help with Accordion Block, please submit a ticket on the Support forum.

If you like Accordion Block and would like to support it’s future development, how about buying me a coffee?

Contribute

If you would like to contribute to the development of Accordion Block, the repository is located on GitHub.

License

Accordion Block is released under the GNU General Public License, version 2 (GPLv2).

Requirements

  • WordPress 6.0 or greater
  • PHP version 7.4 or greater
  • MySQL version 5.7 or greater or MariaDB version 10.3 or greater.

Installation

Accordion Block can be installed in one of the following three ways:

Upload

To install with a .zip file:

  1. Login to your WordPress site at domain.com/wp-admin, where domain.com is the domain of your WordPress site.
  2. On the Dashboard page, in the left menu, click Plugins.
  3. On the Plugins page, click Add New Plugin.
  4. On the Add Plugins page, click Upload Plugin.
  5. Click Choose File, locate the .zip file and click Open.
  6. Click Install Now.
  7. On the Installing Plugin from uploaded file page, click Activate.

Manual

To install with a SFTP client:

  1. If you have a .zip file, unzip it with archiving software such as WinZip or Archive Utility.
  2. In a SFTP client such as WinSCP or FileZilla, connect to your WordPress site directory on your server.
  3. In the unzipped files, copy the accordion-block folder and paste on your server, in your site’s wp-content/plugins folder.
  4. Login to your WordPress site at domain.com/wp-admin, where domain.com is the domain of your WordPress site.
  5. On the Dashboard page, in the left menu, click Plugins.
  6. On the Plugins page, locate Accordion Block and click Activate.

Theme

To install in your theme instead of a plugin:

  1. If you have a .zip file, unzip it with archiving software such as WinZip or Archive Utility.
  2. In the unzipped files, copy the accordion-block folder and paste in your site’s theme folder, such as wp-content/themes/your-theme/inc/accordion-block/, where your-theme is your theme folder.
  3. In a code editor such as Visual Studio Code or Notepad++, open your theme’s functions.php file.
  4. In your functions.php file, add the path from Step 2, such as require get_stylesheet_directory() . ‘/inc/accordion-block/accordion-block.php’;.
  5. Save and close your functions.php file.

FAQ

What is an accordion?

An accordion is a common UI/UX pattern that can help reduce or condense the amount of information presented to users.

It is a vertically stacked set of interactive headings that each contain a title, content snippet, or thumbnail representing a section of content. The headings function as controls that enable users to reveal or hide their associated sections of content. Accordions are commonly used to reduce the need to scroll when presenting multiple sections of content on a single page.

The term stems from the musical accordion in which sections of the bellows can be expanded by pulling outward.

To learn more, see Accordion (Sections With Show/Hide Functionality).

How do I install Accordion Block?

Please see Installation section.

How do I add an Accordion block?

  1. Login to your WordPress site at domain.com/wp-admin, where domain.com is the domain of your WordPress site.
  2. On the Dashboard page, in the left menu, click Posts or Pages.
  3. On the Posts or Pages page, either click Add New, search for and/or click the desired post or page title.
  4. In the block editor, either:
    • Click the block inserter + icon in the top toolbar
    • Click the block inserter + icon to the right of an empty block, or
    • Click the block inserter + icon between blocks
  5. In the block inserter pop-up modal window, search for and/or click Accordion to add an Accordion block.

How do I edit an Accordion block?

  1. Login to your WordPress site at domain.com/wp-admin, where domain.com is the domain of your WordPress site.
  2. On the Dashboard page, in the left menu, click Posts or Pages.
  3. On the Posts or Pages page, search for and/or click the desired post or page title.
  4. In the block editor, click the desired Accordion block.
  5. To edit the whole Accordion block:
    1. In the block toolbar above, click the Accordion icon, select the desired position, block alignment, text formatting and/or other options.
    2. In the settings sidebar, in the Block tab:
      • In the Settings tab, select the desired Header ElementHeader Icon and/or Header Icon Position settings.
      • In the Styles tab, select the desired ColorTypographyDimensions and/or Border settings.
  6. To edit an Accordion Item within the Accordion block:
    1. Click the desired Accordion Item title and/or panel to edit.
    2. In the block toolbar above, select the desired position, text alignment, text formatting and/or other options.
    3. In the settings sidebar, in the Block tab, select the desired ColorTypographyDimensions and/or Advanced settings.
  7. To add an Accordion Item, click the + button below the Accordion block.

How do I setup a development environment?

  1. Install WordPress on a local server such as LocalDockerMAMP or XAMPP.
  2. To install Accordion Block on your local site, see Installation section.
  3. If node.js is not already installed locally, go to https://nodejs.org/ to install.
  4. In a Command Line Interface (CLI) such as Command Prompt or Terminal, navigate to the accordion-block folder. For example, cd localhost/your-site/wp-content/plugins/accordion-block.
  5. To install project dependencies, type npm install.
  6. In the accordion-block folder, edit the desired file or files.
  7. To create or update the production build directory, type npm run build. For other commands, type npm run.

Screenshots

Accordion block added from the block inserter.
Accordion block variations [Pro].
Accordion block settings sidebar [Pro].
Accordion block settings sidebar [Pro].
Accordion block on the front end.

Changelog

0.1.0 – November 15, 2023

  • Initial release

Credits