Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In React Native, how can I flip a View horizontally?

Suppose I have an icon like this:

<FontAwesome
    name={'column'}
    size={20}
    style={ /* mirror horizontally */ }
/>

How can I mirror this horizontally?

like image 569
TIMEX Avatar asked Jan 31 '26 01:01

TIMEX


2 Answers

React-native uses an array of transforms according to the docs, the scaleX prop has been deprecated. You can scale transform on the x-axis by the inverse:

style={{
  transform: [
    { scaleX: -1 }
  ]
}}
like image 92
Drew Reese Avatar answered Feb 02 '26 15:02

Drew Reese


2 way that you may use to flip or reverse the view of the component through style

fontAwesomeStyle: {
  transform: [
    {rotateX: '180deg'}, //horizontally
    {rotateY: '180deg'} //vertically
    {scaleX: -1} //horizontally
    {scaleY: -1} //vertically
  ]
}

but I prefer to use rotate it's because being convenient in terms of animating

like image 28
Maker Avatar answered Feb 02 '26 15:02

Maker



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!