Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native: borderRadius and padding styling for nested text

I want to apply a different borderRadius and padding styling to nested texts, but as far as I could understand this is not supported by react native yet. Is there a workaround for this ?

What I tried so far is :

     <Text>
        <Text
          style={{
            backgroundColor: 'green',
            borderRadius: 12,
          }}>
          Text1
        </Text>
        <Text
          style={{
            backgroundColor: 'blue',
            borderRadius: 12,
          }}>
          Text2
        </Text>
      </Text>

Expected Result: Text with different backgrounds and with a borderRadius.

Actual Result: backgrounds are differnet but no borderRadius is applied

like image 540
kendhia Avatar asked Apr 10 '26 04:04

kendhia


1 Answers

You can put this code in the text style

<View
      style={{
        backgroundColor: 'green',
        borderRadius: 10,
        borderWidth: 1,
        borderColor: '#fff',
        padding: 10
      }}>
     <Text>Text1</Text>
    </View>
like image 54
massam Avatar answered Apr 11 '26 19:04

massam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!