Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Styling a single word inside a <Text /> element react-native

I'm looking for a way to style a single word (or multiple words) which is inside a <Text> with other words.

Say styling a word in a sentence that is inside <Text>.

Something like this.

"The words i put inside a sentence" (i.e The italics)

I'm currently doing something like

<Text>The words i </Text> <Text style={...}> style inside </Text> <Text> a sentence </Text>

But unfortunately every <Text /> element i add makes a newline effect so it ends up in multiple lines.

How can I accomplish this? Thanks.

like image 319
ArchNoob Avatar asked Apr 19 '26 18:04

ArchNoob


1 Answers

You can do it using Text as a container like the following example

<Text>
  <Text>The words i </Text>
  <Text style={...}> style inside </Text>
  <Text> a sentence </Text>
</Text>
like image 64
Ahmed Ali Avatar answered Apr 21 '26 08:04

Ahmed Ali