As the screen size shrinks, two components merge together

One issue I'm facing with my site is the component called NavPanel. This consists of two components - a back button (BackToButton) and a search field (SearchTextField). Everything looks fine on a standard screen size, but when the screen size decreases, these components start to overlap.

I would prefer it if the second component (SearchTextField) could be positioned under the first one (BackToButton) when the screen size is reduced. Do you have any suggestions on how I can achieve this?

    const Style = {
    paddingLeft: '8%',
    paddingRight: '8%',
    minHeight: '70px',
    alignItems: 'center',
    flexWrap: 'nowrap',
    whiteSpace: 'nowrap'
}

export default function NavPanel() {
    
    return (
        <Grid container sx={Style}>
            <BackToButton />
            <SearchTextField />
           
        </Grid>
    );
}

Answer ā„–1

Here is the solution...

You may need to revisit your implementation of the grid.

Check out the modified code snippet here.


UPDATE 1

A:

B:


UPDATE 2

To resolve the issue, consider changing the breakpoint from sm to md. This adjustment will affect the stacking order of elements like PageNameBackToButton and FilterButtonSearchTextField, but it will prevent scenario A.

View the revised snippet here.

PageNameBackToButton Component

// Code for PageNameBackToButton component
// ...

FilterButtonSearchTextField Component

// Code for FilterButtonSearchTextField component
// ...

Filter Component

// Code for Filter component
// ...

Answer ā„–2

<Grid container> is essential with <Grid item>s nested inside.

Similar to Bootstrap,

Utilizing a grid system maintains consistency in layouts while providing flexibility for diverse designs. Material Design's responsive UI adopts a 12-column grid layout.

Your code snippet would resemble this:

<Grid container spacing={1} sx={Style}>
  <Grid item xs={12} sm={6}>
    <BackToButton />
  </Grid>
  <Grid item xs={12} sm={6}>
    <SearchTextField />
  </Grid>
</Grid>

I highly recommend exploring the MUI Grid Docs.

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

Change the state within the click event handler

One issue I'm facing is dealing with 2 submit buttons in my react form. To differentiate between the two buttons, I need to extract the `id` of the one that was clicked using the `onClick` function. Currently, when trying to set the state with this ` ...

In order to showcase an image ahead of another (stay tuned),

Help! I'm facing a dilemma here. I have an abundance of adorable animal images with unique facial expressions, but there's one problem - the eyes are hidden! I desperately want to showcase those captivating eyes. This is what my code looks like. ...

What is the best way to dynamically adjust row sizes in react-bootstrap?

I have successfully created a grid of cards in groups of three using react-bootstrap. However, I am facing an issue where if one card's height is longer than the others, it creates unnecessary space and disrupts the layout of the entire row. You can s ...

Gatsby: A guide on inserting unadulterated HTML within the head section

Is it possible to insert raw HTML into the <head></head> section of every page in a Gatsby.js project? I need to add a string of HTML for tracking purposes, including inline and external script tags, link tags, and meta tags. For example, here ...

Could Google Adsense be causing issues with my website's navigation bar?

There seems to be an irritating bug that I've come across. While navigating my website, [the menu (located in the top right corner) functions correctly]. However, when you land on a page with a Google AdSense ad, the menu suddenly appears distorted ...

Setting the backEnd URL in a frontEnd React application: Best practices for integration

Hey there - I'm new to react and front-end development in general. I recently created a RESTful API using Java, and now I'm wondering what the best way is to specify the backend URL for the fetch() function within a .jsx file in react. Currently, ...

Show text and image side by side on the same row

I am looking to showcase both image and text on the same line, similar to how it's done on tripadvisor.in/ <div style="display:inline-block"> <div style="display:inline;float:left"> <a href="CollegeProfile.php" class="white"> <h ...

Step-by-step guide on achieving rounded borders with a gap:

Struggling to design blocks and elements with rounded corners that have a gap between the corner and the straight line. It's proving to be quite challenging :) Additionally, I need to create buttons that look like this, and If CSS alone doesn' ...

"Implement a feature in Material-UI to conceal input fields and set character limits for minimum and maximum

I'm looking to add a text input field and sign up button, with the password entered in the field hidden for security reasons. Any suggestions on how I can achieve this feature? Additionally, I want to restrict the field so that passwords less than 5 ...

Why won't the main bar column in Bootstrap extend to the entire width of the page?

I've set up a basic row with two child columns: the sidebar column with className='col-md-2' and the mainbar column with className='col-md-10'. The parent row has a display:flex property to position the two children side by side. & ...

What is stopping me from updating the state within the componentDidUpdate method, even when a condition is met?

Currently, I am comparing props within the componentDidUpdate and attempting to update the state. Following that, I need to fetch some data which is dependent on certain state parameters. componentDidUpdate(prevProps) { if (prevProps.location.search.sp ...

asking for the generation of fresh frames in kepler.gl

Is there a way to trigger the rendering of a new frame in kepler.gl? I have implemented an animated deck.gl layer following the vis.academy tutorial: I have successfully integrated this layer with kepler.gl as well, but I noticed that kepler.gl updates t ...

Need to send emails to two separate users? Look no further than Resend.com for a quick and

I am currently utilizing resend.com to send an email containing different variables to two distinct users. import type { NextApiRequest, NextApiResponse } from "next"; import { EmailTemplate } from "../../components/emails/EmailTemplate" ...

Displaying negative values highlighted in red on Datatables platform

After successfully integrating the datatables on my VF page, I now have one final requirement: to display any negative values in red and bold within numerical columns. In my Salesforce implementation, I am using <apex:datatable> for my table. Each nu ...

Exploring domain routing in Next.js with sub-domains

I am currently working on translating my Next app according to the specific subdomain. For instance, I want en.hello.com to display content in English, while it.hello.com should show content in Italian. I have been attempting to accomplish this using Next ...

Creating a mandatory 'Select' component in Material UI with React JS

Is there a method to show an error message in red until a choice is selected? ...

Error Message: Undefined Constructor for Firebase Google Authentication

Hey there! I've been working on integrating Firebase google authentication into my project. Unfortunately, I encountered an error while testing it out. Here's the error message that appeared in the console: Uncaught (in promise) TypeError: Cannot ...

deactivating image mapping on mobile media screens

I'm looking to disable my image map on mobile screens using media queries. I've attempted to include some javascript in the head of my html file, but I encountered an error: <script src="http://code.jquery.com/jquery-1.11.3.min.js"></s ...

Axios delivers the index.html data to the front end of a React.js application

Iā€™m currently in the process of developing a web application using React.js for the front-end and Flask for the back-end. I attempted to establish a connection between the two by defining a proxy server in React and enabling CORS in Flask. Everything was ...

Having trouble implementing the Material UI time picker because it does not meet the required DateTime format

REVISE I recently switched my dataType from DateTime to TimeSpan in my code. I have a functioning MVC version that already uses TimeSpan, and the times are posted in HH:MM format. Now, I am unsure if the issue lies with the headers set up on Axios or if it ...