Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 5.14 KB

Shadows.md

File metadata and controls

22 lines (15 loc) · 5.14 KB

Comparison of the Shadow blur/radius property across platforms

The shadow blur-radius property on Web, shadowRadius property on Apple platforms (iOS/macOS), and elevation property on Android all affect how blurred out the edges of a shadow look. However, they each affect the resulting shadow differently, and setting the same value for each of these will not result in a shadow that looks the same across platforms.

Convention

If you are working with shadowRadius on an Apple platform trying to align with designs made with a web tool (like Figma or Sketch), divide the blur by 2. This applies to React Native as well. This applies to these platforms on React Native as well (React Native, React Native macOS, and React Native Web)

Rationale

We compared how shadows are rendered across different platforms, and found a discrepancy in how blur is handled. For whatever reason, dividing the blur by 2 is necessary to have the correct effect on Apple platforms. See the table below:

Platform + Notes Code Screenshot
Web: CSS

box-shadow documentation, also can try out shadows here
Screen Shot 2022-09-07 at 1 11 53 PM Shadow blur = 100 Screen Shot 2022-09-06 at 1 34 55 PM
Web: Figma

Figma uses the same shadow blur property as web
Screen Shot 2022-09-07 at 12 31 38 PM Screen Shot 2022-09-06 at 1 48 25 PM
Web: React Native Web

React Native shadowRadius documentation here, CSS shadow blur documentation here, also can test shadows with this snack. Uses shadowRadius, which ends up being the same as the blur property (don't need to /2)
Screen Shot 2022-09-07 at 1 43 41 PM Screen Shot 2022-09-06 at 1 47 08 PM
Apple: React Native iOS

React Native shadowRadius documentation here, native Apple shadowRadius documentation here, also can test shadows with this snack. In order to get Apple shadows to look the same as Figma, shadowRadius should be blur/2.
Screen Shot 2022-09-07 at 1 43 41 PM Screen Shot 2022-09-07 at 1 45 45 PM Screen Shot 2022-09-06 at 1 45 54 PM Screen Shot 2022-09-06 at 2 02 50 PM
Apple: Native macOS

shadowBlurRadius documentation
NativeMacOS_100 NativeMacOS_50 NativeMacOS_100_screenshot NativeMacOS_50_screenshot
Android: React Native Android

Can test shadows with this snack. Uses elevation, which is just different from both how web/iOS handle shadows
Screen Shot 2022-09-07 at 1 42 18 PM Screen Shot 2022-09-06 at 1 46 26 PM