components icon indicating copy to clipboard operation
components copied to clipboard

bug(mat-divider): Incorrect color token on Material 3 Theme

Open pmpak opened this issue 1 year ago • 2 comments
trafficstars

Is this a regression?

  • [X] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

18.0.x

Description

In Angular Material 18.1.x, when using a Material 3 theme, the mat-divider component uses the outline token instead of the outline-variant as specified by the Material 3 guidelines. This change caused sections in our application to appear more prominent than expected. Additionally, this creates inconsistency in places where we combine custom styles that set the color of outlines by using the outline-variant role from the theme, and also have mat-dividers within.

I understand that the change from #28995 is to achieve better color contrast. However, this deviates from the specification, which explains that dividers are decorative elements and have no minimum contrast requirements.

https://m3.material.io/components/divider/accessibility https://m3.material.io/components/divider/specs#f7d1605e-1629-404c-86a5-0ef6848ce520 image

A potential workaround can be to use the --mat-divider-color property and set color to the outline-variant token, but it would be nice if there is no need for style changes.

Reproduction

StackBlitz links:

  • Angular Material 18.1.x: https://stackblitz.com/edit/mwztdu?file=package.json
  • Angular Material 18.0.x: https://stackblitz.com/edit/mwztdu-iaag8z?file=package.json

Steps to reproduce:

  1. Open the example using Angular Material 18.1.x. Observe that the dividers take their color from the outline token.
  2. Open the example using Angular Material 18.0.x. Observe that the dividers take their color from the outline-variant token.

Expected Behavior

Divider uses the outline-variant color token

Actual Behavior

Divider uses the outline color token

Environment

Angular CLI: 18.1.2 Node: 18.20.3 Package Manager: yarn 1.22.19 OS: linux x64

Angular: 18.1.2 ... animations, cdk, cli, common, compiler, compiler-cli, core ... forms, localize, material, material-experimental ... material-moment-adapter, platform-browser ... platform-browser-dynamic, router

Package Version

@angular-devkit/architect 0.1801.2 @angular-devkit/build-angular 18.1.2 @angular-devkit/core 18.1.2 @angular-devkit/schematics 18.1.2 @schematics/angular 18.1.2 rxjs 7.4.0 typescript 5.4.5 zone.js 0.14.6

pmpak avatar Jul 26 '24 19:07 pmpak

Sounds like it's due to #28995 cc @DBowen33 and @andrewseguin

crisbeto avatar Jul 26 '24 20:07 crisbeto

Faced the same issue. I think the divider color is just way too dark and doesn't match the spec.

behzadmehrabi avatar Aug 14 '24 07:08 behzadmehrabi

Yes correct current divider match color 'outline' where according to specs should be outline-variant

vulture9 avatar Sep 09 '24 11:09 vulture9

Doesn't match the spec:

image

aastrouski avatar Sep 16 '24 13:09 aastrouski

It's true that the divider no longer matches the spec. However this is because the spec is out of date with internal Google guidelines that govern contrast ratios for non-text elements. This change to darken the outline was made to ensure the divider is accessible for all users. The workaround of overriding the divider is recommended if it appears too dark in your application

andrewseguin avatar Oct 02 '24 19:10 andrewseguin

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.