diff --git a/src/material-experimental/mdc-form-field/_form-field-density.scss b/src/material-experimental/mdc-form-field/_form-field-density.scss index 61e9785284b2..2f75b9942faa 100644 --- a/src/material-experimental/mdc-form-field/_form-field-density.scss +++ b/src/material-experimental/mdc-form-field/_form-field-density.scss @@ -88,7 +88,8 @@ .mat-mdc-text-field-wrapper.mdc-text-field--outlined .mdc-notched-outline--upgraded .mdc-floating-label--float-above { --mat-mdc-form-field-label-transform: translateY( - -#{mdc-textfield.get-outlined-label-position-y($height)}) scale(0.75); + -#{mdc-textfield.get-outlined-label-position-y($height)}) + scale(var(--mat-mdc-form-field-floating-label-scale, 0.75)); transform: var(--mat-mdc-form-field-label-transform); } diff --git a/src/material-experimental/mdc-form-field/_form-field-theme.scss b/src/material-experimental/mdc-form-field/_form-field-theme.scss index 0675714d9e29..2ebb598fec08 100644 --- a/src/material-experimental/mdc-form-field/_form-field-theme.scss +++ b/src/material-experimental/mdc-form-field/_form-field-theme.scss @@ -89,7 +89,8 @@ // For the non-upgraded notch label (i.e. when rendered on the server), also // use the correct `body1` typography level. .mdc-floating-label--float-above { - font-size: mdc-typography.get-size(body1) * 0.75; + font-size: calc(#{ + mdc-typography.get-size(body1)} * var(--mat-mdc-form-field-floating-label-scale, 0.75)); } .mdc-notched-outline--upgraded .mdc-floating-label--float-above { font-size: mdc-typography.get-size(body1); diff --git a/src/material-experimental/mdc-form-field/directives/notched-outline.ts b/src/material-experimental/mdc-form-field/directives/notched-outline.ts index 2270734aad67..dcca4f417c7a 100644 --- a/src/material-experimental/mdc-form-field/directives/notched-outline.ts +++ b/src/material-experimental/mdc-form-field/directives/notched-outline.ts @@ -35,8 +35,8 @@ import { encapsulation: ViewEncapsulation.None, }) export class MatFormFieldNotchedOutline implements AfterViewInit { - /** Width of the notch. */ - @Input('matFormFieldNotchedOutlineWidth') width: number = 0; + /** Width of the label (original scale) */ + @Input('matFormFieldNotchedOutlineLabelWidth') labelWidth: number = 0; /** Whether the notch should be opened. */ @Input('matFormFieldNotchedOutlineOpen') open: boolean = false; @@ -62,7 +62,9 @@ export class MatFormFieldNotchedOutline implements AfterViewInit { _getNotchWidth() { if (this.open) { const NOTCH_ELEMENT_PADDING = 8; - return `${this.width > 0 ? this.width + NOTCH_ELEMENT_PADDING : 0}px`; + return this.labelWidth > 0 + ? `calc(${this.labelWidth}px * var(--mat-mdc-form-field-floating-label-scale, 0.75) + ${NOTCH_ELEMENT_PADDING}px)` + : '0px'; } return null; diff --git a/src/material-experimental/mdc-form-field/form-field.html b/src/material-experimental/mdc-form-field/form-field.html index 644d9c951a0f..12a3f43e6585 100644 --- a/src/material-experimental/mdc-form-field/form-field.html +++ b/src/material-experimental/mdc-form-field/form-field.html @@ -46,7 +46,7 @@