in my site i have a title with this text shadow:
h1.title { text-shadow: -1px 1px 10px rgba(0, 0, 0, 0.75) }
<h1 class="title">title</h1>
I want do the same in my react native app.
I've seen the properties:
textShadowColor color textShadowOffset {width: number, height: number} textShadowRadius number
but I don't knows how to have the same effect of html.
How can I do?
To add text shadow in React Native, we can set some text shadow styles. to set the textShadowColor to the text shadow color. We set textShadowOffset to add depth to the shadow. And we set textShadowRadius to set the shadow radius.
For adding box shadows in Android, we can use the elevation prop, which uses the Android Elevation API. Next, import the StyleSheet again to style the card: // remember to import StyleSheet from react-native const styles = StyleSheet.
The text-shadow CSS property adds shadows to text. It accepts a comma-separated list of shadows to be applied to the text and any of its decorations . Each shadow is described by some combination of X and Y offsets from the element, blur radius, and color.
CSS text-shadow has the below syntax,
text-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit;
To achieve similar effect with the css you provided you can use something like this,
// text-shadow: -1px 1px 10px rgba(0, 0, 0, 0.75) { textShadowColor: 'rgba(0, 0, 0, 0.75)', textShadowOffset: {width: -1, height: 1}, textShadowRadius: 10 }
I tried sir bennygenel's answer and it worked. I used it something like this...
<View> <Text style={styles.textWithShadow}>Hello world</Text> </View>
.....
const styles = StyleSheet.create({ textWithShadow:{ textShadowColor: 'rgba(0, 0, 0, 0.75)', textShadowOffset: {width: -1, height: 1}, textShadowRadius: 10 } });
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