Ngo Kim Huynh
Ngo Kim Huynh

Reputation: 79

Can we make different style in same text tag in react native?

I have a text like this: User ID: 12345
I want to put it in only a text tag. <Text>UserID: 12345</Text>
But both part will be same style if I do that. So can we make only "UserID" bold?

Upvotes: 2

Views: 2534

Answers (2)

masoud soroush
masoud soroush

Reputation: 677

sure you can use an other tag inside of your tag like this:
UserID: 12345

<Text><Text style={styles.bold}>UserID:</Text> 12345</Text>

var styles = StyleSheet.create({ bold: { fontWeight: 'bold', }, };

Upvotes: 1

Pritish Vaidya
Pritish Vaidya

Reputation: 22209

You can use nested Text in order to do that

    <Text>
        <Text style={{ fontWeight: 'bold' }}>UserID:</Text>12345
    </Text>

Upvotes: 9

Related Questions