Created
August 27, 2020 05:56
-
-
Save daveteu/299eb16f6600d44c4a26c2d3e4db66a1 to your computer and use it in GitHub Desktop.
Simple way to display text in the middle of 2 horizontal lines in Material-Ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Grid, Divider, Typography } from '@material-ui/core' | |
//Could use makeStyles here but it's harder to understand | |
const MidText = ({text}) => { | |
return ( <div style={{ padding: '8px' }}> | |
<Grid container> | |
<Grid item style={{ flex: 1, display: 'flex', alignItems: 'center'}}> | |
<Divider style={{ flexGrow: 1 }}/> | |
</Grid> | |
<Grid item> | |
<Typography style={{ paddingLeft: '20px', paddingRight: '20px'}}>{text}</Typography> | |
</Grid> | |
<Grid item style={{ flex: 1, display: 'flex', alignItems: 'center'}}> | |
<Divider style={{ flexGrow: 1 }}/> | |
</Grid> | |
</Grid> | |
</div>) | |
} | |
export default MidText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fully responsive with the use of material-ui grid and flex grow