Jump to content

How can I display an open Accordion Block item by default?

Recommended Posts

14 minutes ago, usingmyhead said:

I'm wondering if anyone has some code that will show an item from the Squarespace Accordion Block as open by default? My client wants the first accordion item to be open when the page loads

This is a built-in feature 🙂

expand-first-accordion-item.thumb.jpg.36ef08b4c1d1a95092bfda12a5eeb2f0.jpg

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

...and never more shocked than me to discover that something is built in and doesn't require code 😲

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment
6 hours ago, paul2009 said:

...and never more shocked than me to discover that something is built in and doesn't require code 😲

I would have started coding without even checking for sure... 🤦‍♂️

Freelance Squarespace developer making plugins like Full-Width Blocks, Hover effects for grid gallery and the Darkmode plugin. I know Squarespace inside out and I'm able to solve pretty much any Squarespace code problem.

Get in touch here!

Link to comment
  • 1 month later...
On 2/4/2022 at 10:06 AM, paul2009 said:

This is a built-in feature 🙂

expand-first-accordion-item.thumb.jpg.36ef08b4c1d1a95092bfda12a5eeb2f0.jpg

Any insight on how to set all accordion blocks to be opened at once?

 

I understand it would most likely take some javascript... Attempting to have a list layout on Desktop with each section always open, but then make it more mobile friendly aka accordion-functioning on mobile. Any thoughts?

Link to comment
On 3/23/2022 at 4:39 AM, MayaViolet said:

Any insight on how to set all accordion blocks to be opened at once?

 

I understand it would most likely take some javascript... Attempting to have a list layout on Desktop with each section always open, but then make it more mobile friendly aka accordion-functioning on mobile. Any thoughts?

Add to Design > Custom CSS

/* Accordion Block - Expand all items */
  .sqs-block-accordion .accordion-item__dropdown {
    display: block !important;
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • 1 year later...
On 3/24/2022 at 7:39 AM, tuanphan said:

Add to Design > Custom CSS

/* Accordion Block - Expand all items */
  .sqs-block-accordion .accordion-item__dropdown {
    display: block !important;
}

 

how would we apply this to not all items, but say the 4th one? odd request i know! 

and is it possible to number the accordian list titles in a different font?! 

 

thank you so much this would be so helpful!!!

 

Link to comment
On 11/22/2023 at 12:12 AM, daniellenoakes said:

how would we apply this to not all items, but say the 4th one? odd request i know! 

and is it possible to number the accordian list titles in a different font?! 

 

thank you so much this would be so helpful!!!

 

#1. Use this

/* Accordion Block - Expand all items */
  .sqs-block-accordion li:nth-child(4) .accordion-item__dropdown {
    display: block !important;
}

#2. Each titles in each accordion will use a different font name or font color or?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 11/24/2023 at 3:30 AM, tuanphan said:

#1. Use this

/* Accordion Block - Expand all items */
  .sqs-block-accordion li:nth-child(4) .accordion-item__dropdown {
    display: block !important;
}

#2. Each titles in each accordion will use a different font name or font color or?

i'm trying to change the numbers to be a different font, here's my attempt:

 

#block-yui_3_17_2_1_1700055594134_17636  .accordion-item__title h4 strong * {font-family: 'montserrat'!important;
font-size:08.em!important;
letter-spacing:0.2em!important;}

Screenshot 2023-12-01 at 11.14.40.png

Link to comment
33 minutes ago, daniellenoakes said:

i'm trying to change the numbers to be a different font, here's my attempt:

 

#block-yui_3_17_2_1_1700055594134_17636  .accordion-item__title h4 strong * {font-family: 'montserrat'!important;
font-size:08.em!important;
letter-spacing:0.2em!important;}

Screenshot 2023-12-01 at 11.14.40.png

Use

strong b, strong

instead of

strong *

If it still doesn't work, you can share link to page where you use accordion, I can check easier

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
5 hours ago, tuanphan said:

Use

strong b, strong

instead of

strong *

If it still doesn't work, you can share link to page where you use accordion, I can check easier

 

I got it to work using your thread: 

with <strong> 01/ </strong> in the accordion title

using code: 

#block-yui_3_17_2_1_1700055594134_17636  .accordion-item__title strong {font-family: 'montserrat'!important;
font-size:12px!important;
  position:relative;
  top:-1vh!important;
letter-spacing:0.2em!important;
font-weight:400;}

 

and this code in the page header code injection:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("span.accordion-item__title").each(function(){
    $(this).html($(this).text());
  });
});
</script>

 

 

 

Link to comment
On 11/24/2023 at 3:30 AM, tuanphan said:

#1. Use this

/* Accordion Block - Expand all items */
  .sqs-block-accordion li:nth-child(4) .accordion-item__dropdown {
    display: block !important;
}

#2. Each titles in each accordion will use a different font name or font color or?

is there a way to use this code but then have the item close when another is expanded? i only want one open at a time ! thank you 

Link to comment
On 12/2/2023 at 12:14 AM, daniellenoakes said:

is there a way to use this code but then have the item close when another is expanded? i only want one open at a time ! thank you 

Can you share link to a page where you use accordion, I can check easier

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 12/4/2023 at 7:10 PM, daniellenoakes said:

www.annajonesbridal.co.uk/about-new

Try this code

/* Accordion Block - Expand all items */
[data-section-id="6554d09ab712136bc5ed868e"] {
  .sqs-block-accordion li:nth-child(4) .accordion-item__dropdown {
    display: block !important;
}
[data-is-open="true"] ~ li.accordion-item .accordion-item__dropdown {
    display: none !important;
}}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
1 hour ago, tuanphan said:

Try this code

/* Accordion Block - Expand all items */
[data-section-id="6554d09ab712136bc5ed868e"] {
  .sqs-block-accordion li:nth-child(4) .accordion-item__dropdown {
    display: block !important;
}
[data-is-open="true"] ~ li.accordion-item .accordion-item__dropdown {
    display: none !important;
}}

 

amazing did the job thank you so much!

Link to comment
  • 3 months later...
On 3/24/2022 at 2:39 AM, tuanphan said:

Add to Design > Custom CSS

/* Accordion Block - Expand all items */
  .sqs-block-accordion .accordion-item__dropdown {
    display: block !important;
}

 

Can this code be used for certain pages and not the entire site? I would like different sections to expand on different website pages. 

Link to comment
On 3/26/2024 at 3:49 PM, StephanieFlynnLaw said:

Can this code be used for certain pages and not the entire site? I would like different sections to expand on different website pages. 

You can edit that page > Add a Block > Choose Code > Paste this code

<style>
  /* Accordion Block - Expand all items */
  .sqs-block-accordion .accordion-item__dropdown {
    display: block !important;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.