I am trying to create a hero banner using the material-ui framework.
So far what I have looks as follows:
As you can see, there is annoying left and right padding. I cannot seem to get rid of it.
My Hero component looks like this:
import React from 'react'
import Container from '@material-ui/core/Container'
import { makeStyles } from '@material-ui/core'
const useStyles = makeStyles((theme) => ({
heroContent: {
backgroundColor: theme.palette.background.paper,
padding: theme.spacing(8, 0, 6),
},
heroButtons: {
marginTop: theme.spacing(4),
},
}))
const Hero = () => {
const classes = useStyles()
return <Container className={classes.heroContent}></Container>
}
export default Hero
Can someone please explain how I can get rid of the padding on the left and right, and achieve full width?
I tried setting the paddings in my styles as you can see, but that has no effect. Any guidance is appreciated!
The disableGutters
prop removes the padding.
Example:
import React from "react";
import CssBaseline from "@material-ui/core/CssBaseline";
import Typography from "@material-ui/core/Typography";
import Container from "@material-ui/core/Container";
export default function SimpleContainer() {
return (
<React.Fragment>
<CssBaseline />
<Container disableGutters maxWidth={false}>
<Typography
component="div"
style={{ backgroundColor: "#cfe8fc", height: "100vh" }}
/>
</Container>
</React.Fragment>
);
}
Related documentation: https://material-ui.com/api/container/#props
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With