I'm trying to create a layout similar to most editors/IDEs using material-ui and react, using material-ui Grid for the layout. I have a top bar, a bottom bar, side panels on both sides and a center area. My question is: how to make this grid occupy the entire screen?
The way it is now, it only grows as far as the inner elements min-heights. I want both side panels to fill the screen vertically.
Here is a simple example with exactly the same layout I'm trying to implement: https://codesandbox.io/s/material-demo-0pl9e
What I'm trying to do is to make the grid occupy the entire screen by expanding only the middle container.
The grid component Material Design's grid system is implemented in MUI using the <Grid /> component. Under the hood, the <Grid /> component uses Flexbox properties for greater flexibility. There are two types of grid components: containers and items.
The Material Design responsive layout grid adapts to screen size and orientation, ensuring consistency across layouts. The grid creates visual consistency between layouts while allowing flexibility across a wide variety of designs. Material Design's responsive UI is based on a 12-column grid layout.
xs, extra-small: 0px. sm, small: 600px. md, medium: 900px. lg, large: 1200px.
After a little research, I was able to achieve the expected behavior (the IDE-like layout) using viewport units and the css 'calc' function.
I used two material-ui Grids, namely 'mainGrid', with direction='row' (default) and a 'middleGrid', with direction='column'. The mainGrid style:
mainGrid: {
width: '100vw',
height: '100vh',
spacing: 0,
justify: 'space-around'
}
And the middleGrid:
middleGrid: {
height: `calc(100vh - ${uiDefault.APPBAR_HEIGHT})`,
spacing: 0,
direction: 'column'
}
APPBAR_HEIGHT is a constant defining the fixed height of my top navigation bar. Using this scheme, its easy to get the proper, full screen layout. Results are saved in the same codesandbox shared in the question: https://codesandbox.io/s/material-demo-0pl9e
<Container
style={{
border: "solid",
minWidth: "100%",
height: "100vh",
}}
>
<Content/>
</Container>
border: "solid", (for visual purposes you can delete this)
you can use <Grid>
insted
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