Skip to content

Commit

Permalink
fix(material/form-field): correct color of prefix/suffix text
Browse files Browse the repository at this point in the history
Correct the color of the prefix and suffix text in form fields to align
with MD spec. Set the color of the prefix and suffix text to the same
color as the placeholder. Do this by adding support to form-field for
the input-text-prefix-color and input-text-suffix-color tokens. Then,
set the values of the tokens to the same value as the prefix.

Fix angular#27628
  • Loading branch information
zarend committed Oct 2, 2023
1 parent 47ac55f commit a1a51ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/material/core/tokens/m2/mdc/_filled-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ $prefix: (mdc, filled-text-field);
input-text-color: rgba($on-surface, 0.87),
disabled-input-text-color: rgba($on-surface, 0.38),
input-text-placeholder-color: rgba($on-surface, 0.6),
input-text-prefix-color: rgba($on-surface, 0.6),
input-text-suffix-color: rgba($on-surface, 0.6),

error-focus-label-text-color: $warn-color,
error-label-text-color: $warn-color,
Expand Down
2 changes: 2 additions & 0 deletions src/material/core/tokens/m2/mdc/_outlined-text-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ $prefix: (mdc, outlined-text-field);
input-text-color: rgba($on-surface, 0.87),
disabled-input-text-color: rgba($on-surface, 0.38),
input-text-placeholder-color: rgba($on-surface, 0.6),
input-text-prefix-color: rgba($on-surface, 0.6),
input-text-suffix-color: rgba($on-surface, 0.6),

error-caret-color: $warn-color,
error-focus-label-text-color: $warn-color,
Expand Down
22 changes: 22 additions & 0 deletions src/material/form-field/form-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
tokens-mdc-filled-text-field.get-unthemable-tokens());
@include mdc-filled-text-field-theme.theme-styles(
tokens-mdc-filled-text-field.get-token-slots());
@include token-utils.use-tokens(
tokens-mdc-filled-text-field.$prefix,
tokens-mdc-filled-text-field.get-token-slots()) {
.mat-mdc-form-field-text-prefix {
@include token-utils.create-token-slot(color, input-text-prefix-color);
}

.mat-mdc-form-field-text-suffix {
@include token-utils.create-token-slot(color, input-text-suffix-color);
}
}
}

.mdc-text-field--outlined {
Expand All @@ -64,6 +75,17 @@
tokens-mdc-outlined-text-field.get-unthemable-tokens());
@include mdc-outlined-text-field-theme.theme-styles(
tokens-mdc-outlined-text-field.get-token-slots());
@include token-utils.use-tokens(
tokens-mdc-outlined-text-field.$prefix,
tokens-mdc-outlined-text-field.get-token-slots()) {
.mat-mdc-form-field-text-prefix {
@include token-utils.create-token-slot(color, input-text-prefix-color);
}

.mat-mdc-form-field-text-suffix {
@include token-utils.create-token-slot(color, input-text-suffix-color);
}
}
}
}

Expand Down

0 comments on commit a1a51ff

Please sign in to comment.