File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
src/material-experimental/mdc-form-field Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change 84
84
85
85
// For the outline appearance, we re-create the active floating label transform. This is
86
86
// necessary because the transform for docked floating labels can be updated to account for
87
- // the width of prefix container. We need to re-create these styles with `!important` because
88
- // the horizontal adjustment for the label is applied through inline styles, and we want to
89
- // make sure that the label can still float as expected. It should be okay using `!important`
90
- // because it's unlikely that developers commonly overwrite the floating label transform.
87
+ // the width of prefix container.
91
88
.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mdc-notched-outline--upgraded
92
89
.mdc-floating-label--float-above {
93
- $outlined-label-floating-position-y : mdc-textfield .get-outlined-label-position-y ($height );
94
- // This transform has been extracted from the MDC text-field styles. We can't access it
95
- // through a variable because MDC generates this label transform through a mixin.
96
- transform : translateY (- $outlined-label-floating-position-y ) scale (0.75 ) !important ;
90
+ --mat-mdc-form-field-label-transform : translateY (
91
+ - #{mdc-textfield .get-outlined-label-position-y ($height )} ) scale (0.75 );
92
+ transform : var (--mat-mdc-form-field-label-transform );
97
93
}
98
94
99
95
// Add vertical spacing to the infix to ensure that outlined form fields have their controls
Original file line number Diff line number Diff line change @@ -668,9 +668,13 @@ export class MatFormField
668
668
( ( iconPrefixContainer ? iconPrefixContainerWidth - WRAPPER_HORIZONTAL_PADDING : 0 ) +
669
669
textPrefixContainerWidth ) ;
670
670
671
- // Update the transform the floating label to account for the prefix container. Note
672
- // that we do not want to overwrite the default transform for docked floating labels.
673
- floatingLabel . style . transform = `${ FLOATING_LABEL_DEFAULT_DOCKED_TRANSFORM } translateX(${ labelHorizontalOffset } px)` ;
671
+ // Update the translateX of the floating label to account for the prefix container,
672
+ // but allow the CSS to override this setting via a CSS variable when the label is
673
+ // floating.
674
+ floatingLabel . style . transform = `var(
675
+ --mat-mdc-form-field-label-transform,
676
+ ${ FLOATING_LABEL_DEFAULT_DOCKED_TRANSFORM } translateX(${ labelHorizontalOffset } px
677
+ )` ;
674
678
}
675
679
676
680
/** Checks whether the form field is attached to the DOM. */
You can’t perform that action at this time.
0 commit comments