What is the best way to arrange the second div in the second row, while the first and third div are displayed on the first row within the MUI appbar

I have 3 components in the appbar, 1. Logo 2. Search Input 3. Login Buttons

When viewing on desktop, all three components will be in a single row as shown below

https://i.stack.imgur.com/FYMEH.png

Below is my code snippet:

export default function NavBar(props) {
return (
<>
  <CssBaseline />
  <HideOnScroll {...props}>
    <AppBar elevation={0}>
      <Container sx={{ pl: { xs: '5px', sm: '5px', md: '16px' }, pr: { xs: '5px', sm: '5px', md: '16px' } }}>
        <Toolbar sx={{ pl: { xs: '0px', sm: '0px', md: '16px' }, pr: { xs: '5px', sm: '5px', md: '16px' } }}>
  
          //First Part
          <Typography sx={{ fontWeight: 600, display: { xs: 'inline-block', sm: 'inline-block', md: 'inline-block' } }}>LOGO</Typography>
          
          //Second Part
          <InputSearch />

          //Third Part
          <DivRight>
            <IconButton sx={{ color: '#fff' }} size='large' aria-label="add to shopping cart">
              <AddShoppingCartIcon />
            </IconButton>
            <Button variant="outlined" size='small' sx={{backgroundColor:'#fff', height:'30px', borderColor:'#fff'}}>Login</Button>
          </DivRight>
  
  </Toolbar>
      </Container>
    </AppBar>
  </HideOnScroll>
</>
)
}

In the second part of the appbar, I want the search input component to be displayed on a separate second row.

Answer №1

To enhance the layout, I suggest eliminating the <Toolbar> container and utilizing flex box along with some new styles. Check out this live demo for reference.

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

Able to successfully access user account on Postman, however encountering login issues when trying to do

If I can successfully log in a user using Postman, does that indicate there is a bug in my front end code? Encountered CastError: Casting to string failed with value "{ email: '[email protected]', password: '123456' }" (type Objec ...

Navigating a JSON message received from a websocket: Best practices

How can I cycle through various types of JSON messages received from WebSocket and trigger a function based on the type to modify observables in MobX? Can anyone assist with this? For instance, one of the simple messages looks like this: { name: "as ...

Implementing a Custom CSS Theme in JavaFX

Hey everyone, I stumbled upon this amazing JavaFX theme called Flatter on . I've been attempting to implement it for a couple of hours now, but I'm struggling with the process. Can someone provide me with a detailed guide on how to activate thi ...

ReactJS incorporates multiple CSS files

I am currently working on developing a Single Page Application using ReactJS. However, I am facing an issue with styling. Currently, I have created 3 different pages (with the intention of adding more in the future), each having its own CSS file that is im ...

Enzyme fails to locate text within a div even though it is present

In my current test scenario, I have a set of data displayed in Material-UI Cards. The data is provided through a JSON array consisting of objects with fields like projectName, crc, dateCreated, createdBy, and lastModified. { projectName: 'P ...

Image remains fluid within a static div without resizing

Any assistance would be greatly appreciated. I am currently facing an issue with a fixed div that is floating at the bottom of the screen, serving as ad space for the mobile version of a website. The problem arises when attempting to resize the browser win ...

Connections transition among associated HTML pages

I am working on my very first website using HTML and I'm encountering some challenges with maintaining consistency across pages. On the top of my page, I have a div containing some links. While they function correctly, I noticed that the spacing betw ...

Rendering from the server side with dynamic client side capabilities through the power of the Next.js App Router

One common pattern I've frequently employed in NextJs involves rendering everything server-side, including data fetching, and then transitioning to dynamic client-side rendering. To illustrate this approach: export async function getServerSideProps() ...

What is causing the text below the SVG path to appear thicker?

I am encountering an interesting issue with my SVG green marker. The text inside appears bolder than the same text with the same attributes when it is standalone. Upon further inspection, I noticed that the text within the green marker looks bolder compar ...

Can you explain how to incorporate a node module script into a React.js project?

I have encountered an issue where the element works perfectly fine when using an external node module, but fails to function properly when using a locally downloaded node module. Unfortunately, I am unable to identify the root cause of this problem. You c ...

Issue with React Redux and FireStore - Updates to FireStore collection are not automatically displayed on my screen, requiring manual refresh to see

I'm currently using React alongside Redux and Firebase. Below is a snippet from my Action.js file showcasing a function: export const loadItemsInCategory = (categoryId) => { return (dispatch) => { let itemsArray = []; ...

The flow of execution context does not transition smoothly from getStaticPaths to getStaticProps as expected

Struggling to access data from a dynamic route in pages/science-and-engineering/[field].js. Using getStaticPath with getStaticProps but facing an issue where getStaticProps isn't being executed and the component isn't rendering. Only getStaticPat ...

Is there a way to retrieve both the items within a specific category and its corresponding subcategories simultaneously?

Presently, I am managing two models for Category and subcategory. The category model provides an array of data as shown below: category = [ {_id: '1', name: 'Appliances', slug: 'appliances'}, {_id: '2', na ...

Instructions for activating the click function for each individual looping image

When creating a blog page, I am using PHP to loop the like button images according to the total count of posts (example: Facebook like button). The issue I am facing is that while the PHP loop is working, when I click on the first post image, only the firs ...

Unable to solve CORS issue for authenticated request

I'm consistently encountering the CORS error when attempting a credentialed request (withCredentials: true). I have an httpproxy arrangement in place within express.js that directs traffic to multiple microservices behind it, all running on express.js ...

Next.js loses state when switching pages with Redux

I have set up the Redux state on this page: import React from 'react'; import { connect } from 'react-redux'; import styled from 'styled-components'; import wrapper from '../redux/store'; // Importing various compo ...

I am looking to incorporate a 10 px border at the top of my column by utilizing bootstrap4

How can I add a border to the top of my column using Bootstrap 4? I've been struggling with it and can't seem to get it right. Here is the code I'm currently using, which includes <div> tags for the columns: <!doctype html> &l ...

What is the best way to center align an element while having another element situated directly below it?

I want to create a grid of "clock" elements, with five clocks in each row. Below each clock, I'd like to display the DAY and DATE centered with the clock (day on top line, date below). Since I'm new to html/css, I appreciate your patience. Here&a ...

How to create a full-width and full-height background image in a div using CSS

When using a bootstrap template, I encountered an issue with adding an image as a background. Here is the CSS code: background:url(../images/banner.png) no-repeat; background-size: 100%; The problem with these CSS rules is that the image gets clipped and ...

Radio buttons have been concealed and are not visible

Tried the solutions recommended in a previous question about radio buttons not showing in Safari and Chrome, but unfortunately, it did not solve my problem. It seems like this issue is different from the one discussed in that question. The WordPress them ...