question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Yo ! I’m using this lib to render icon component and I find that the icons are not vertically centered. Maybe I’m using it wrong, but even if I render just the Icon component and put his background color to see better, the icon is clearly not centered.

image

import { Ionicon } from '@expo/vector-icons'

<Ionicon
  color='white'
  name='close'
  style={ { backgroundColor: 'red' } }
/>

I tried to put alignItems: 'center' and justifyContent: 'center' to style without success…

If I put paddingTop: 2 to style, the icon is centered

image

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:18
  • Comments:24 (1 by maintainers)

github_iconTop GitHub Comments

90reactions
ZackTRobertsoncommented, Feb 5, 2018

Wrap the icon component in a parent view and then set that view’s justifyContent style property to “center”. (or alignItems if you make the flexDirection “row”)

<View style={{justiftyContent:"center", alignItems:"center"}}>
   <Icon>
</View>
87reactions
martinezguillaumecommented, Aug 8, 2018

@basbase solution is good. And if you want to center the icon inside (because sometimes icons are not centered), you can add textAlign: 'center' to style icon

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to center Font Awesome icons horizontally? - css
I have a table with a Font Awesome icon and I want to align text left and center icons. I tried with centering...
Read more >
How to target all Font Awesome icons and align them center?
The most preferred way to center Font Awesome Icons is to assign a center class to each <i> tag. Setting width to 100%,...
Read more >
[Solved] center align icon fonts horizontally - CSS-Tricks
I can't figure out how to txt-center icon fonts. They just don't center no matter what you do. example of css and html...
Read more >
align-center Icon | Font Awesome
align -center icon in the Solid style. Make a bold statement in small sizes.. Available now in Font Awesome 6.
Read more >
How to Vertically Center Text and Icons in CSS - SitePoint
To vertically center a single line of text or an icon within its container, we can use the line-height property. This property controls...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found