angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.34k stars 6.73k forks source link

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

Closed pmpak closed 2 weeks ago

pmpak commented 2 months ago

Is this a regression?

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:

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

crisbeto commented 2 months ago

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

behzadmehrabi commented 2 months ago

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

vulture9 commented 1 month ago

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

aastrouski commented 1 month ago

Doesn't match the spec:

image

andrewseguin commented 2 weeks ago

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