Press "Enter" to skip to content

A Simple Accessible Show-and-Hide/Accordion Script | houdini

Houdini is a simple accessible show-and-hide/accordion script. Houdini gradually improves the codec as it loads. You provide content and Houdini layers in toggle buttons, ARIA themes, and interaction on your behalf.

what’s new?

  • Supports multiple creations simultaneously.
  • Ease of access and better connotations.
  • It automatically improves your coding incrementally.
  • Deprecated callbacks in favor of custom events.


Houdini includes smart defaults and works right out of the box. But if you want to customize things, it also has a powerful API that provides you with multiple ways to set default options and settings.

How to make use of it:

1. Import Houdini files (JavaScript and Stylesheet) to the page.

<!-- stylesheets -->
<link rel="stylesheet" href="dist/css/houdini.css">
<!-- Javascript -->
<script src="dist/js/houdini.js"></script>

2. Configure the Houdini library.


3. Create a widget that switches the main content.

<a class="collapse-toggle" data-collapse href="#show-me">
  <span class="collapse-text-show">Show +</span>
  <span class="collapse-text-hide">Hide -</span>
<div class="collapse" id="show-me">
  Target content

4. Create a basic accordion widget that supports multiple content blocks and only one block should be visible at a time.

<a class="collapse-toggle active" data-collapse data-group="accordion" href="#section1">
  Section 1
  <span class="collapse-text-show">+</span>
  <span class="collapse-text-hide">-</span>
<div class="collapse active" id="section1">
  Section 1 Content
<a class="collapse-toggle active" data-collapse data-group="accordion" href="#section2">
  Section 2
  <span class="collapse-text-show">+</span>
  <span class="collapse-text-hide">-</span>
<div class="collapse active" id="section2">
  Section 2 Content
<a class="collapse-toggle active" data-collapse data-group="accordion" href="#section3">
  Section 3
  <span class="collapse-text-show">+</span>
  <span class="collapse-text-hide">-</span>
<div class="collapse active" id="section3">
  Section 3 Content

5. Default settings.

  selectorToggle: '[data-collapse]',
  selectorContent: '.collapse',
  toggleActiveClass: 'active',
  contentActiveClass: 'active',
  initClass: 'js-houdini',
  stopVideo: true

6. Callback functions will be triggered when content is shown or hidden.

  callbackOpen: function () {},
  callbackClose: function () {}

Custom Events

Houdini emits five custom events:

  • houdiniExpand is emitted on a content element after it’s expanded.
  • houdiniCollapse is emitted on a content element after it’s collapsed.
  • houdiniInitialize is emitted  document when the script is initialized, but before the DOM is set up.
  • houdiniSetup is emitted  document after the DOM is set up.
  • houdiniDestroy is emitted  document after initialization is destroyed.

On the houdiniExpand  houdiniCollapse the event, the event.detail object includes the content and button. For the houdiniInitializehoudiniSetup, and houdiniDestroy the event includes the settings object.

accordion & content toggle js, Houdini Plugin/Github/Codepen

See Demo And Download

Official Website(cferdinandi): Click Here

This superior jQuery/javascript plugin is developed by cferdinandi. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.