material-components / material-web

Material Design Web Components
https://material-web.dev
Apache License 2.0
8.96k stars 844 forks source link

Support Material Density #841

Open dfreedm opened 4 years ago

dfreedm commented 4 years ago

The MDC Density system currently relies completely on Sass mixins, which is not compatible with how we are using the Sass with Web Components.

We need to provide a way to do this via CSS Custom Properties, or a theming system.

TomzBench commented 4 years ago
@use "@material/button";

.my-custom-button {
  // Sets button density scale to `-3`, i.e. button height to `24px`.
  @include button.density(-3);
}

Is it possible to pass through this API? I tried that before reaching here and am blocked by the shadowroot. However, if I can passthrough my styles to the shadow root styles as a work around?

If the base class had a method to merge the component static styles property then wouldnt the mwc density API work?

asyncLiz commented 4 years ago

It's not possible to use MDC's sass density mixins with MWC. We're actively working on a solution though!

TomzBench commented 4 years ago

Will the solution allow using MDC sass mixins with MWC?

Or is the solution going to be wrapping all of MDC functionality with a unique wrapper API? I vote for the former!

yinonov commented 4 years ago

Where does this stand? Density is a fundamental abstraction in our branding identity. Would love to be able to control it with a high level variable

asyncLiz commented 4 years ago

It's planned out, but a few things have slipped behind due to the COVID situation. This should be coming soon though after some theming work.

maicol07 commented 3 years ago

It has been almost 1 year since the last update. Is it coming soon?

Daymannovaes commented 3 years ago

Me too. I constantly rely on the use-case of an mwc-button with a different height.

lsatheeshkumar commented 3 years ago

An update on this would be of great help.

aress31 commented 3 years ago

+1

JamesODonoghue commented 3 years ago

We are also looking forward to this support.

Any updates would be greate

milesje commented 2 years ago

Any update on this???

asyncLiz commented 2 years ago

Density support is slowly being added as components' theming capabilities are being updated. <mwc-switch> is a good first example:

@use '@material/mwc-switch';

mwc-switch.dense {
  @include mwc-switch.theme(mwc-switch.density(-1));
}

Generates:

mwc-switch.dense {
  --mdc-switch-state-layer-size: 44px;
}