Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align horizontal icon and text in MUI

I am a newbie in MUI, now my icon and text are not aligned:

not align

My desired results:

My code is:

<div style={{     display: 'inline-flex',     VerticalAlign: 'text-bottom',     BoxSizing: 'inherit',     textAlign: 'center',     AlignItems: 'center' }}>     <LinkIcon className={classes.linkIcon}  />     revolve </div>   

I tried grid and row, but not work. Can anyone help me?

like image 678
tong Avatar asked Aug 21 '18 00:08

tong


People also ask

How do I align horizontal icon and text in material UI?

To align horizontal icon and text in React Material UI, we can add flexbox styles with makeStyles . to call makeStyles with a function that returns the styles for the wrapIcon class to return the useStyle hook.

How do I align text vertically to icons?

Use line-height for vertical centering with a fixed height To vertically center a single line of text or an icon within its container, we can use the line-height property. This property controls the height of a line in a run of text and adds an equal amount of space above and below the line-box of inline elements.


1 Answers

This works perfectly!

<div style={{     display: 'flex',     alignItems: 'center',     flexWrap: 'wrap', }}>     <LinkIcon />     <span>revolve</span> </div>   
like image 148
Peter Moses Avatar answered Oct 03 '22 11:10

Peter Moses