The I am facing an issue with Material-ui Grid where the width of the Grid item is too large and extending beyond the boundaries

I'm in the process of setting up a basic layout for a single-page application using Material-ui and React. My plan is to have a sidebar on the left-hand side and a main area on the right-hand side to display information. However, I am facing two issues with my current setup: The <Grid item> and its container <Button> elements are extending beyond the left sidebar

<Grid container item xs={3} className={classes.sideBarGrid}>
into the right-hand column. I'm not sure where I'm going wrong and would greatly appreciate any help!

Access Code Sandbox here

I'm also struggling to get the right-hand grid column

<Grid container item xs={9} className={classes.labelGrid}>
to take up the full width, even though I've set it to width: "100%".

Code snippet:


import React from "react";
// other module imports...

export default function Labelscreen(props) {
  const classes = useStyles();

  // additional code snippets omitted...
}

UPDATE

It appears that the gray area on the right side isn't fully occupying the screen when the screen size is large, despite setting the width to 100% in the labelGrid.

https://i.sstatic.net/k4KzB.png

Answer №1

  1. The buttons in your layout have margin on the right and left, causing them to extend beyond the boundaries of the left sidebar.
    You can rectify this issue by:
classButton: {
    margin: theme.spacing(1, 0)
  },
  submit: {
    margin: theme.spacing(1, 0)
  },
  1. To create space on the left and right sides, you can apply padding to the container:
sideBarGrid: {
    maxWidth: 300,
    flexDirection: "column",
    justifyContent: "space-between",
    padding: theme.spacing(0, 1)
  },

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

Can you inherit from a class in a different file using SASS?

All the information needed is in this question. For example, if I decide to utilize Twitter Bootstrap, would it be possible for me to create classes in my own SASS stylesheet that inherit from Bootstrap's CSS classes? Or is SASS inheritance restricte ...

How to isolate a function in React when mapping data

I am currently working on mapping data as a repeater in my React project. However, I am facing an issue with isolating the opening function, specifically with an accordion component. As I continue to learn React, I want to ensure that each accordion operat ...

Creating optimal spacing for two buttons in Material Design

I need help with spacing between two buttons. I tried wrapping them in a box and applying margins, but they are stuck together. Here is my code: render() { return ( <> <ThemeProvider theme={theme}> <CssBaselin ...

Why is the CSS selector `:first-child:not(.ignore)` not working to exclude the `ignore` class from the selection?

Is there a way to utilize the first-child selector with the not(.ignore) selector to target every element that is the first child of its parent, except when that first child has the class ignore? I've experimented with :first-child:not(.ignore){...}, ...

Hide, show, toggle, or empty elements using jQuery

I am having trouble getting this jQuery code to function properly. Within a div, there is a paragraph that I want to hide when a specific button is clicked and show when another button is clicked. Check out the code here $("#details").on("c ...

Unable to relocate CSS Loader Container

Can someone help me with adjusting the placement of my container? I'm struggling to maintain the styles while getting rid of the position: absolute; on the .dot class. Every attempt I make is resulting in the dots moving erratically! To clarify, I w ...

What is the optimal approach to organizing components' props?

As I dive into testing Material-UI components, one thing has me puzzled. Take the List component for example - why use such syntax? <List component="nav"> <ListItem button selected={selectedIndex === 0} onClick={(event) => ha ...

What causes the alignment of text to be overridden by the presence of a floating element?

https://jsfiddle.net/u0Ltgh3e/68/ .text { width: 50%; text-align: justify; } I am currently developing a custom formatting tool for a specific purpose and I am attempting to create a two-column layout similar to the one demonstrated in this Jsfiddle l ...

Why do my tablet media queries take precedence over mobile view media queries?

I've noticed that when I view my website on mobile devices, the tablet media queries always seem to override my mobile media queries. Can anyone explain why this is happening? Here is how I have set it up: /* X-Small devices (portrait phones, less t ...

Obtaining a CHUNKY h1

After years of designing websites, one thing that continues to puzzle me is how people achieve that bold and THICK h1 effect. Take a look at this example - https://i.sstatic.net/xOJHn.png Even with a font weight of 700, it always seems too thin no matter ...

Show the menu when hovering in reactjs

Currently, in my react project, I am implementing dropdown menus using the reactstrap css framework. Example.Js <Dropdown className="d-inline-block" onMouseOver={this.onMouseEnter} onMouseLeave={this.onMouseLeave} ...

Using touch-action to enable movement from the last item to the first item in HTML/C

Currently, I am utilizing the touch-action property in my carousel which auto slides without any issues. However, I am facing a problem where when I scroll using touch-action, it stops at the last slide instead of looping back to the first slide. My goal i ...

What is causing the malfunction of the position within this particular section?

On my website, I have a specific section where I want to showcase four products with arrows on both sides for navigation. However, I am facing an issue with the positioning of the elements. Can someone take a look and help me figure it out? Check out this ...

In React Native with reactnavigation, how can I navigate back to the screen before the current one within a Drawer?

Take a look at this demonstration showcasing the issue: I'm trying to navigate from ScreenOne -> ScreenTwo -> ScreenThree -> goBack() to ScreenTwo.... However, when I call navigation.goBack() on ScreenThree, it takes me back to ScreenOne in ...

Photos failing to load in the image slider

Although it may seem intimidating, a large portion of the code is repetitive. Experiment by clicking on the red buttons. <body> <ul id="carousel" class="carousel"> <button id="moveSlideLeft" class="moveSlide moveSlideLeft"></button& ...

Browser and contexmenu intersecting halfway

I have successfully implemented a custom context menu in my HTML project. It functions well, but I am facing an issue where half of the menu appears off-screen to the right. Is there a way to detect this and reposition the menu above the mouse pointer? He ...

Applying CSS to Align List Items to the Left with Word Wrap

Over at my blog page qavalidation.com, I am faced with an issue related to the alignment of vertical menus with links. When word wrap is applied, there seems to be a misalignment in the left indentation. Can someone provide guidance on the correct CSS sty ...

Changing the Input Label Color on Hover in Material-UI TextField

I have a custom styled Mui TextField called CustomTextField. It changes the input background color and font color on hover, but I also want to change the label font color when hovered over. Currently, the input background changes from black to white on hov ...

Issue encountered while importing supercluster in TypeScript (TypeError: Unable to assign property 'options' to an undefined variable)

After attempting to import supercluster in TypeScript, I encountered the following error. Any helpful insights would be appreciated. ExceptionsManager.js:86 TypeError: Cannot set property 'options' of undefined This error is located at: ...

Modify the color of the text to be white

How can I modify the code below to change the text color to white? The original code is inspired by this question. I am unsure about how the text color was originally set to blue. .footer-background { padding-top: 20px; padding-bottom: 20px; bac ...