Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elements depth with Polymer - Material Design

In the Material Design spec the depth of the paper items goes from z=0 (dp) to z=24 (dp), but Polymer Elements only use 5 different depths, in pixels.

Is there a way to use the official depth values from the Material Design spec, and do some kind of transformation from the polymer element definition?

One way would be to do again all the CSS for the shadows, but I was hoping for a cleaner solution.

like image 892
tomasyany Avatar asked Jun 18 '26 08:06

tomasyany


1 Answers

There are just 5 predefined styles which are selected by the z attribute (https://github.com/Polymer/paper-shadow/blob/master/paper-shadow.css) This is the example for z=5

html /deep/ .paper-shadow-top-z-5 {
  box-shadow: 0 17px 17px 0 rgba(0, 0, 0, 0.15);
}

html /deep/ .paper-shadow-bottom-z-5 {
  box-shadow: 0 27px 55px 0 rgba(0, 0, 0, 0.3);
}

add a similar style to your page and with a custom suffix instead of 1-5 and then use this suffix as depth. (not tested myself though)

like image 182
Günter Zöchbauer Avatar answered Jun 24 '26 17:06

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!