React-native-vector-icons: (react-native) Ionicon icons are aligned left within their <Icon>'s internal <Text> component.

Created on 26 Sep 2017  路  3Comments  路  Source: oblador/react-native-vector-icons

FYI: I am using NativeBase's Icon component that uses Ionicons.

Pictures are worth a thousand words:

image

and the other icon highlighted too:

image

This makes working with the icons a bit tedious as it's really hard to align different kinds of icons.

Is this intended behavior or is there something wrong with my setup? Is there a way to make the icons align center instead of left?

Note: this is not an issue with my own code, I have:

<View style={{width: 40, alignItems: 'center', justifyContent: 'center'}}>
  <Icon active name={icon} size={20} />   
</View>

and the highlighted part in the above pictures is not the View, it's inside the Icon component.

Most helpful comment

For those who end up here from a google search just like I did:

Solved it using textalign: "center" on the icon component's style.

This is how my code looks:

<Icon style={{textAlign: "center"}} name={icon} size={20} />

All 3 comments

Closing, it was a NativeBase issue.

How did you fix this?

For those who end up here from a google search just like I did:

Solved it using textalign: "center" on the icon component's style.

This is how my code looks:

<Icon style={{textAlign: "center"}} name={icon} size={20} />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fevzican picture fevzican  路  3Comments

jakewtaylor picture jakewtaylor  路  4Comments

AbhayVarshney picture AbhayVarshney  路  3Comments

alihesari picture alihesari  路  3Comments

arjs1000 picture arjs1000  路  3Comments