I can't seem to find any official CSS code for all the box-shadows for elevation of cards for Material Design.
Calculating shadow values for all Material Design elevations
I've read these answers but they don't align with the box-shadow that Google is using on their search box on http://www.google.com when I do a quick inspection.
The box-shadow that Google is using on the search box is this CSS:
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
Is there an official CSS for all elevations?
Elevation (Android) Elevation is the relative depth, or distance, between two surfaces along the z-axis. Specifications: Elevation is measured in the same units as the x and y axes, typically in density-independent pixels (dp).
the mat-elevation-z8 class is an Angular Material elevation class that allows you to add separation between elements along the z-axis.
A dp is equal to one physical pixel on a screen with a density of 160. To calculate dp: dp = (width in pixels * 160) / screen density.
According to https://material.io/design/environment/elevation.html by Google , Cards should have an elevation of 2dp when resting and 8dp when raised.
And according to https://pixplicity.com,
ldpi @ 1.00dp = 0.75px = 1.00sp = 0.16mm = 0.01in = 0.45pt
mdpi @ 1.00dp = 1.00px = 1.00sp = 0.16mm = 0.01in = 0.45pt
tvdpi @ 1.00dp = 1.33px = 1.00sp = 0.16mm = 0.01in = 0.45pt
hdpi @ 1.00dp = 1.50px = 1.00sp = 0.16mm = 0.01in = 0.45pt
xhdpi @ 1.00dp = 2.00px = 1.00sp = 0.16mm = 0.01in = 0.45pt
xxhdpi @ 1.00dp = 3.00px = 1.00sp = 0.16mm = 0.01in = 0.45pt
xxxhdpi @ 1.00dp = 4.00px = 1.00sp = 0.16mm = 0.01in = 0.45pt
Try using these conversions to get the box shadow size in css.
Note: On desktop, the resting elevation is 0dp
here you can find official guide for elevation: https://material.io/develop/web/components/elevation/
There is a library of styles you can install it like that: npm install @material/elevation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With