Skip to content

Commit 2543b87

Browse files
committed
feat: add underline variant to tabs
1 parent b9a2b2b commit 2543b87

File tree

3 files changed

+61
-18
lines changed

3 files changed

+61
-18
lines changed

docs/content/components/navs-tabs.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,27 @@ Take that same HTML, but use `.nav-pills` instead:
168168
</ul>
169169
{{< /example >}}
170170

171+
### Underline
172+
173+
Take that same HTML, but use `.nav-underline` instead:
174+
175+
{{< example >}}
176+
<ul class="nav nav-underline">
177+
<li class="nav-item">
178+
<a class="nav-link active" aria-current="page" href="#">Active</a>
179+
</li>
180+
<li class="nav-item">
181+
<a class="nav-link" href="#">Link</a>
182+
</li>
183+
<li class="nav-item">
184+
<a class="nav-link" href="#">Link</a>
185+
</li>
186+
<li class="nav-item">
187+
<a class="nav-link disabled" aria-disabled="true">Disabled</a>
188+
</li>
189+
</ul>
190+
{{< /example >}}
191+
171192
### Fill and justify
172193

173194
Force your `.nav`'s contents to extend the full available width one of two modifier classes. To proportionately fill all available space with your `.nav-item`s, use `.nav-fill`. Notice that all horizontal space is occupied, but not every nav item has the same width.

scss/_nav.scss

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
display: flex;
1818
flex-wrap: wrap;
19-
@include ltr-rtl("padding-left", 0);
19+
padding-left: 0;
2020
margin-bottom: 0;
2121
list-style: none;
2222
}
@@ -44,7 +44,8 @@
4444
}
4545

4646
// Disabled state lightens text
47-
&.disabled {
47+
&.disabled,
48+
&:disabled {
4849
color: var(--#{$prefix}nav-link-disabled-color);
4950
pointer-events: none;
5051
cursor: default;
@@ -70,7 +71,6 @@
7071

7172
.nav-link {
7273
margin-bottom: calc(-1 * var(--#{$prefix}nav-tabs-border-width)); // stylelint-disable-line function-disallowed-list
73-
background: none;
7474
border: var(--#{$prefix}nav-tabs-border-width) solid transparent;
7575
@include border-top-radius(var(--#{$prefix}nav-tabs-border-radius));
7676

@@ -80,13 +80,6 @@
8080
isolation: isolate;
8181
border-color: var(--#{$prefix}nav-tabs-link-hover-border-color);
8282
}
83-
84-
&.disabled,
85-
&:disabled {
86-
color: var(--#{$prefix}nav-link-disabled-color);
87-
background-color: transparent;
88-
border-color: transparent;
89-
}
9083
}
9184

9285
.nav-link.active,
@@ -117,15 +110,7 @@
117110
// scss-docs-end nav-pills-css-vars
118111

119112
.nav-link {
120-
background: none;
121-
border: 0;
122113
@include border-radius(var(--#{$prefix}nav-pills-border-radius));
123-
124-
&:disabled {
125-
color: var(--#{$prefix}nav-link-disabled-color);
126-
background-color: transparent;
127-
border-color: transparent;
128-
}
129114
}
130115

131116
.nav-link.active,
@@ -136,6 +121,39 @@
136121
}
137122

138123

124+
//
125+
// Underline
126+
//
127+
128+
.nav-underline {
129+
// scss-docs-start nav-underline-css-vars
130+
--#{$prefix}nav-underline-gap: #{$nav-underline-gap};
131+
--#{$prefix}nav-underline-border-width: #{$nav-underline-border-width};
132+
--#{$prefix}nav-underline-link-active-color: #{$nav-underline-link-active-color};
133+
// scss-docs-end nav-underline-css-vars
134+
135+
gap: var(--#{$prefix}nav-underline-gap);
136+
137+
.nav-link {
138+
padding-right: 0;
139+
padding-left: 0;
140+
border-bottom: var(--#{$prefix}nav-underline-border-width) solid transparent;
141+
142+
&:hover,
143+
&:focus {
144+
border-bottom-color: currentcolor;
145+
}
146+
}
147+
148+
.nav-link.active,
149+
.show > .nav-link {
150+
font-weight: $font-weight-bold;
151+
color: var(--#{$prefix}nav-underline-link-active-color);
152+
border-bottom-color: currentcolor;
153+
}
154+
}
155+
156+
139157
//
140158
// Justified variants
141159
//

scss/_variables.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,10 @@ $nav-tabs-link-active-border-color: var(--#{$prefix}border-color) var(--#{$prefi
12321232
$nav-pills-border-radius: var(--#{$prefix}border-radius) !default;
12331233
$nav-pills-link-active-color: $component-active-color !default;
12341234
$nav-pills-link-active-bg: $component-active-bg !default;
1235+
1236+
$nav-underline-gap: 1rem !default;
1237+
$nav-underline-border-width: .125rem !default;
1238+
$nav-underline-link-active-color: var(--#{$prefix}emphasis-color) !default;
12351239
// scss-docs-end nav-variables
12361240

12371241

0 commit comments

Comments
 (0)