Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text shadow in react native

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?

like image 926
Luca Romagnoli Avatar asked Sep 24 '17 06:09

Luca Romagnoli


People also ask

How do I shadow text in React Native?

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.

How do I add a shadow effect in React Native?

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.

What is the use of text shadow?

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.


2 Answers

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 } 
like image 179
bennygenel Avatar answered Sep 18 '22 19:09

bennygenel


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      } }); 
like image 31
Rufo Gabrillo Jr Avatar answered Sep 17 '22 19:09

Rufo Gabrillo Jr