Skip to content

Commit

Permalink
fix(material/tabs): deprecate backgroundColor API (#28262)
Browse files Browse the repository at this point in the history
(cherry picked from commit 771f1df)
  • Loading branch information
andrewseguin committed Dec 11, 2023
1 parent 2d5f74e commit ac77efd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/material/tabs/tab-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export interface MatTabGroupBaseHeader {
/** Possible positions for the tab header. */
export type MatTabHeaderPosition = 'above' | 'below';

/** Boolean constant that determines whether the tab group supports the `backgroundColor` input */
const ENABLE_BACKGROUND_INPUT = true;

/**
* Material design tab-group component. Supports basic tab pairs (label + content) and includes
* animated ink-bar, keyboard navigation, and screen reader.
Expand Down Expand Up @@ -236,13 +239,21 @@ export class MatTabGroup

private _preserveContent: boolean = false;

/** Background color of the tab group. */
/**
* Background color of the tab group.
* @deprecated The background color should be customized through Sass theming APIs.
* @breaking-change 20.0.0 Remove this input
*/
@Input()
get backgroundColor(): ThemePalette {
return this._backgroundColor;
}

set backgroundColor(value: ThemePalette) {
if (!ENABLE_BACKGROUND_INPUT) {
throw new Error(`mat-tab-group background color must be set through the Sass theming API`);
}

const classList: DOMTokenList = this._elementRef.nativeElement.classList;

classList.remove('mat-tabs-with-background', `mat-background-${this.backgroundColor}`);
Expand Down
1 change: 1 addition & 0 deletions tools/public_api_guard/material/tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export class MatTabGroup extends _MatTabGroupMixinBase implements AfterContentIn
set animationDuration(value: NumberInput);
// (undocumented)
_animationMode?: string | undefined;
// @deprecated
get backgroundColor(): ThemePalette;
set backgroundColor(value: ThemePalette);
get contentTabIndex(): number | null;
Expand Down

0 comments on commit ac77efd

Please sign in to comment.