


Creating Responsive Layouts in React using Material UI Grid
By:
Manamohan Sethi
22 Apr 2025
Hi there! If you've ever built a React app and found it difficult to make your layout look good on both desktop and mobile, you're not alone. Good news? Material UI (aka MUI) makes it easy to create responsive design with its powerful Grid system. Let’s see how you can create a completely responsive layout using MUI Grid, step by step, with code you can copy and customize.

Why Use Material UI Grid?
MUI's Grid is based on top of CSS Flexbox, and it works on a 12-column layout system. It means you can divide your layout into sections without much stress, and control different section's behaviour on different screen sizes. Now you don't have to write separate CSS media queries all over the place.
Quick Setup
If you’re new:
npx create-react-app mui-grid-demo
cd mui-grid-demo
npm install @mui/material @emotion/react @emotion/styled
Done? Now, you can move ahead. Open up your App.js
or any component, and let’s go.
Basic Grid Layout
Check out this simple responsive layout with 3 boxes:
import React from "react";
import { Grid, Box } from "@mui/material";
const ResponsiveGrid = () => {
return (
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="primary.main" color="white">Box 1</Box>
</Grid>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="secondary.main" color="white">Box 2</Box>
</Grid>
<Grid item xs={12} sm={12} md={4}>
<Box p={2} bgcolor="error.main" color="white">Box 3</Box>
</Grid>
</Grid>
);
};
export default ResponsiveGrid;
What's happening here?
xs={12}
: Full width on extra-small screens (mobile)sm={6}
: Half width on small screens (like tablets)md={4}
: One-third width on medium screens and up (desktops)
Boom! Here you built a layout that adapts to screen sizes.
Nested Grids
You can even nest grids inside other grids:
<Grid item xs={12}>
<Grid container spacing={1}>
<Grid item xs={6}>Nested Grid 1</Grid>
<Grid item xs={6}>Nested Grid 2</Grid>
</Grid>
</Grid>
Useful when you have to break things down within a section.
Styling with Box
MUI’s Box
component is the best thing for you. You can quick style by adding padding, colors, margins, borders, all using the sx
prop or shorthand props like p
, m
, bgcolor
, etc.
<Box p={2} bgcolor="info.main" color="white" borderRadius={2}>
Styled Box
</Box>
Want More Control?
Try it:
alignItems
,justifyContent
onGrid container
display="flex"
inBox
for layout adjustments.hidden
component to hide/show stuff based on screen size
Conclusion
Now you dont have to write a single media query to create a responsive UI, MUI’s Grid system makes it possible. The result is clean, predictable, and works great. Next time you’re building a dashboard, landing page, or product listing, no need to stress out use Grid
.
Frequently Asked
Q. How does the MUI Grid system work in React?
A. The MUI Grid system is based on a 12-column layout using CSS Flexbox. You can control how components adjust across the grid at different screen sizes by assigning column widths to components with props like xs
, sm
, md
, etc.,. With this you can create responsive designs without writing custom media queries.
Q. How do I make a responsive layout using MUI Grid?
A. To create a responsive layout with MUI Grid, wrap your components in a Grid
container and specify the column span for each item at various breakpoints. For example:
<Grid container spacing={2}> <Grid item xs={12} sm={6} md={4}> {/* Content */} </Grid> </Grid>
In this setup, the grid item spans full width on extra-small screens, half width on small screens, and one-third width on medium and larger screens.
Q. Can I nest Grids inside other Grids in MUI?
A. Yes, you can place a Grid
container inside a Grid
item to create complex layouts. This approach is useful for structuring components hierarchically and managing spacing effectively.
Hi there! If you've ever built a React app and found it difficult to make your layout look good on both desktop and mobile, you're not alone. Good news? Material UI (aka MUI) makes it easy to create responsive design with its powerful Grid system. Let’s see how you can create a completely responsive layout using MUI Grid, step by step, with code you can copy and customize.

Why Use Material UI Grid?
MUI's Grid is based on top of CSS Flexbox, and it works on a 12-column layout system. It means you can divide your layout into sections without much stress, and control different section's behaviour on different screen sizes. Now you don't have to write separate CSS media queries all over the place.
Quick Setup
If you’re new:
npx create-react-app mui-grid-demo
cd mui-grid-demo
npm install @mui/material @emotion/react @emotion/styled
Done? Now, you can move ahead. Open up your App.js
or any component, and let’s go.
Basic Grid Layout
Check out this simple responsive layout with 3 boxes:
import React from "react";
import { Grid, Box } from "@mui/material";
const ResponsiveGrid = () => {
return (
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="primary.main" color="white">Box 1</Box>
</Grid>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="secondary.main" color="white">Box 2</Box>
</Grid>
<Grid item xs={12} sm={12} md={4}>
<Box p={2} bgcolor="error.main" color="white">Box 3</Box>
</Grid>
</Grid>
);
};
export default ResponsiveGrid;
What's happening here?
xs={12}
: Full width on extra-small screens (mobile)sm={6}
: Half width on small screens (like tablets)md={4}
: One-third width on medium screens and up (desktops)
Boom! Here you built a layout that adapts to screen sizes.
Nested Grids
You can even nest grids inside other grids:
<Grid item xs={12}>
<Grid container spacing={1}>
<Grid item xs={6}>Nested Grid 1</Grid>
<Grid item xs={6}>Nested Grid 2</Grid>
</Grid>
</Grid>
Useful when you have to break things down within a section.
Styling with Box
MUI’s Box
component is the best thing for you. You can quick style by adding padding, colors, margins, borders, all using the sx
prop or shorthand props like p
, m
, bgcolor
, etc.
<Box p={2} bgcolor="info.main" color="white" borderRadius={2}>
Styled Box
</Box>
Want More Control?
Try it:
alignItems
,justifyContent
onGrid container
display="flex"
inBox
for layout adjustments.hidden
component to hide/show stuff based on screen size
Conclusion
Now you dont have to write a single media query to create a responsive UI, MUI’s Grid system makes it possible. The result is clean, predictable, and works great. Next time you’re building a dashboard, landing page, or product listing, no need to stress out use Grid
.
Frequently Asked
Q. How does the MUI Grid system work in React?
A. The MUI Grid system is based on a 12-column layout using CSS Flexbox. You can control how components adjust across the grid at different screen sizes by assigning column widths to components with props like xs
, sm
, md
, etc.,. With this you can create responsive designs without writing custom media queries.
Q. How do I make a responsive layout using MUI Grid?
A. To create a responsive layout with MUI Grid, wrap your components in a Grid
container and specify the column span for each item at various breakpoints. For example:
<Grid container spacing={2}> <Grid item xs={12} sm={6} md={4}> {/* Content */} </Grid> </Grid>
In this setup, the grid item spans full width on extra-small screens, half width on small screens, and one-third width on medium and larger screens.
Q. Can I nest Grids inside other Grids in MUI?
A. Yes, you can place a Grid
container inside a Grid
item to create complex layouts. This approach is useful for structuring components hierarchically and managing spacing effectively.
Hi there! If you've ever built a React app and found it difficult to make your layout look good on both desktop and mobile, you're not alone. Good news? Material UI (aka MUI) makes it easy to create responsive design with its powerful Grid system. Let’s see how you can create a completely responsive layout using MUI Grid, step by step, with code you can copy and customize.

Why Use Material UI Grid?
MUI's Grid is based on top of CSS Flexbox, and it works on a 12-column layout system. It means you can divide your layout into sections without much stress, and control different section's behaviour on different screen sizes. Now you don't have to write separate CSS media queries all over the place.
Quick Setup
If you’re new:
npx create-react-app mui-grid-demo
cd mui-grid-demo
npm install @mui/material @emotion/react @emotion/styled
Done? Now, you can move ahead. Open up your App.js
or any component, and let’s go.
Basic Grid Layout
Check out this simple responsive layout with 3 boxes:
import React from "react";
import { Grid, Box } from "@mui/material";
const ResponsiveGrid = () => {
return (
<Grid container spacing={2}>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="primary.main" color="white">Box 1</Box>
</Grid>
<Grid item xs={12} sm={6} md={4}>
<Box p={2} bgcolor="secondary.main" color="white">Box 2</Box>
</Grid>
<Grid item xs={12} sm={12} md={4}>
<Box p={2} bgcolor="error.main" color="white">Box 3</Box>
</Grid>
</Grid>
);
};
export default ResponsiveGrid;
What's happening here?
xs={12}
: Full width on extra-small screens (mobile)sm={6}
: Half width on small screens (like tablets)md={4}
: One-third width on medium screens and up (desktops)
Boom! Here you built a layout that adapts to screen sizes.
Nested Grids
You can even nest grids inside other grids:
<Grid item xs={12}>
<Grid container spacing={1}>
<Grid item xs={6}>Nested Grid 1</Grid>
<Grid item xs={6}>Nested Grid 2</Grid>
</Grid>
</Grid>
Useful when you have to break things down within a section.
Styling with Box
MUI’s Box
component is the best thing for you. You can quick style by adding padding, colors, margins, borders, all using the sx
prop or shorthand props like p
, m
, bgcolor
, etc.
<Box p={2} bgcolor="info.main" color="white" borderRadius={2}>
Styled Box
</Box>
Want More Control?
Try it:
alignItems
,justifyContent
onGrid container
display="flex"
inBox
for layout adjustments.hidden
component to hide/show stuff based on screen size
Conclusion
Now you dont have to write a single media query to create a responsive UI, MUI’s Grid system makes it possible. The result is clean, predictable, and works great. Next time you’re building a dashboard, landing page, or product listing, no need to stress out use Grid
.
Frequently Asked
Q. How does the MUI Grid system work in React?
A. The MUI Grid system is based on a 12-column layout using CSS Flexbox. You can control how components adjust across the grid at different screen sizes by assigning column widths to components with props like xs
, sm
, md
, etc.,. With this you can create responsive designs without writing custom media queries.
Q. How do I make a responsive layout using MUI Grid?
A. To create a responsive layout with MUI Grid, wrap your components in a Grid
container and specify the column span for each item at various breakpoints. For example:
<Grid container spacing={2}> <Grid item xs={12} sm={6} md={4}> {/* Content */} </Grid> </Grid>
In this setup, the grid item spans full width on extra-small screens, half width on small screens, and one-third width on medium and larger screens.
Q. Can I nest Grids inside other Grids in MUI?
A. Yes, you can place a Grid
container inside a Grid
item to create complex layouts. This approach is useful for structuring components hierarchically and managing spacing effectively.
Explore our services
Explore other blogs
Explore other blogs

let's get in touch
Have a Project idea?
Connect with us for a free consultation !
Confidentiality with NDA
Understanding the core business.
Brainstorm with our leaders
Daily & Weekly Updates
Super competitive pricing

let's get in touch
Have a Project idea?
Connect with us for a free consultation !
Confidentiality with NDA
Understanding the core business.
Brainstorm with our leaders
Daily & Weekly Updates
Super competitive pricing
DEFINITELY POSSIBLE
Our Services
Technologies
Crafted & maintained with ❤️ by our Smartees | Copyright © 2025 - Smartters Softwares PVT. LTD.
Our Services
Technologies
Created with ❤️ by our Smartees
Copyright © 2025 - Smartters Softwares PVT. LTD.