How to align horizontal icon and text in Material-UI

前端 未结 8 2214
后悔当初
后悔当初 2021-01-31 07:35

I am a newbie in material-ui, now my icon and text are not aligned :

\"not

My desired results:

8条回答
  •  情书的邮戳
    2021-01-31 08:34

    styles

    const styles = theme => ({
        icon: {
            position: "relative",
            top: theme.spacing.unit,
            width: theme.typography.display1.fontSize,
            height: theme.typography.display1.fontSize
        }
    });
    

    JSX

    
        Your Text
    
    

    you could replace display1 with display3 or another typography variant in all 3 places to choose your text size. The   ensures that your text doesn't break between words when it wraps.

    For me this can render to look like this

    with display3 and a few other styles added for color.

提交回复
热议问题