Tips for generating rows with material-ui grid

I am utilizing material-ui grid to make my content responsive. However, I am facing challenges in creating nested rows for my layout. My requirement is to have the first row span the entire width and then divide it into 3 columns with widths of 3, 3, and 6 respectively. Within the first column, I need to further break it down into two rows that match the height of the second and third columns. I am unsure of how to split a column into two rows. https://i.sstatic.net/R0AZg.png

Code:

<Grid container spacing={1}>
            <Grid container item xs={12} spacing={3}>
                <Grid item xs={3}>
                    <Grid container item xs={12} spacing={3}>
                        <Grid item xs={12}>
                            <Grid container item xs={12} spacing={3}>
                                <Grid item xs={12}>
                                    <Paper className={classes.paper}>item</Paper>
                                </Grid>
                            </Grid>
                            <Grid container item xs={12} spacing={3}>
                                <Grid item xs={12}>
                                    <Paper className={classes.paper}>item</Paper>
                                </Grid>
                            </Grid>
                        </Grid>
                    </Grid>
                </Grid>
                <Grid item xs={3}>
                    <Grid container item xs={12} spacing={3}>
                        <Grid item xs={12}>
                            <Paper className={classes.paper}>item</Paper>
                        </Grid>
                    </Grid>
                </Grid>
                <Grid item xs={6}>
                    <Paper className={classes.paper}>item</Paper>
                </Grid>

            </Grid>

        </Grid> 

Answer №1

Remember to place item xs.={...} specifically on the individual items, not on the contsiner.

Additionally, it's important to set sm={...} (and other screen sizes) for each item. Using xs with a value of 12 will always span the full row.

For more examples, refer to the documentation at https://material-ui.com/components/grid/

Answer №2

Here is a solution tailored for your specific situation:

<Grid container>
  <Grid container item xs={3}>
    <Grid item xs={12} style={{border: "black solid 1px"}}>
      cell 1, row 1
    </Grid>
    <Grid item xs={12} style={{border: "black solid 1px"}}>
      cell 2, row 1
    </Grid>
  </Grid>
  <Grid item xs={3} style={{border: "black solid 1px"}}>
    cell 3
  </Grid>
  <Grid item xs={6} style={{border: "black solid 1px"}}>
    cell 4
  </Grid>
</Grid>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

``The Art of Handling REST API with Express and Mongoose

Running Express on my application, I have a delete route set up as shown below: router.route('/lists/:id') .delete(function(req, res){ Entry.remove({ _id: req.params.id }, function(err, list){ if(err) ...

HTML checkbox utilizing JavaScript

<input type="checkbox" name="smoker"> Is there a way for JavaScript to determine whether the checkbox is checked or unchecked without making changes to the HTML code above? ...

Injecting personalized themes into withStyles

I've designed a theme that I'm attempting to incorporate into my useStyles. Here's the theme: import { createMuiTheme } from "@material-ui/core/styles"; const customTheme = createMuiTheme({ palette: { primary: { ...

Store live text field group in their respective index

I am working on a project that involves creating dynamic description textareas based on the value selected from a dropdown list. The dropdown list contains numbers 1 through 5, and for each number chosen, I need to generate corresponding textareas with ser ...

Tips for updating the bottom border of a disabled Material-UI <Autocomplete/> component

Is there a way to customize the appearance of the autocomplete component in MaterialUi when it is disabled? Currently, they suggest using borderBottom: dotted, but I would like it to have the same look as the select component when it is disabled, as shown ...

A method for dividing a string into separate characters and organizing them into an array of JSON objects

I have a collection of JSON objects with a fixed key 'type' and additional keys based on the type. Here is an example of how it looks: theArray = [ { "type": "text", "text": "= SUM(" ...

Transferring a single dataset from a table to a pop-up modal using Angular

I am working on a table to display entries for a contest, extracted from a database using PHP and converted into a .json object for AngularJS and JavaScript. I want to add a modal feature so that when a "judge" clicks on an entry, they can view its details ...

Fetch data using Ajax without the need for a hash signal

My current goal is to load content through Ajax on a website. Let's say our main page is example.com/blankpage (I've eliminated the .html extension using htaccess). At the moment, I have it set up so that when a link on the page directs to mysite ...

What steps can I take to address security issues related to iframes?

Are there other security risks to consider when using iframes besides XSS vulnerabilities? How can I ensure that my website is secure when utilizing iframes? I've seen some JavaScript code that uses top.window, but I'm hesitant to rely on client ...

Discover the method for two form fields to submit data to a distant page, located two pages away

Currently, I'm trying to figure out the best approach for having two fields submitted to a page that is located two pages away. To provide more context, let me elaborate on the situation. On the initial page, there will be two fields - workshop title ...

Guidelines for specifying alternate structures in JSON schema

I have two different JSON file structures, one like this: { "api": "http://my.api.host", "modules": [ "core", "module", "another" ] } and the other like this: { "api": "http://my.api.host", "modules": "*" } The modules attri ...

Display a vibrant welcome screen on an Android WebView that ensures a visually appealing experience while the content loads for the

When launching an application, the desired behavior is as follows: Display a splash screen while simultaneously loading a URL Upon the firing of a JavaScript interface event on page load, remove the splash screen Mainactivity.java myWebView.addJavascript ...

Initiating an Ajax POST request when the onblur() event is triggered

Having an issue with Ajax. I'm trying to submit a changed value from an input field on the onblur() event, but there's a flicker that's bothering me. When I enter a new value and click away, the old value briefly flashes back before changi ...

The implementation of display flex is causing issues with the material-ui grid layout

Struggling to implement the grid system from material-ui due to an issue where grid items do not resize when resizing the browser window. The culprit seems to be a parent div with the style property "display": "flex". The dilemma arises from using a mater ...

The lua.vm.js ajax callbacks are triggering, but unfortunately, the requested data is not

After raising this issue at https://github.com/kripken/lua.vm.js/issues/5, I realized that submitting it to stackoverflow might yield a faster response due to higher exposure. To ensure clarity, I will restate my question: How can the callback data be acce ...

Ways to delay the inner function's output?

Need help with making a function return only after its inner function is called. See below for the code snippet - function x() { function y() { // Inner function logic } return result; // This should be returned only after function y is ca ...

React with custom classes for Material UI Switch

I'm attempting to personalize the color of the toggle switch in Material UI using their classes props. I prefer not to use withStyles HOC because I am developing a customized Formik switch that can be utilized throughout my entire application. Howeve ...

Navigating through intricate JavaScript object

I need help figuring out how to access the "description" property of a JSON object I received from an API endpoint. The object looks like this: - "description" : "Dorian Market 1"? let markets = { "result":[ { "townId" : "MEBD", "stor ...

Tips for implementing event handlers on dynamically generated li elements in VueJS

Creating multiple ul elements using v-for in the following way <div v-for="item in info"> <ul> <li><a>{{item.number}}</a></li> <li><a>{{item.alphabet}}</a></li> </ul> </div&g ...

Javascript - Conceal a Dynamic Div Depending on its Text

I have a unique table that generates dynamic Divs with ID's that count as they are created in the following format: <div id="dgpCheckDiv10_0"> <input Delete </div> <div id="dgpCheckDiv10_1"> text2 </div> Some of t ...