Skip to content

Commit

Permalink
fix(material/tabs): deprecate backgroundColor API (#28262)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin authored Dec 11, 2023
1 parent c8ce5f2 commit 771f1df
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 @@ -52,6 +52,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 @@ -201,13 +204,21 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes
@Input({transform: booleanAttribute})
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 @@ -257,6 +257,7 @@ export class MatTabGroup implements AfterContentInit, AfterContentChecked, OnDes
set animationDuration(value: string | number);
// (undocumented)
_animationMode?: string | undefined;
// @deprecated
get backgroundColor(): ThemePalette;
set backgroundColor(value: ThemePalette);
color: ThemePalette;
Expand Down

0 comments on commit 771f1df

Please sign in to comment.