Skip to content

Commit fbcd237

Browse files
committed
fix(material/tabs): add header divider for m3 (#28244)
* fix(material/tabs): add header divider for m3 * fix(material/tabs): fix inverted header (cherry picked from commit cb9c222)
1 parent a229002 commit fbcd237

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

src/dev-app/tabs/tabs-demo.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ <h3>Inverted Tabs</h3>
2626
<tab-group-inverted-example></tab-group-inverted-example>
2727
<h3>Ink bar fit to content</h3>
2828
<tab-group-ink-bar-example></tab-group-ink-bar-example>
29+
<h3>Tab group with the headers on the bottom</h3>
30+
<tab-group-header-below-example></tab-group-header-below-example>

src/material-experimental/theming/_custom-tokens.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,8 @@
509509
@return mat.private-merge-all(
510510
_generate-typography-tokens($systems, label-text, title-small),
511511
(
512+
divider-color: map.get($systems, md-sys-color, surface-variant),
513+
divider-height: 1px,
512514
disabled-ripple-color: null, // TODO(mmalerba): Figure out correct value.
513515
pagination-icon-color: map.get($systems, md-sys-color, on-surface),
514516
inactive-label-text-color: map.get($systems, md-sys-color, on-surface),

src/material/core/tokens/m2/mat/_tab-header.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ $prefix: (mat, tab-header);
88
// Tokens that can't be configured through Angular Material's current theming API,
99
// but may be in a future version of the theming API.
1010
@function get-unthemable-tokens() {
11-
@return ();
11+
@return (
12+
// For some period of time, the MDC tabs removed the divider. This has been added back in
13+
// and will be present in M3.
14+
divider-color: transparent,
15+
divider-height: 0,
16+
);
1217
}
1318

1419
// Tokens that can be configured through Angular Material's color theming API.

src/material/tabs/_tabs-common.scss

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,30 @@ $mat-tab-animation-duration: 500ms !default;
338338
}
339339

340340
// Structural styles for the element that wraps the paginated container's content.
341-
@mixin paginated-tab-header-container {
341+
// Include a selector for an inverted header if the header may be optionally positioned on the
342+
// bottom of the content.
343+
@mixin paginated-tab-header-container($inverted-header-selector: null) {
342344
display: flex;
343345
flex-grow: 1;
344346
overflow: hidden;
345347
z-index: 1;
348+
@include token-utils.use-tokens(
349+
tokens-mat-tab-header.$prefix,
350+
tokens-mat-tab-header.get-token-slots()
351+
) {
352+
border-bottom-style: solid;
353+
@include token-utils.create-token-slot(border-bottom-width, divider-height);
354+
@include token-utils.create-token-slot(border-bottom-color, divider-color);
355+
356+
@if ($inverted-header-selector) {
357+
#{$inverted-header-selector} & {
358+
border-bottom: none;
359+
border-top-style: solid;
360+
@include token-utils.create-token-slot(border-top-width, divider-height);
361+
@include token-utils.create-token-slot(border-top-color, divider-color);
362+
}
363+
}
364+
}
346365
}
347366

348367
@mixin paginated-tab-header-with-background($header-selector, $tab-selector) {

src/material/tabs/tab-header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@include tabs-common.paginated-tab-header;
55

66
.mat-mdc-tab-label-container {
7-
@include tabs-common.paginated-tab-header-container;
7+
@include tabs-common.paginated-tab-header-container('.mat-mdc-tab-group-inverted-header');
88
}
99

1010
.mat-mdc-tab-labels {

0 commit comments

Comments
 (0)