Skip to content

Commit dd005df

Browse files
asyncLizcopybara-github
authored andcommitted
fix(tabs): allow changing tab padding
PiperOrigin-RevId: 577030425
1 parent f5daadc commit dd005df

File tree

2 files changed

+28
-37
lines changed

2 files changed

+28
-37
lines changed

tabs/internal/_tab.scss

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@
1818
@mixin styles() {
1919
:host {
2020
display: inline-flex;
21+
align-items: center;
22+
justify-content: center;
2123
outline: none;
24+
padding: 0 16px;
25+
position: relative;
2226
-webkit-tap-highlight-color: transparent;
2327
vertical-align: middle;
2428
user-select: none;
29+
font-family: var(--_label-text-font);
30+
font-size: var(--_label-text-size);
31+
line-height: var(--_label-text-line-height);
32+
font-weight: var(--_label-text-weight);
33+
color: var(--_label-text-color);
34+
z-index: 0; // Ensure this is a stacking context so the indicator displays
2535

2636
@include ripple.theme(
2737
(
@@ -45,24 +55,6 @@
4555
margin-bottom: calc(var(--_active-indicator-height) + 1px);
4656
}
4757

48-
.button {
49-
box-sizing: border-box;
50-
display: inline-flex;
51-
align-items: center;
52-
justify-content: center;
53-
vertical-align: middle;
54-
width: 100%;
55-
position: relative;
56-
padding: 0 16px;
57-
margin: 0;
58-
z-index: 0; // Ensure this is a stacking context so the indicator displays
59-
font-family: var(--_label-text-font);
60-
font-size: var(--_label-text-size);
61-
line-height: var(--_label-text-line-height);
62-
font-weight: var(--_label-text-weight);
63-
color: var(--_label-text-color);
64-
}
65-
6658
.button::before {
6759
background: var(--_container-color);
6860
content: '';
@@ -105,7 +97,7 @@
10597
}
10698

10799
// unselected states
108-
.button ::slotted([slot='icon']) {
100+
::slotted([slot='icon']) {
109101
display: inline-flex;
110102
position: relative;
111103
writing-mode: horizontal-tb;
@@ -116,37 +108,36 @@
116108
height: var(--_icon-size);
117109
}
118110

119-
.button:hover {
111+
:host(:hover) {
120112
color: var(--_hover-label-text-color);
121113
cursor: pointer;
122114
}
123115

124-
.button:hover ::slotted([slot='icon']) {
116+
:host(:hover) ::slotted([slot='icon']) {
125117
color: var(--_hover-icon-color);
126118
}
127119

128-
.button:focus {
120+
:host(:focus) {
129121
color: var(--_focus-label-text-color);
130122
}
131123

132-
.button:focus ::slotted([slot='icon']) {
124+
:host(:focus) ::slotted([slot='icon']) {
133125
color: var(--_focus-icon-color);
134126
}
135127

136-
.button:active {
128+
:host(:active) {
137129
color: var(--_pressed-label-text-color);
138-
outline: none;
139130
}
140131

141-
.button:active ::slotted([slot='icon']) {
132+
:host(:active) ::slotted([slot='icon']) {
142133
color: var(--_pressed-icon-color);
143134
}
144135

145136
// selected styling
146137
:host([active]) .indicator {
147138
opacity: 1;
148139
}
149-
:host([active]) .button {
140+
:host([active]) {
150141
color: var(--_active-label-text-color);
151142
@include elevation.theme(
152143
(
@@ -164,32 +155,32 @@
164155
);
165156
}
166157

167-
:host([active]) .button ::slotted([slot='icon']) {
158+
:host([active]) ::slotted([slot='icon']) {
168159
color: var(--_active-icon-color);
169160
}
170161

171162
// selected states
172-
:host([active]) .button:hover {
163+
:host([active]:hover) {
173164
color: var(--_active-hover-label-text-color);
174165
}
175166

176-
:host([active]) .button:hover ::slotted([slot='icon']) {
167+
:host([active]:hover) ::slotted([slot='icon']) {
177168
color: var(--_active-hover-icon-color);
178169
}
179170

180-
:host([active]) .button:focus {
171+
:host([active]:focus) {
181172
color: var(--_active-focus-label-text-color);
182173
}
183174

184-
:host([active]) .button:focus ::slotted([slot='icon']) {
175+
:host([active]:focus) ::slotted([slot='icon']) {
185176
color: var(--_active-focus-icon-color);
186177
}
187178

188-
:host([active]) .button:active {
179+
:host([active]:active) {
189180
color: var(--_active-pressed-label-text-color);
190181
}
191182

192-
:host([active]) .button:active ::slotted([slot='icon']) {
183+
:host([active]:active) ::slotted([slot='icon']) {
193184
color: var(--_active-pressed-icon-color);
194185
}
195186

tabs/internal/tab.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
queryAssignedNodes,
1717
state,
1818
} from 'lit/decorators.js';
19-
import {classMap} from 'lit/directives/class-map.js';
19+
import {ClassInfo, classMap} from 'lit/directives/class-map.js';
2020

2121
import {
2222
polyfillARIAMixin,
@@ -105,7 +105,7 @@ export class Tab extends tabBaseClass {
105105

106106
protected override render() {
107107
const indicator = html`<div class="indicator"></div>`;
108-
return html` <div
108+
return html`<div
109109
class="button"
110110
role="presentation"
111111
@click=${this.handleContentClick}>
@@ -123,7 +123,7 @@ export class Tab extends tabBaseClass {
123123
</div>`;
124124
}
125125

126-
protected getContentClasses() {
126+
protected getContentClasses(): ClassInfo {
127127
return {
128128
'has-icon': this.hasIcon,
129129
'has-label': !this.iconOnly,

0 commit comments

Comments
 (0)