Skip to content

Commit 78e891c

Browse files
committed
fix(material/tabs): deprecate backgroundColor API
1 parent 714eac3 commit 78e891c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/material/tabs/tab-group.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export interface MatTabGroupBaseHeader {
5252
/** Possible positions for the tab header. */
5353
export type MatTabHeaderPosition = 'above' | 'below';
5454

55+
/** Boolean constant that determines whether the tab group supports the `backgroundColor` input */
56+
const ENABLE_BACKGROUND_INPUT = true;
57+
5558
/**
5659
* Material design tab-group component. Supports basic tab pairs (label + content) and includes
5760
* animated ink-bar, keyboard navigation, and screen reader.
@@ -201,13 +204,21 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes
201204
@Input({transform: booleanAttribute})
202205
preserveContent: boolean = false;
203206

204-
/** Background color of the tab group. */
207+
/**
208+
* Background color of the tab group.
209+
* @deprecated The background color should be customized through Sass theming APIs.
210+
* @breaking-change 20.0.0 Remove this input
211+
*/
205212
@Input()
206213
get backgroundColor(): ThemePalette {
207214
return this._backgroundColor;
208215
}
209216

210217
set backgroundColor(value: ThemePalette) {
218+
if (!ENABLE_BACKGROUND_INPUT) {
219+
throw new Error(`mat-tab-group background color must be set through the Sass theming API`);
220+
}
221+
211222
const classList: DOMTokenList = this._elementRef.nativeElement.classList;
212223

213224
classList.remove('mat-tabs-with-background', `mat-background-${this.backgroundColor}`);

tools/public_api_guard/material/tabs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes
257257
set animationDuration(value: string | number);
258258
// (undocumented)
259259
_animationMode?: string | undefined;
260+
// @deprecated
260261
get backgroundColor(): ThemePalette;
261262
set backgroundColor(value: ThemePalette);
262263
color: ThemePalette;

0 commit comments

Comments
 (0)