Good morning everyone, I have a problem with shadows on a TouchableOpacity with rounded edges.
I'll insert the code and the result I got
<SafeAreaView>
<ScrollView contentContainerStyle={{flexGrow: 1}}>
<View style={{padding: 20}}>
<TouchableOpacity
style={{
backgroundColor: theme.colors.gold,
width: 150,
height: 150,
borderRadius: 100,
elevation: 5,
}}
/>
</View>
</ScrollView>
</SafeAreaView>
I would expect the shadow to be naturally along the circumference, but in addition to having a different rounding, it is also cut on all four sides.
Thank a lot for helping me
Good morning everyone, I have a problem with shadows on a TouchableOpacity with rounded edges.
I'll insert the code and the result I got
<SafeAreaView>
<ScrollView contentContainerStyle={{flexGrow: 1}}>
<View style={{padding: 20}}>
<TouchableOpacity
style={{
backgroundColor: theme.colors.gold,
width: 150,
height: 150,
borderRadius: 100,
elevation: 5,
}}
/>
</View>
</ScrollView>
</SafeAreaView>
I would expect the shadow to be naturally along the circumference, but in addition to having a different rounding, it is also cut on all four sides.
Thank a lot for helping me
Share Improve this question asked 2 days ago Luca RomanoLuca Romano 1187 bronze badges1 Answer
Reset to default -2It looks like you’re running into a common issue where the shadow (especially on Android) doesn’t appear to match the circular shape of your TouchableOpacity, and also seems to be clipped or cut off. There are a few things you can try:
Ensure Proper Shadow Props (Especially on iOS)
On iOS, the elevation style alone won’t display shadows. You need to use the following shadow props in your style:
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.3,
shadowRadius: 3.84,
These properties work together to produce a smooth shadow. On iOS, elevation does nothing, so it’s important to include these if you want consistent shadows across platforms.
Double Check Your borderRadius
To make a perfect circle with width 150 and height 150, your borderRadius should be half of that dimension (i.e., borderRadius: 75). Although you used 100 (which is bigger than 75), it might still appear circular, but ensuring it’s exactly half helps avoid any unexpected shape quirks. Example:
borderRadius: 75,
Avoid Shadow Clipping by Adjusting Parent Views
Sometimes, parent views have overflow: 'hidden' or simply aren’t large enough to display the full shadow. Make sure that your parent containers (SafeAreaView, ScrollView, and any wrapping View) do not clip the shadow. You can add some extra padding or margin around the TouchableOpacity if the shadow is still getting cut off. For instance:
<View style={{
padding: 20,
// Make sure no overflow clipping
overflow: 'visible'
}}>
...
</View>
Combine Both Android and iOS Shadow Approaches
If you want your component to look the same on both platforms, you’ll need both elevation (for Android) and the shadow properties (for iOS). A combined style might look like:
style={{
backgroundColor: theme.colors.gold,
width: 150,
height: 150,
borderRadius: 75, // half of width/height
elevation: 5, // Android shadow
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.3,
shadowRadius: 3.84,
}}
Test on Real Devices and Emulators
Shadows can look different on various devices. It’s always good to test on an actual Android device and an iOS simulator (or device) to make sure the appearance is consistent with what you expect. In summary, use borderRadius equal to half of your width/height, combine the iOS shadow props with the Android elevation style, and ensure your parent containers aren’t clipping the shadow. This should give you a nice, circular shadow that wraps smoothly around your TouchableOpacity without getting cut off.
Hope this helps you achieve the perfect circular button with a nice shadow!