Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve Font Awesome stack icons feature in react native

Achieving Stack/Overlap Icons using React native.

I am trying to achieve something like this in react native: https://fontawesome.com/how-to-use/on-the-web/styling/stacking-icons

how to achieve this?

like image 387
Naidu A Avatar asked Aug 29 '19 00:08

Naidu A


People also ask

How do I stack Font Awesome icons?

To stack multiple icons, use the fa-stack class on the parent HTML element of the 2 icons you want to stack. Then add the fa-stack-1x class for the regularly sized icon and add the fa-stack-2x class for the larger icon. fa-inverse can be added to the icon with the fa-stack-1x to help with a knock-out looking effect.

How do I get Font Awesome icons in react-native?

Use of Font-Awesome Icon in React Native You can apply styles directly into the FontAwesome RN component by just passing a style as you do in a <Text> component. You need to pass the icon name which you can get from the Official Site.


1 Answers

You can achieve this by doing it like this. Using width and height helps you keep the view in place and aligning everything to the center so it looks nice like stacked icons.enter image description here

<View style={{
        position:"relative",
        justifyContent:'center',
        alignItems:"center",
        width:40,
        height:40
      }}>
         <Icon name="circle" size={34} color={"black"} />
         <Icon name="flag" size={20} color={"white"} style={{position: 'absolute', zIndex: 99}} />  
      </View>

https://snack.expo.io/HkxWerHBr

like image 167
Ammar Ahmed Avatar answered Sep 19 '22 13:09

Ammar Ahmed