Skip to content

Allow palettes to specify a separate hue for uncontained text #15148

@benelliott

Description

@benelliott

Please describe the feature you would like to request.

There is a lot of emphasis on making sure that you choose accessible text colors to ensure readability when your palette color is used in the background but there is no such concern when your palette color itself is used as the text color on a neutral background. This is exacerbated by the fact that @angular/material components will implicitly use the default hue of the palette when selecting this text color - for example in _form-field_theme.scss:

$focused-label-color: mat-color($primary);

it's very hard to pick a palette whose primary is effective both as a strong background color and as a strong text color for small text on a neutral background and conforms to any existing brand guidelines.

One way to fix this would be to extend mat-palette with a fourth argument, $text. For compatibility it could default to $default if not specified, but this would allow you to use a much darker hue on form field labels and so on without making primary backgrounds darker everywhere else.

You can quite easily see the accessibility issues with the current system with some of the prepackaged themes. For instance setting the theme to purple-green on https://material.angular.io/components/form-field/examples gives a contrast ratio of 2.09 for the form field inputs.

What is the use-case or motivation for this proposal?

Improves accessibility

Is there anything else we should know?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    AccessibilityThis issue is related to accessibility (a11y)P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentfeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions