Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make some part of text clickable and some part having different text color in react-native

I am trying to make some portion of text of different color and clickable

Here is my code:

<Text style = {styles.term_service}>By signing up, you agree to Terms of Service and Privacy Policy.</Text>

I want to make Terms of Service and Privacy Policy clickable and have different color.

like image 294
Mohd Shahzad Avatar asked Sep 22 '17 11:09

Mohd Shahzad


People also ask

How do you change the color of text in React Native?

To set text color in React, we can set the style prop to an object with the color property. to set the style prop of the h1 element to an object that has the color property set to 'red' . Now we should see that the color of the text is red.

How do you break text in React Native?

To insert a line break into a Text component in React Native, we can add the '\n' character string. to add {'\n'} into the content of Text .

How do you bold specific text in a string in a react JS app?

Use inline styles to bold specific text in React. js, e.g. <span style={{fontWeight: 'bold'}}>world</span> . The bold font will only be applied to the element to which it was added and its children.


1 Answers

you can use nested text doc also Text accept onPress doc

<Text style = {styles.term_service}>By signing up, you agree to Terms of Service and <Text onPress={()=> someAction()} style = {{ color: '#fff' }}>Privacy Policy.</Text></Text>
like image 189
Mohamed Khalil Avatar answered Oct 04 '22 00:10

Mohamed Khalil