Skip to content

fix(material/tabs): deprecate backgroundColor API #28262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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