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

Having trouble with my React private route, can't seem to get it to function properly

I'm fairly new to React, and I've set up a private route with an authToken passed through props from the state of App.js. The idea is that if the authToken is true, the private route should direct me to /HomePage, but whenever I log in with valid ...

Adjust the horizontal background-position transition for color change while scrolling using jQuery and CSS

I came across a fascinating website - - where the background-position changes on scroll() from a linear gradient with two colors to smoothly slide one color off the screen. While I grasped how they achieved the split colors using linear-gradient, I'm ...

Prevent redirection on buttons within ionic lists

THE ISSUE: I am facing an issue in my Ionic app where I am using the ion-list component. Each item in the list can be swiped to reveal a button (add/remove to favorites). Additionally, each item serves as a link to another page. The problem arises when ...

Reduce the number of divs on a webpage while incorporating animated transitions

I've been attempting to incorporate an animation on the width property for my div .panels. I've tried using transition-property in CSS and also with .animate() in jQuery, but unfortunately, it doesn't seem to be working. I also noticed that ...

Is it better to define a function within useEffect or externally?

What is the reason behind defining the fetchData function inside the useEffect instead of outside? Link: https://github.com/zeit/next.js/blob/canary/examples/with-graphql-faunadb/lib/useFetch.js import { useState, useEffect } from 'react' exp ...

An effective method to arrange divs in a line adjacent to each other

Apologies for the repetitive question, but I am in need of some answers. In my opinion: Having 1 div with a width of 100% and 2 divs inside each with a width of 50%. Why does it not fit properly? HTML: <div id="top-menu"> <div id="logo">& ...

Child element casting shadow over parent element

I am currently using box shadow for both the parent (.map) and child (.toggle-button): .map { position: fixed; top: 20px; right: 0; width: 280px; height: 280px; z-index: 9999; box-shadow: 0px 1px 6px 0px rgba(0,0,0,0.3); } .map ...

Sharing a single return value from MUI useScrollTrigger across several components: How to do it?

Currently, I am utilizing MUI's useScrollTrigger hook to control the visibility of three elements - NavBar, a post FAB, and a back to top button as shown below: export default function NavBar() { const isScrolledDown = useScrollTrigger({ target: win ...

Can you explain the meaning of the ?. operator in JavaScript?

While using react-hook-form, I encountered the ?. operator. Can you explain its meaning? Here's an example of how it works: <span>{errors?.name?.message}</span> The errors variable is obtained from useForm() by destructuring, as shown bel ...

Tips for sending status codes to the client side using Redux asyncThunk

I am seeking a way to retrieve the status sent by my Express server within my React component. I have implemented redux for dispatching a login fetch request and aim to dynamically render different children based on the received status code (e.g., display ...

Modifying various states within React using the useState() hook

Curiosity strikes me - what actually happens when I modify more than one state in a handler function? Will they be updated simultaneously, or will the changes occur sequentially? const [x, setX] = useState(0) const [y, setY] = useState(0) const handlerFu ...

What is the process for deselecting text from a text field?

After performing a search and displaying the results on my search form, I've noticed that the text query in the textfield is being marked as selected text even though I don't want it to be. How can I prevent this? Fiddle 1) What is the best app ...

Determining the browser width's pixel value to enhance responsiveness in design

Lately, I've been delving into the world of responsive design and trying to grasp the most effective strategies. From what I've gathered, focusing on content-driven breakpoints rather than device-specific ones is key. One thing that would greatl ...

Concealing divisions on a website with CSS styling

In my div, I have some text that I want to hide. <div style='visibility:hidden;' id='emailid'>$email</div> Although the visibility attribute successfully hides the text, it leaves behind empty space on the webpage where th ...

The FileReader encountered an error because the first parameter is not a 'Blob' type

I seem to be encountering an issue with a javascript FileReader that is throwing the error Uncaught TypeError: Failed to execute 'readAsDataURL' on 'FileReader': parameter 1 is not of type 'Blob'. This problem occurs intermitt ...

Struggling to align Social Media Share Buttons in inline format for a website

I'm having trouble aligning these social media share buttons with my inline list. I tried using vertical-align: top; on the <li> element, but it didn't work in Chrome. You can view the page here: Here is the full HTML/CSS code: <!DOCT ...

Tips for updating the Material-Table (Material-UI) component in ReactJS after modifying the data

I am currently utilizing material-table within my ReactJS project, and after reviewing its documentation, I am uncertain about how to refresh the table when the data is constantly changing (like every 500ms or so). Any guidance on this would be greatly app ...

Connection lost from JS client in Twilio's Programmable Chat

My React application utilizes the Twilio Programmable Chat library for chat functionality. The setup code typically appears as follows, enclosed within a try/catch block: this.accessManager = new AccessManager(twilioToken.token); const chatClientOptio ...

'jQuery' is not recognized as defined, error no-undef

I am currently working on a file that utilizes jQuery for testing purposes: (function($) { "use strict"; // Start of use strict // Configure tooltips for collapsed side navigation $('.navbar-sidenav [data-toggle="tooltip"]').tooltip({ ...

Tips for altering the selected color of a checkbox?

I'm trying to change the color of my checked checkbox to green and also adjust the size, but for some reason, only the size is changing in my code. I even attempted using `:checked:after` without success. input[type='checkbox']{ width: 1 ...