React and Material UI collaboration causing layout problems

Seeking assistance with implementing React and Material UI in my project.

My objective is to create a layout with 3 columns on desktop - one column with a radio button and label inline, and the other two columns containing select menus with option values.

For the mobile version, I aim to have two columns with the select menus inside, and the input positioned above the columns.

Refer to the following images for reference: Desktop Layout and Mobile Layout.

Currently, I have achieved the 3-column layout on desktop but facing challenges with the mobile version. As a beginner in React and Material UI, any guidance would be highly appreciated.

<Grid display='flex>
    <Grid lg={4}
            <FormControlLabel value="my quantity" control={<Radio />} label="My Label" />
    </Grid>
    <Grid lg={4}>
        <InputLabel  htmlFor="uncontrolled-native" sx={{ display:'inline-block'}}>Text One</InputLabel>
        <Select defaultValue={4} sx={{ backgroundColor:'lightgrey'}}>
        <option value={1}>1</option>
        </Select>  
    </Grid>
    <Grid lg={4}>
        <InputLabel htmlFor="uncontrolled-native" sx={{ display:'inline-block'}}>Text Two</InputLabel>
        <Select>
        <option value={1}>1</option>
        </Select>
    </Grid>
</Grid>

Thank you and have a great day!

Answer №1

In Grid, there are a total of 12 columns available. Suppose you want one column to contain 2 elements, you would divide 12 by 2, resulting in 6 columns per element. Here is a hypothetical scenario:

    <Grid container spacing={2}>
      <Grid item xs={12} lg={6}>
        <Item>Example Label (1)</Item>
      </Grid>
      <Grid item xs={12} lg={6}>
        <Stack direction="row" spacing={2}>
          <Item>Example Text 1</Item>
          <Item>Example Text 2</Item>
        </Stack>
      </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

What is the best way to configure the default entry point for a package.json file in a React

I'm having trouble with the default export in my package.json file. when I try to import: import { Component } from 'packagename/'; // size 22kb or import { Component } from 'packagename/dist' // size 22kb; but import { Component ...

Tips for ensuring only one property is present in a Typescript interface

Consider the React component interface below: export interface MyInterface { name: string; isEasy?: boolean; isMedium?: boolean; isHard?: boolean; } This component must accept only one property from isEasy, isMedium, or isHard For example: <M ...

Guide to utilizing SVG animations for line drawing rather than just outlines

I've been experimenting with animating an SVG file to resemble the gif below, and I'm getting pretty close, but I seem to be encountering an issue where the outlines are drawn before being filled. I want the entire lines to be animated as shown i ...

What could be the reason overflow:hidden isn't functioning properly in IE6?

Would you mind checking this out? http://jsfiddle.net/UQNJA/1/ It displays correctly in all updated browsers, including IE7/8 and 9. However, in IE6, the red and pink borders do not contain the floated <li>s. Any suggestions on how to fix this issu ...

Connecting to a pathway of Material-UI menu items

I am currently utilizing Material-UI's menu components as part of my project requirements. However, I am encountering difficulties in properly routing each MenuItem to an existing route within my application. As a temporary solution, I have resorted ...

Implementing optional payload in React JS for API requests

I am currently working on making API calls in React JS using AXIOS. I want to send a payload as optional only when the productID has a value. Here is an example from my service.js file fetchProducts: (payload) => put(`/products`, payload), fetc ...

Reduced complications with mixin scopes

I have developed a parametric mixin that utilizes a unique "node-value" system to locate the children of an element. The process involves detecting the children through a loop function named ".extractArrays", which contains ".deliverChild" within it. Subse ...

Bootstrap grid. Instead of moving to the next row, scroll horizontally when the content overflows

Here is the code snippet: <div class="row shochatgroup"> <div *ngFor="let message of messages" class="col-auto"> <button *ngIf="message.state.attributes.shochatpaid > 0 && message.state.at ...

If the error state is true, MuiPhoneNumber component in react library will disable typing, preventing users from input

I am currently trying to implement the material-ui-phone-number plugin for react, using Material UI. Whenever the onChange event is triggered, it calls the handlePhone function which stores the input value in the state. However, I have encountered an issue ...

What could be causing the issue with React Router not functioning properly in Material UI?

I'm currently working on creating a tab and adding routing inside the first tab. However, I am facing an issue where the desired page does not display after clicking on the link. Strangely, upon refreshing the page, the corresponding page appears as e ...

"React's FC generic is one of its most versatile features

I'm currently working on a component that can render either a router Link or a Button based on the provided props. Here is the code snippet I have: import React from 'react'; import Button from '@material-ui/core/Button'; import { ...

Encountering difficulties installing create-react-app on Windows 10

I've attempted to install create-react-app multiple times without success. Each time I try, it throws an error message saying "Unexpected end of JSON input while parsing..." Even after re-installing Node.js, I'm still encountering the same issue ...

What is the best way to incorporate this code snippet into an object's value?

Is there a way to merge the headStyles object into the headText object? I have already injected the headStyles object into headConfig. import { makeStyles } from '@material-ui/core' const headStyles = { backgroundColor:'green', ...

Having trouble getting the `transformItems` feature in React InstantSearch RefinementList to

I recently integrated the React InstantSearch library into my app and I'm working on customizing the refinement list to display only relevant filters for the active user. I attempted the following code: <RefinementList attributeName="organization" ...

How can I resolve the vertical adjustment issue of Bootstrap 5 input group on mobile devices?

My current issue involves using Bootstrap 5.2.3 to create an input group that displays a set of spans with the ".input-group-text" class alongside inputs with the ".form-control" class. While this setup works well on a computer screen, it does not adjust c ...

What steps should I take to ensure that this modal remains persistent?

I am searching for a method to keep this modal persistent even after it appears. Currently, the user can easily close it by clicking outside of the div. <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title ...

Ways to customize the datetime-local format in an HTML input field

When dealing with the HTML input of datetime type, consider the following: Datefield: <input type="datetime-local" data-date="" data-date-format="DD MMMM YYYY, h:mm:ss"> The script below includes important code. $("input").val(moment().format(&apo ...

The useEffect hook in Next.js does not trigger a re-render when the route changes

I'm currently experiencing an issue with a useEffect inside a component that is present in every component. I've implemented some authentication and redirection logic in this component, but I've noticed that when using Next.js links or the b ...

What could be causing the issue where my store.getState() is returning undefined in react and redux?

As I delve into learning how to utilize state with react/redux, it has become apparent that the state is widely accessible throughout the Redux application. An example I have created can be found here. In this demonstration, inspecting the react/redux dev ...

Sass fails to import the theme for the angular material checkbox

I'm facing an issue where, despite specifying imports in my SCSS file and setting up a custom theme, the checkbox styles are not visible except for those related to typography. This is what my SCSS file looks like: @import "~bootstrap/scss/bootstrap ...