Nativebase: How to display Icon and text

Created on 21 Nov 2017  路  6Comments  路  Source: GeekyAnts/NativeBase

I want to display a Icon on the Left and a Text on the Right But it always look false Like the Text is not on the same level as as the icon.
bildschirmfoto 2017-11-21 um 23 46 52

I Use:

<Text>
  <Icon ios='ios-mail-outline' android='ios-mail-outline'/>
  <Text> {this.store.user.email}</Text>
</Text>
awaiting response

Most helpful comment

FWIW, I tried using a flexbox referring to Layout with Flexbox.

<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  <Icon ios='ios-mail-outline' android='ios-mail-outline'/>
  <Text>[email protected]</Text>
</View>

android:
android

ios:
ios

All 6 comments

FWIW, I tried using a flexbox referring to Layout with Flexbox.

<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  <Icon ios='ios-mail-outline' android='ios-mail-outline'/>
  <Text>[email protected]</Text>
</View>

android:
android

ios:
ios

Thats cool thank you!!

@ZeroSoulEater Thats happening with React Native <Text> also
@horiuchie 's workaround runs fine
Also that you can try wrapping <Icon and <Text> with NativeBase's <ListItem>
that gives proper spacing between icon and text with appropriate lineHeight

screen shot 2017-11-22 at 3 26 27 pm

@akhil-geekyants With ListItem I got this Line

bildschirmfoto 2017-11-22 um 11 14 05

<ListItem icon> 
  <Left>
    <Icon name="plane" />
  </Left>
  <Body>
    <Text>Airplane Mode</Text>
  </Body>
  <Right/>
</ListItem>

@ZeroSoulEater just set style={{ borderBottomColor: 'transparent' }} for <Body/> component and remove <Right/> if it don't have any children

<ListItem icon>
      <Left>
         <Icon name="plane" />
      </Left>
      <Body style={{ borderBottomColor: 'transparent' }}>
         <Text>Airplane Mode</Text>
      </Body>
 </ListItem>

Closing this issue due to no response

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bsiddiqui picture bsiddiqui  路  3Comments

aloifolia picture aloifolia  路  3Comments

maphongba008 picture maphongba008  路  3Comments

natashache picture natashache  路  3Comments

muthuraman007 picture muthuraman007  路  3Comments