UNPKG

4.19 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group tabs
7////
8
9/// Default margin of the tab bar.
10/// @type Number
11$tab-margin: 0 !default;
12
13/// Default background color of a tab bar.
14/// @type Color
15$tab-background: $white !default;
16
17/// Font color of tab item.
18/// @type Color
19$tab-color: $primary-color !default;
20
21/// Active background color of a tab bar.
22/// @type Color
23$tab-background-active: $light-gray !default;
24
25/// Active font color of tab item.
26/// @type Color
27$tab-active-color: $primary-color !default;
28
29/// Font size of tab items.
30/// @type Number
31$tab-item-font-size: rem-calc(12) !default;
32
33/// Default background color on hover for items in a Menu.
34$tab-item-background-hover: $white !default;
35
36/// Default padding of a tab item.
37/// @type Number
38$tab-item-padding: 1.25rem 1.5rem !default;
39
40/// Maximum number of `expand-n` classes to include in the CSS.
41/// @type Number
42$tab-expand-max: 6 !default;
43
44/// Default background color of tab content.
45/// @type Color
46$tab-content-background: $white !default;
47
48/// Default border color of tab content.
49/// @type Color
50$tab-content-border: $light-gray !default;
51
52/// Default text color of tab content.
53/// @type Color
54$tab-content-color: $body-font-color !default;
55
56/// Default padding for tab content.
57/// @type Number | List
58$tab-content-padding: 1rem !default;
59
60/// Adds styles for a tab container. Apply this to a `<ul>`.
61@mixin tabs-container (
62 $margin: $tab-margin,
63 $background: $tab-background,
64 $border-color: $tab-content-border
65) {
66 @include clearfix;
67 margin: $margin;
68 border: 1px solid $border-color;
69 background: $background;
70 list-style-type: none;
71}
72
73/// Augments a tab container to have vertical tabs. Use this in conjunction with `tabs-container()`.
74@mixin tabs-container-vertical {
75 > li {
76 display: block;
77 float: none;
78 width: auto;
79 }
80}
81
82/// Adds styles for the links within a tab container. Apply this to the `<li>` elements inside a tab container.
83@mixin tabs-title (
84 $padding: $tab-item-padding,
85 $font-size: $tab-item-font-size,
86 $color: $tab-color,
87 $color-active: $tab-active-color,
88 $background-hover: $tab-item-background-hover,
89 $background-active: $tab-background-active
90) {
91 float: #{$global-left};
92
93 > a {
94 display: block;
95 padding: $padding;
96 font-size: $font-size;
97 line-height: 1;
98 color: $color;
99
100 &:hover {
101 background: $background-hover;
102 color: scale-color($color, $lightness: -14%);
103 }
104
105 &:focus,
106 &[aria-selected='true'] {
107 background: $background-active;
108 color: $color-active;
109 }
110 }
111}
112
113/// Adds styles for the wrapper that surrounds a tab group's content panes.
114@mixin tabs-content (
115 $background: $tab-content-background,
116 $color: $tab-content-color,
117 $border-color: $tab-content-border
118) {
119 border: 1px solid $border-color;
120 border-top: 0;
121 background: $background;
122 color: $color;
123 transition: all 0.5s ease;
124}
125
126/// Augments a tab content container to have a vertical style, by shifting the border around. Use this in conjunction with `tabs-content()`.
127@mixin tabs-content-vertical (
128 $border-color: $tab-content-border
129) {
130 border: 1px solid $border-color;
131 border-#{$global-left}: 0;
132}
133
134/// Adds styles for an individual tab content panel within the tab content container.
135@mixin tabs-panel (
136 $padding: $tab-content-padding
137) {
138 display: none;
139 padding: $padding;
140
141 &.is-active {
142 display: block;
143 }
144}
145
146@mixin foundation-tabs {
147 .tabs {
148 @include tabs-container;
149 }
150
151 // Vertical
152 .tabs.vertical {
153 @include tabs-container-vertical;
154 }
155
156 // Simple
157 .tabs.simple {
158 > li > a {
159 padding: 0;
160
161 &:hover {
162 background: transparent;
163 }
164 }
165 }
166
167 // Primary color
168 .tabs.primary {
169 background: $primary-color;
170
171 > li > a {
172 color: color-pick-contrast($primary-color);
173
174 &:hover,
175 &:focus {
176 background: smart-scale($primary-color);
177 }
178 }
179 }
180
181 .tabs-title {
182 @include tabs-title;
183 }
184
185 .tabs-content {
186 @include tabs-content;
187 }
188
189 .tabs-content.vertical {
190 @include tabs-content-vertical;
191 }
192
193 .tabs-panel {
194 @include tabs-panel;
195 }
196}