Home > Enterprise >  How to rotate and translate the Text 90 degree correctly in React Native?
How to rotate and translate the Text 90 degree correctly in React Native?

Time:09-28

I am trying to implement this layout enter image description here

Here is my view code snippet

<View style={[{
    flexDirection: 'row',
    backgroundColor: 'white', 
    borderRadius: 8
}]}>

    <Text style={{
        color: 'white',
        backgroundColor: 'red',
        paddingStart: 12,
        paddingEnd: 12,
        transform: [
            { rotate: '-90deg' },
        ]

    }}>{`Sample Text`}</Text>

    <View >

        <Text>Right Content will be here</Text>
    </View>
</View>

Output

enter image description here

The problem of my current implementation are

  • The rotated view is not positioned at positioned
  • The container view's height is not affected with the rotated view's width or height

How can I fix it in a way it could adapt the font size accessibility settings?

CodePudding user response:

You can use a transformation.

enter image description here

  • Related