Components will be displayed without any gaps on smaller screens

I attempted to apply styles to two components in order to create space between them, visible on both larger and smaller displays. The code snippet appears as follows:

<div>
  <CustomPageHeader
    pageTitle={t('offersPage.pageHeader')}
    buttonLabel={t('offersPage.newRequestButton')}
    buttonHandler={handleRequest}
  />
  <Grid classes={{ root: classes.container }} container spacing={4}>
    <Filter
      onFilter={(payload) => {
        // setSelectedFilters((prevState) => ({ ...prevState, ...payload }));
        if (payload === null) {
          setData(sourceData);
          return null;
        }
        // filtering by offerId
        if (payload.offerId !== undefined) {
          const filteredData = sourceData.filter(
            (item) => payload.offerId === item.offerId.toString(),
          );
          setData(filteredData);
          return null;
        }
        // filtering by timestamp
        if (payload.time !== undefined) {
          const filteredData = sourceData.filter((item) => payload.time < item.timestamp);
          setData(filteredData);
          payload.time = null;
          return null;
        }
      }}
    >
      <Grid item xs={2}>
        <SingleSelection
          fullWidth={false}
          parameter={'time'}
          className={classes.select}
          defaultValue="1608969777"
          items={[
            ['Last 30 days', 1608969777],
            ['Last 10 days', 1613548977],
            ['Last day', 1613462577],
          ]}
          required
        />
      </Grid>
      <Grid item xs={2}>
        <Autosuggestion
          className={classes.autosuggestion}
          parameter={'offerId'}
          valueAsParameter={true}
          options={sourceData.map((option) => option.offerId.toString())}
          freeSolo
          searchIcon
          hintInDropdown
          fullWidth={true}
          placeholder={t('offersPage.searchForButton')}
        />
      </Grid>
    </Filter>
    //data mapping here
  </Grid>
</div>

View the result below:

https://i.stack.imgur.com/rQffa.gif

The margin applies correctly on a bigger display but not on a smaller one. Any suggestions on how to resolve this issue? The Grid component is sourced from the ui-material library.

Answer №1

It seems like a margin is required, consider including some spacing in a different container:

<Box mt={2} p={8}>
  <Grid container spacing={16}>    
    <Grid item xs={2}></Grid>
    <Grid item xs={2}></Grid>
  </Grid>
</Box>

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

Is there a way to remove text from a div when the div width is reduced to 0?

Upon loading the page, my menu is initially set to a width of 0px. When an icon is clicked, a jQuery script smoothly animates the menu's width to fill the entire viewport, displaying all menu items (links) perfectly. The issue I'm facing is that ...

What is the method to have the text cursor within a text field start a few pixels in?

I need a text field with the cursor starting a few pixels (let's say 4) from the left-hand side. I am aware that this can be achieved by adjusting the size of the text field using padding, but I am curious if there is a way to resize the text box with ...

How can I display a pre-existing div with a dropdown button?

I have individual div elements for each type of clothing item (shirt, pant, suit) that I want to display when the corresponding service is selected. This means that when I click on one of them, only that specific div will be shown. I am looking for a solut ...

Wrapping text in MathJax through React implementation (using material-ui and react-mathjax-node)

I have been experimenting with word wrapping and have come up with the code below. import React from "react"; import Typography from "@material-ui/core/Typography"; import { makeStyles } from "@material-ui/core/styles"; import ...

How can I implement Material UI icons in my project?

While using the Material UI table, I encountered an issue with the font color being white, making it difficult to read the text. However, upon selecting the text, the data is visible but there seems to be a problem with the icons as well. Even though I hav ...

Is the Google Material Design Grid duplicating its own layout?

Currently, I am attempting to incorporate Material's layout grid for a web project. However, I have encountered an issue where the width (in this case 33.33%) specified for the columns is being replaced by the same class with width: auto;. Can anyone ...

Having trouble with React updating the Array object?

I am facing an issue with my application where the selected seats are not greying out as expected when the user clicks on "reserve." It seems like the object array of seats is not updating properly, and the isReserved property is toggling back and forth ...

Trigger the fire event on .click() except when text is being selected

I am currently working on a chat box project and I want the input field within the message area to automatically get focused when the user clicks anywhere in the chat box. However, I don't want this functionality to interfere with text selection for c ...

Modify the border in jQuery if a specific div exists within a list item

Here is a collection of items: <div class="wine"> <H1>Title</H1> <div class="promotion"></div></div> <div class="wine"> <H1>Title</H1> </div></div> <div class="wine"> <H1>Title& ...

Adjust the margins of datalabels in React Apexcharts for better spacing

I am currently utilizing the React Apexcharts library to generate a chart. My issue lies in trying to incorporate space around the datalabels within a pie chart. Is there anyone who could provide guidance on this matter? const pieChartOptions = { label ...

Intercommunication of Functions between Parent and Child Components

I am facing an issue with passing a callback function between parent and child components. The child component in question is a list of numbers, and I am attempting to implement a pagination component. However, when clicking on a number in the list, I rece ...

Exploring CSS3 for Creating Stylish Navigation Bars

Currently, I am attempting to design a Navigation bar that resembles the style shown in this image, complete with a drop-down menu feature. Here is how I have structured my menu: <nav> <ul> <li> <a href="/i ...

An issue arises on iOS related to React-Codegen within the project's Pods directory, citing an explicit dependency on the target 'React-Codegen' that has been halted

After executing the command on my Mac M1 terminal to run the react-native app in iPhone 15 Pro simulator, I encountered the following error: PhaseScriptExecution [CP-User]\ Generate\ Specs /Users/databasket/Library/Developer/Xcode/DerivedData/DbA ...

I specialize in optimizing blog content by omitting the final line within a React framework

https://i.stack.imgur.com/WKOXT.png Currently, I have 4 lines and the 5th line in the current input field. This is my React code snippet: import { FC, useEffect, useState } from "react"; interface BlogWitterProps {} const BlogWitter: FC<B ...

React does not allow objects as children, but what if it's actually an array?

My function is encountering an error message that reads: "Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead." I am struggling to understand why this error is occurring. ...

The issue of the Dropdown Menu Not Remaining Fixed While Scrolling

There is a challenge with a Datetime Picker Dropdown Menu not staying in place when the user scrolls. Previous attempts to use .daterangepicker {position: fixed !important;} have been unsuccessful, causing the Datetime Picker to not stay fixed in its posit ...

Creating a fixed-size set in React with randomly ordered elements

I am currently working on a project where I need to retrieve a random array from a .json file using React. My goal is to create 16 cards, each displaying a number that appears twice. To ensure uniqueness, I am utilizing a Set, but I am facing an issue with ...

React - Received an unexpected string containing a template expression with no curly braces present in the string

Currently, I am enrolled in a React tutorial online. I have inputted the code exactly as it was shown on the screen. Strangely, it seems to be working perfectly fine in the video but not when I try it myself. Below is the code snippet: <Link to={&apos ...

Implement a hover animation for the "sign up" button using React

How can I add an on hover animation to the "sign up" button? I've been looking everywhere for a solution but haven't found anything yet. <div onClick={() => toggleRegister("login")}>Sign In</div> ...

Encountering issues while attempting to connect to Metamask using React and Next.js

I'm currently working through a tutorial on creating an NFT marketplace using Next.js, and I've hit a roadblock when it comes to implementing a button that should open MetaMask. From what I understand, calling 'connectWallet('injected&a ...