Skip to content

Commit ac77efd

Browse files
committed
fix(material/tabs): deprecate backgroundColor API (#28262)
(cherry picked from commit 771f1df)
1 parent 2d5f74e commit ac77efd

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
@@ -69,6 +69,9 @@ export interface MatTabGroupBaseHeader {
6969
/** Possible positions for the tab header. */
7070
export type MatTabHeaderPosition = 'above' | 'below';
7171

72+
/** Boolean constant that determines whether the tab group supports the `backgroundColor` input */
73+
const ENABLE_BACKGROUND_INPUT = true;
74+
7275
/**
7376
* Material design tab-group component. Supports basic tab pairs (label + content) and includes
7477
* animated ink-bar, keyboard navigation, and screen reader.
@@ -236,13 +239,21 @@ export class MatTabGroup
236239

237240
private _preserveContent: boolean = false;
238241

239-
/** Background color of the tab group. */
242+
/**
243+
* Background color of the tab group.
244+
* @deprecated The background color should be customized through Sass theming APIs.
245+
* @breaking-change 20.0.0 Remove this input
246+
*/
240247
@Input()
241248
get backgroundColor(): ThemePalette {
242249
return this._backgroundColor;
243250
}
244251

245252
set backgroundColor(value: ThemePalette) {
253+
if (!ENABLE_BACKGROUND_INPUT) {
254+
throw new Error(`mat-tab-group background color must be set through the Sass theming API`);
255+
}
256+
246257
const classList: DOMTokenList = this._elementRef.nativeElement.classList;
247258

248259
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
@@ -266,6 +266,7 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
266266
set animationDuration(value: NumberInput);
267267
// (undocumented)
268268
_animationMode?: string | undefined;
269+
// @deprecated
269270
get backgroundColor(): ThemePalette;
270271
set backgroundColor(value: ThemePalette);
271272
get contentTabIndex(): number | null;

0 commit comments

Comments
 (0)