Open In App

Foundation CSS Accordion Sass Reference

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Foundation CSS is an open-source and responsive front-end framework created by ZURB in September 2011 that makes it simple to create stunning responsive websites, apps, and emails that operate on any device. Many companies, like Facebook, eBay, Mozilla, Adobe, and even Disney, use it. This framework is based on Bootstrap, which is similar to SaaS. It’s more complex, versatile, and configurable. It also comes with a command-line interface, making it simple to use with module bundlers. You may get responsive HTML emails from an email frameworks that functions on any device. Foundation for Apps allows you to build fully responsive web applications.

Accordions are the elements that help us to organize and navigate different sections in a single container. These are used to switch between the sections in the container. We can store a large amount of data in a structured manner and can be easily accessible. In this article, we will discuss the basics of the accordion.

Variable Used:

Variable-NameDescriptionTypeDefault-Value
$accordion-background This variable is used to define the default background color of an accordion group.Color $white 
$accordion-plusminus This variable is used to add plus and minus icons to the side of each accordion title.Boolean true
$accordion-plus-content This variable is used to define the content for the plus icon when $accordion-plusminus is trueString'\002B' 
$accordion-minus-content This variable is used to define the content for the minus icon when $accordion-plusminus is trueString'\2013' 
$accordion-title-font-size This variable is used to define the font size of accordion titles.Number rem-calc(12) 
$accordion-item-color This variable is used to define the default text color for items in a menu.Color$primary-color 
$accordion-item-background-hover This variable is used to define the default background color on hover for items in a menu.Color$light-gray 
$accordion-item-padding This variable is used to define the default padding of an accordion item.Number or List 1.25rem 1rem 
$accordion-content-background This variable is used to define the default background color of tab content.Color$white 
$accordion-content-border This variable is used to define the default border color of tab content.Color1px solid $light-gray 
$accordion-content-color This variable is used to define the default text color of tab content.Color$body-font-color 
$accordion-content-padding This variable is used to define the default padding for tab content.Number or List 1rem 
 

Example 1: In the below code, we will make use of the above variable to demonstrate the use of the accordion.

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/foundation.min.css"
          crossorigin="anonymous"/>

    <!-- Compressed JavaScript -->
    <script src=
"https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js">
    </script>
    <script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/foundation.min.js" 
          crossorigin="anonymous">
    </script>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <center>
        <h2 style="color:green">GeeksforGeeks</h2>
        <h3>A computer science portal for geeks</h3>
    </center>

    <ul class="accordion" data-accordion>
        <li class="accordion-item is-active" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 1</a>
            <div class="accordion-content" data-tab-content>
                <p>A Computer Science portal for geeks.</p>
            </div>
        </li>
        <li class="accordion-item" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 2</a>
            <div class="accordion-content" data-tab-content>
                <p>
                    It contains well written, well thought and
                    well explained computer science and
                    programming articles,
                </p>
            </div>
        </li>
        <li class="accordion-item" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 3</a>
            <div class="accordion-content" data-tab-content>
                <p>
                    Gfg is the only reason to fall in love
                    with data structure and programming
                </p>
            </div>
        </li>
    </ul>

    <script>
        $(document).ready(function () {
            $(document).foundation();
        });
    </script>
</body>
</html>

SASS Code:

$accordion-background: white;
.accordion {
   background-color:$accordion-background;
}

Compiled CSS Code:

.accordion {
  background-color: white; 
}

Output:

 

Example 2:  In the below code, we will make use of the above variable to demonstrate the use of the accordion.

HTML
<!DOCTYPE html>
<html>
<head>
    <!-- Compressed CSS -->
    <link rel="stylesheet" href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/foundation.min.css"
          crossorigin="anonymous"/>

    <!-- Compressed JavaScript -->
    <script src=
"https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js">
    </script>
    <script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/foundation.min.js" 
          crossorigin="anonymous">
    </script>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <center>
        <h2 style="color:green">GeeksforGeeks</h2>
        <h3>A computer science portal for geeks</h3>
    </center>

    <ul class="accordion" data-accordion>
        <li class="accordion-item is-active" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 1</a>
            <div class="accordion-content" data-tab-content>
                <p>A Computer Science portal for geeks.</p>
            </div>
        </li>
        <li class="accordion-item" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 2</a>
            <div class="accordion-content" data-tab-content>
                <p>
                    It contains well written, well thought and
                    well explained computer science and
                    programming articles,
                </p>
            </div>
        </li>
        <li class="accordion-item" data-accordion-item>
            <a href="#" class="accordion-title">GeeksforGeeks 3</a>
            <div class="accordion-content" data-tab-content>
                <p>
                    Gfg is the only reason to fall in love
                    with data structure and programming
                </p>
            </div>
        </li>
    </ul>

    <script>
        $(document).ready(function () {
            $(document).foundation();
        });
    </script>
</body>
</html>

SASS Code:

$accordion-item-background-hover: lightgrey;
.accordion-item {
   background-color:$accordion-item-background-hover;
}

Compiled CSS Code:

.accordion-item {
   background-color: lightgrey; 
}

Output:

 

Reference: https://get.foundation/sites/docs/accordion.html


Similar Reads