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

What causes the Ref object to prompt a rerender in this code?

Check out the amazing react-native animation demo on https://reactnative.dev/docs/animated const fadeInOut = useRef(new Animated.Value(0)).current // Initial opacity value: 0 React.useEffect(() => { Animated.timing( fadeInOut, { ...

When a function is called, retrieve a specific number of elements from an array using the slice method in

If I have an array of 15 objects, but I am only displaying 5 on the browser using this code: const displayedArray = array.slice(0,4) I also have a function that will load another 5 objects each time a user scrolls down. displayedArray.concat(array.slice ...

The exported variable 'SAlert' is utilizing the name 'AlertInterface' from an external module

Utilizing the antd alert component (ts) with styled components import styled from 'styled-components'; import Alert from 'antd/es/alert'; export const SAlert = styled(Alert)` && { margin-bottom: 24px; border-radiu ...

What method does Apple use to apply overflow:hidden to elements within position:fixed?

After conducting my own experiments and delving into the topic online, I discovered that elements using position: fixed do not adhere to the overflow: hidden property of their parent element. This also applies to children within the fixed positioned elemen ...

How can I create a Material ui Card with a border-less design?

After reviewing the information provided, I noticed that you can set the option to have it as variant="outlined" or raised However, I am curious if there is a method to create the card without any visible borders at all? ...

How to retrieve multiple checked values from checkboxes in Semantic UI React

Trying to enable users to select multiple checkboxes in react using semantic-ui-react. I am new to react. Here is my code: class ListHandOver extends React.Component { state = { data: {} } handleChange = (e, data) => { console.log( ...

"Production environment encounters issues with react helper imports, whereas development environment has no trouble with

I have a JavaScript file named "globalHelper.js" which looks like this: exports.myMethod = (data) => { // method implementation here } exports.myOtherMethod = () => { ... } and so forth... When I want to use my Helper in other files, I import it ...

What could be causing my hover effect to function exclusively on Chromium-based browsers and not on Firefox?

Could use some help with this code snippet .podmenu { display: flex; flex-direction: column; list-style: none; width: 10rem; margin-left: 3rem; margin-bottom: 60px; } .verze { list-style: none; flex-direction: column; ...

Encountering a Typescript error when trying to invoke a redux action

I have created a redux action to show an alert message export const showAlertConfirm = (msg) => (dispatch) => { dispatch({ type: SHOW_ALERT_CONFIRM, payload: { title: msg.title, body: msg.body, ...

How can I convert the left links in my navigation bar to a CSS drop-down menu to make it more responsive on small screens?

Here is the structure of my HTML (at the top): <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></s ...

Securing access across multiple routes in a React application

I am facing a challenge in my React app where I need to verify the logged-in state before allowing access to multiple routes. Despite consulting various resources like Stack Overflow for solutions such as creating a Private Route, I have only found example ...

Hide or show list items in an unordered list using jQuery

I am interested in creating a script that can toggle between "show more" and "show less" functionality for elements in a list. I came across this script: HTML <ul id="myList"> <li>One</li> <li>Two</li> <li> ...

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 ...

How to create a stunning Bootstrap Jumbotron with a blurred background that doesn't affect the

I need help making my Jumbotron image blurry without affecting the text inside it! Below is the code from my index.html and style.css files. Any assistance would be greatly appreciated. body { background-image: url(bg1.png); background-repeat: repea ...

Any tips on customizing the appearance of `NavigationBar()` and `NavigationBarItem()` in Jetpack Compose?

I'm struggling to modify the colors of selected and unselected icons as well as the active indicator. Unfortunately, the documentation lacks examples or detailed explanations, and my online searches have not yielded any helpful results (please share a ...

The same HTML/CSS appears with varying appearances

I have encountered an issue where I created two identical pages, with one page calling the other through a link. Surprisingly, my top menubar changes significantly between the two pages, even though the HTML/CSS code is exactly the same. <html> < ...

babel-node encountered an error: 'Reference error - window has not been defined'

I recently took on the challenge of incorporating server-side rendering into a React application. After following a tutorial from this source, I attempted to replicate the steps on the actual project. While everything went smoothly with client-side ...

Using React.js in combination with JWT, Socket.io for user authentication

I've been working on implementing Socket.io in React with an Express Backend that uses JWT (Passport JWT) for authentication. While my regular routes work fine with authorization handled correctly, I'm struggling to include the Bearer Token when ...

Troubleshooting the "Uncaught Error: 't' is read-only" issue in MUI DataGridPro

My attempt to utilize MUI DataGridPro is encountering an issue where instead of rendering my data, I receive an "An error occurred" message. The data is hardcoded into the component, so its absence is not the problem. The console displays the following er ...

Anchor positioning within Firefox Mobile (for Android)

I created a homepage with multiple sections, each linked to from the main menu: <body> <header> <!-- nav used on all pages --> <a href="#nav" class="toggle-nav"> menu <i class="fa fa-bars">< ...