angular / components

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

feat(core): Expose SCSS breakpoints #25923

Open MikaStark opened 1 year ago

MikaStark commented 1 year ago

Feature Description

As @angular/flex-layout become deprecated and Angular team does not intend to provide an alternative, we are forced to handle responsive layout by our own.

Writing CSS is ok, but to stick with Material design guidance we must use specific breakpoints. It would be great if @angular/material could expose these breakpoints like it does for palettes and theming. Otherwise we have to declare them ourself for every projects.

Use Case

would simplify scss writting and add opinions about breakpoints (like CDK Layout API)

@use '@angular/material' as mat;

@media #{$mat.gt-xs} {
  // insert your styles
}
crisbeto commented 1 year ago

As far as I can tell, the Material design spec doesn't mention specific breakpoints so anything we provide would be arbitrary.

MikaStark commented 1 year ago

@crisbeto sorry but in fact it did here : https://m2.material.io/design/layout/responsive-layout-grid.html#breakpoints

dhdaines commented 1 year ago

This would be super nice, I have inherited a project that has a mystery "$toolbar-breakpoint: 600px" in it to cope with the fact that a mat-toolbar magically shrinks its height at 600 pixels. Grepping in node_modules is not a substitute for documentation.

dhdaines commented 1 year ago

also it's really fun that these breakpoints are not the same as the ones in bootstrap SCSS, for instance: https://getbootstrap.com/docs/5.0/layout/breakpoints/

msrumon commented 1 year ago

+1. Coming from #3606. We already have the full list here at src/cdk/layout/breakpoints.ts - just publish them as SASS variables and we'll be more than happy.