React Native add bold or italics to single words in field

后端 未结 12 2604
攒了一身酷
攒了一身酷 2020-12-13 05:14

How do I make a single word in a Text field bold or italics? Kind of like this:

This is a sentence with one word in bold         


        
12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 05:59

    Nesting Text components is not possible now, but you can wrap your text in a View like this:

    
        
            {'Hello '}
        
        
            {'this is a bold text '}
        
        
            and this is not
        
    
    

    I used the strings inside the brackets to force the space between words, but you can also achieve it with marginRight or marginLeft. Hope it helps.

提交回复
热议问题