Skip to content

Instantly share code, notes, and snippets.

@faustaleonardo
Last active August 3, 2021 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save faustaleonardo/976d266a795b74a958d55f9adad4096d to your computer and use it in GitHub Desktop.
Save faustaleonardo/976d266a795b74a958d55f9adad4096d to your computer and use it in GitHub Desktop.
React Native Styling - Overlay Image
const createStyles = () =>
StyleSheet.create({
image: {
borderRadius: Spacing.tiny,
overflow: "hidden",
position: "relative",
},
overlay: {
position: "absolute",
top: 0,
right: 0,
bottom: 0,
left: 0,
backgroundColor: "gray",
opacity: 0.6,
overflow: "hidden",
borderRadius: Spacing.tiny,
},
});
<View style={styles.image}>
<Image width={158} height={118} source={{ uri: imageUrl }} />
{stockAvailable <= 0 && <View style={styles.overlay} />}
</View>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment