Foundation CSS Tabs Sass Reference
Foundation CSS is an open-source & responsive front-end framework built by ZURB foundation in September 2011, that makes it easy to design beautiful responsive websites, apps, and emails that look amazing & can be accessible to any device. It is used by many companies such as Facebook, eBay, Mozilla, Adobe, and even Disney. The framework is built on Saas-like bootstrap. It is more sophisticated, flexible, and easily customizable. It also comes with CLI, so it’s easy to use it with module bundlers. It offers the Fastclick.js tool for faster rendering on mobile devices.
Tabs are components that help us navigate multiple documents in a single container without leaving the page. They act as a link that changes the content inside the container based on which tab is active.
Variable Used:
Variable-Name | Description | Type | Default-Value |
---|---|---|---|
$tab-margin | This variable is used to define the default margin of the tab bar. |
Number | 0 |
$tab-background | This variable is used to define the default background color of a tab bar. | Color | $white |
$tab-color | This variable is used to define the font color of the tab item. | Color | $primary-color |
$tab-background-active | This variable is used to define the active background color of a tab bar. | Color | $light-gray |
$tab-active-color | This variable is used to define the active font color of the tab item. | Color | $primary-color |
$tab-item-font-size | This variable is used to define the font size of tab items. | Number | rem-calc(12) |
$tab-item-background-hover | This variable is used to define the default background color on hover for items in a Menu. | Color | $white |
$tab-item-padding | This variable is used to define the default padding of a tab item. | Number | 1.25rem 1.5rem |
$tab-content-background | This variable is used to define the default background color of tab content. | Color | $white |
$tab-content-border | This variable is used to define the default border color of tab content. | Color | $light-gray |
$tab-content-color | This variable is used to define the default text color of tab content. | Color | $body-font-color |
$tab-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 tabs.
HTML
<!DOCTYPE html> < html lang = "en" > < head > < title >GeeksforGeeks</ title > < link rel = "stylesheet" href = "style.css" > < link rel = "stylesheet" href = crossorigin = "anonymous" > < script src = crossorigin = "anonymous" > </ script > < link rel = "stylesheet" href = < script src = </ script > </ head > < body style = "margin:20px;" > < center > < h1 style = "color:green;" > GeeksforGeeks </ h1 > < h3 >A computer science portal for geeks</ h3 > </ center > < ul class = "tabs" data-tabs id = "tabs_example" > < li class = "tabs-title is-active" > < a href = "#content1" >Tab1</ a > </ li > < li class = "tabs-title" > < a href = "#content2" >Tab2</ a > </ li > < li class = "tabs-title" > < a href = "#content3" >Tab3</ a > </ li > < li class = "tabs-title" > < a href = "#content4" >Tab4</ a > </ li > </ ul > </ body > </ html > |
SASS Code:
$tab-background :lightgreen; li{ background-color:$tab-background; }
Compiled CSS Code:
li { background-color: lightgreen; }
Output:

Example 2: In the below code, we will make use of the above variable to demonstrate the use of tabs.
HTML
<!DOCTYPE html> < html lang = "en" > < head > < title >GeeksforGeeks</ title > < link rel = "stylesheet" href = "style.css" > < style > .tabs-title { padding: 40px; } </ style > < link rel = "stylesheet" href = crossorigin = "anonymous" > < script src = crossorigin = "anonymous" > </ script > < link rel = "stylesheet" href = < script src = </ script > </ head > < body style = "margin:20px;" > < center > < h1 style = "color:green;" > GeeksforGeeks </ h1 > < h3 >A computer science portal for geeks</ h3 > </ center > < ul class = "tabs" data-tabs id = "tabs_example" > < li class = "tabs-title is-active" > < a href = "#content1" >Tab1</ a > </ li > < li class = "tabs-title" > < a href = "#content2" >Tab2</ a > </ li > < li class = "tabs-title" > < a href = "#content3" >Tab3</ a > </ li > < li class = "tabs-title" > < a href = "#content4" >Tab4</ a > </ li > </ ul > </ body > </ html > |
SASS Code:
$tab-item-padding:40px; .tabs-title{ padding:$tab-item-padding; }
Compiled CSS Code:
.tabs-title { padding: 40px; }
Output:

Reference: https://get.foundation/sites/docs/tabs.html
Please Login to comment...