[Grid] Covering full height
Problem description
I'm implementing the grid container in v1 and it isn't taking up the full height of the viewport, as expected.
Link to minimal working code that reproduces the issue
<Grid
container
align={'flex-start'}
>
<Grid item>
<Sidebar />
</Grid>
</Grid>
Versions
-
Material-UI:

-
React:
-
Browser:
I'm not sure to following, why would/should the grid takes the full height?
I'm closing the issue as the grid wasn't designed to take the full height of the viewport.
Still, it would be nice if it had the possibility to do it
People can always define a height to the component.
But what if you just needed rest of height not taken by other items. It would be nice if grid calculated that
@oliviertassinari: So you mean that to make a fullscreen app with material-ui, we should set html + body + div#root height's to 100% ?
@iabotsiTC this worked for me, but not as expected :( with pages that have a scroll view the application only renders the size of the screen
Relevant discussion: https://twitter.com/ryanflorence/status/958465067166588929
@mbrookes : What are the benefits of using #root { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } over html, body { height: 100%}?
If you want a full-height grid use the makeStyles and set the root class to be 100vh.
For example,
here is a component I made that takes up the entire screen.
import React from 'react';
import { Grid, makeStyles } from '@material-ui/core';
import WelcomeHeader from './WelcomeHeader/WelcomeHeader';
import GetInTouchButton from './GetInTouchButton/GetInTouchButton';
import MoreButton from './MoreButton/MoreButton';
const useStylesContainer = makeStyles(theme => ({
root: {
height: '100vh',
}
}));
const useStylesGetStartedBtn = makeStyles(theme => ({
root: {
width: '30%',
margin: '0 auto'
}
}));
const useStylesWelcomeHeader = makeStyles(theme => ({
root: {
marginTop: '30vh',
marginBottom: '10vh'
}
}));
const useStylesArrowButton = makeStyles(theme => ({
root: {
margin: '20vh auto 0 auto'
}
}));
const Introduction = () => {
const classesContainer = useStylesContainer();
const classesGetStartedBtn = useStylesGetStartedBtn();
const classesWelcomeHeader = useStylesWelcomeHeader();
const classesArrowButton = useStylesArrowButton();
return (
<Grid container
direction='column'
className={classesContainer.root}
>
<Grid item className={classesWelcomeHeader.root}>
<WelcomeHeader/>
</Grid>
<Grid item className={classesGetStartedBtn.root}>
<GetInTouchButton/>
</Grid>
<Grid item className={classesArrowButton.root}>
<MoreButton/>
</Grid>
</Grid>
);
}
export default Introduction;