Urgent Collapsible Description Section Not Working Properly

Topic summary

A store owner is experiencing two issues with a custom collapsible description section, with a website launch scheduled in 5 days:

Problems identified:

  1. Collapsible sections work inconsistently after the site is published
  2. Button titles display in unwanted blue color on mobile devices

Solutions provided:

For inconsistent behavior: Move the JavaScript initialization code to a global file (theme.js) or the theme.liquid footer to ensure it runs reliably across all page loads, including dynamic/AJAX-loaded content.

For blue mobile styling: Add CSS rules to override default browser button styling:

.collapsible-btn {
  color: #333;
}
.collapsible-btn:focus,
.collapsible-btn:active {
  color: #333;
  outline: none;
}

Current status: The original poster resolved the JavaScript issue but needed clarification on CSS placement. The helper provided detailed instructions to replace the existing .collapsible-btn styles within the <style> tags and offered ongoing support for implementation.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

I’m launching my website in 5 days and I need help with an issue I’m facing. I created a custom section in my theme code for collapsible descriptions, which I’m using on both product pages and a general content page. However, most of the time, the collapsible sections don’t work once the site is published.

Also, on the mobile interface, the collapsible titles are showing in blue, which I didn’t specify in my design or code.

Could you please help me fix:

  1. The inconsistent behavior of the collapsible sections (sometimes not working when published).

  2. The blue color of the collapsible titles on mobile, which I didn’t set.

Any urgent guidance would be hugely appreciated so I can launch on time!

The code:

{% comment %}
Collapsible Description Section
File: collapsible-description.liquid
{% endcomment %}

{% if section.settings.title != blank %}

{{ section.settings.title }}

{% endif %}

{% for block in section.blocks %}

{{ block.settings.heading }}
{{ block.settings.content }}
{% endfor %}
.collapsible-section { margin: 20px 0; } .collapsible { border-bottom: 1px solid #ddd; margin-bottom: 10px; } .collapsible-btn { width: 100%; background: none; border: none; text-align: left; padding: 10px; font-size: 18px; cursor: pointer; font-weight: bold; position: relative; } .collapsible-content { display: none; padding: 10px; background-color: #f9f9f9; } .collapsible-btn::after { content: '+'; position: absolute; right: 10px; } .collapsible.active .collapsible-btn::after { content: '-'; }

{% schema %}
{
“name”: “Collapsible Description”,
“settings”: [
{
“type”: “text”,
“id”: “title”,
“label”: “Section Title”,
“default”: “More Information”
}
],
“blocks”: [
{
“type”: “collapsible”,
“name”: “Collapsible Item”,
“settings”: [
{
“type”: “text”,
“id”: “heading”,
“label”: “Heading”,
“default”: “Click to expand”
},
{
“type”: “richtext”,
“id”: “content”,
“label”: “Content”,
“default”: “

Here is your collapsible content.


}
]
}
],
“presets”: [
{
“name”: “Collapsible Description”,
“category”: “Custom”
}
]
}
{% endschema %}

Hi! :waving_hand: Your section and JS logic are well-structured! Here are my suggestions that should get things working consistently:

1. Collapsible sections not working when published
This happens because the JavaScript may not be re-initialized properly when the section is loaded dynamically (e.g., on product pages).
Try placing your script either in a global JS file (like theme.js) or include it in the theme.liquid footer to ensure it always runs.

2. Blue button text on mobile
That’s due to default mobile browser styling on elements. Add this to your CSS:

.collapsible-btn {
  color: #333;
}
.collapsible-btn:focus,
.collapsible-btn:active {
  color: #333;
  outline: none;
}

That should fix both issues — let me know if you’d like help moving the JS globally or adjusting styling for your specific theme!

Good luck on your launch!
Thanks.

Thank you for your quick response. I solved the first part of my problem, but I’m not quite sure where exactly to add the part of your code. Could you please be a little more specific about where to place it? Should I add it before or after a specific part of the existing code?

wherever between you can put it. You can revise collapsible-btn in style tag in your code and add two button css state as follows:

collapsible-btn {
width: 100%;
background: none;
border: none;
text-align: left;
padding: 10px;
font-size: 18px;
cursor: pointer;
font-weight: bold;
position: relative;
color: #333;
}

.collapsible-btn:focus,
.collapsible-btn:active {
  color: #333;
  outline: none;
}

You can copy this code and replace the css code of collapsible-btn inside of tag. I added a random color as #333, you can change it whatever you like.

Hope it helps! If you’re still having trouble, I can guide you step by step or take a quick look with you.

Could you do that? Do you need a guidance you can ping me anytime.

Hello again!

thank you so much for your time and answer!

1 Like