List Custom Accordion

Description

  • custom accordion with image/excerpt/title/content
  • use People List Section

(initial)

List custom accordion 1

(on click)

List custom accordion 2

#1. Install Code

Hover on page where you want to run this affect > Click Gear icon

List custom accordion 3

Click Advanced > Paste this code

<!-- @tuanphan list custom acc -->
<link rel="stylesheet" href="https://code.beaverhero.com/file?filename=1762329737642listcustomacc.css"/>
<script src="https://code.beaverhero.com/file?filename=1762329784304listcustomacc.js">
</script>

List custom accordion 4

#2. Usage

First, you need to use People List Section (Choose People > Section with (i) icon)

List custom badges 4

Next, hover on top right of List People Section > Click Edit Section

List custom badges 5

In Anchor Link, enter: list-custom-acc

list-custom-acc

List custom accordion 5

Next, hover on top right of List People section > Click Edit Content

List custom badges 5

and add your desired text/image/description

Flip list 5

Note: use ## symbol to split Excerpt text (under title) and Accordion Content text

###

List custom accordion 6

#3. Customize

This list will inherit People List section style, however with some styles, you will need to use Custom CSS code.

#3.1. To change image height, use code like this to Custom CSS

section[id*="list-custom-acc"] .tp-img {
    --tp-img-h: 300px;
}

List custom accordion 7

#3.2. To change toggle style

List custom accordion 8

You can use this to Custom CSS

section[id*="list-custom-acc"] .tp-toggle {
    --tp-toggle-bg: #000;
    --tp-toggle-color: green;
    --tp-toggle-size: 50px;
}

List custom accordion 9

#3.3. To change space between items

List custom accordion 10

Use this to Custom CSS.

section[id*="list-custom-acc"] .tp-item {
    --tp-margin-bottom: 50px;
}

List custom accordion 11

#3.4. To make first item open in default, you can use this code under main code

<script>
document.addEventListener('DOMContentLoaded', function() {
  function openFirstItem() {
    const firstItem = document.querySelector('section[id*="list-custom-acc"] .tp-item:first-child');
    if (firstItem && !firstItem.classList.contains('active')) {
      firstItem.classList.add('active');
      const toggle = firstItem.querySelector('.tp-toggle');
      if (toggle) {
        toggle.textContent = '−';
      }
    }
  }
  
  setTimeout(openFirstItem, 100);
  
  if (window.Squarespace && window.Squarespace.onInitialize) {
    window.Squarespace.onInitialize(Y, function() {
      setTimeout(openFirstItem, 100);
    });
  }
});
</script>

List custom accordion 1

Result

List custom accordion 2

Buy me a coffee