material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[Grid] Covering full height

Open suaradial opened this issue 9 years ago • 10 comments

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: screen shot 2017-07-15 at 11 12 15 am

  • React:

  • Browser:

suaradial avatar Jul 15 '17 15:07 suaradial

I'm not sure to following, why would/should the grid takes the full height?

oliviertassinari avatar Jul 15 '17 19:07 oliviertassinari

I'm closing the issue as the grid wasn't designed to take the full height of the viewport.

oliviertassinari avatar Jul 16 '17 14:07 oliviertassinari

Still, it would be nice if it had the possibility to do it

dobryanskyy avatar Jul 24 '17 09:07 dobryanskyy

People can always define a height to the component.

oliviertassinari avatar Jul 24 '17 09:07 oliviertassinari

But what if you just needed rest of height not taken by other items. It would be nice if grid calculated that

dobryanskyy avatar Jul 24 '17 10:07 dobryanskyy

@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 avatar Dec 29 '17 10:12 iabotsiTC

@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

danielteles avatar Jan 31 '18 17:01 danielteles

Relevant discussion: https://twitter.com/ryanflorence/status/958465067166588929

mbrookes avatar Jan 31 '18 20:01 mbrookes

@mbrookes : What are the benefits of using #root { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } over html, body { height: 100%}?

iabotsiTC avatar Feb 01 '18 08:02 iabotsiTC

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;

SARCASMOOO avatar Mar 27 '21 02:03 SARCASMOOO