Generate React Native shadow styles that look the same on iOS and Android. Set an Android elevation and the matching iOS shadowOffset, shadowRadius and shadowOpacity are filled in for you, then fine-tune them and pick a shadow color. Copy a StyleSheet snippet, the boxShadow string for React Native 0.76+, or the web CSS equivalent. It's free, runs in your browser, and nothing is uploaded.
| Elevation | height | shadowRadius | shadowOpacity |
|---|---|---|---|
| 1 | 0 | 0.54 | 0.18 |
| 2 | 1 | 1.08 | 0.18 |
| 4 | 2 | 2.16 | 0.19 |
| 8 | 4 | 4.32 | 0.19 |
| 12 | 6 | 6.48 | 0.20 |
| 24 | 12 | 12.96 | 0.22 |
Classic Android shadows only come from elevation, and the view needs a background color. shadowColor and shadowOffset are ignored there.
Set the elevation here; the iOS values are calculated from it with the common approximation, then you can adjust them.
From React Native 0.76 with the New Architecture, a CSS-style boxShadow works on both platforms. Older versions need the platform-specific props.
overflow: 'hidden' on the same view clips the shadow. Put the shadow on a wrapper view.
No. The styles are generated in your browser.
React Native has historically drawn shadows differently on each platform. iOS uses four props — shadowColor, shadowOffset, shadowOpacity and shadowRadius — while Android uses a single elevation number that the system turns into a Material shadow, ignoring color, offset and opacity. To keep the two looking alike, the generator starts from the Android elevation and derives iOS values with the approximation widely used in the React Native community: a vertical offset of about half the elevation, a radius of about 0.54 times it, and opacity rising slowly from 0.18. The iOS values can then be fine-tuned independently. React Native 0.76 and later, on the New Architecture, also accept a CSS-style boxShadow string that renders the same on both platforms, so that form is generated too, along with the plain web CSS for React Native Web or a design handoff. The preview approximates the iOS shadow with CSS.