material-web icon indicating copy to clipboard operation
material-web copied to clipboard

Support Material Density

Open dfreedm opened this issue 4 years ago • 12 comments

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.

dfreedm avatar Feb 05 '20 23:02 dfreedm

@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?

TomzBench avatar Mar 13 '20 16:03 TomzBench

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

asyncLiz avatar Mar 13 '20 16:03 asyncLiz

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!

TomzBench avatar Mar 13 '20 17:03 TomzBench

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

yinonov avatar May 21 '20 03:05 yinonov

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.

asyncLiz avatar May 21 '20 16:05 asyncLiz

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

maicol07 avatar Feb 09 '21 12:02 maicol07

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

Daymannovaes avatar Feb 10 '21 21:02 Daymannovaes

An update on this would be of great help.

lsatheeshkumar avatar Mar 17 '21 05:03 lsatheeshkumar

+1

aress31 avatar Mar 17 '21 07:03 aress31

We are also looking forward to this support.

Any updates would be greate

JamesODonoghue avatar Apr 13 '21 22:04 JamesODonoghue

Any update on this???

milesje avatar Aug 05 '21 15:08 milesje

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;
}

asyncLiz avatar Aug 06 '21 21:08 asyncLiz