What is the best way to create an interactive menu icon that includes dropdown options using MUI menu features?

i am looking to create a component similar to this

currently, I am utilizing a material UI pop menu in my project

below is the JSX code snippet

<div className="navMenu" style={{ position: "relative" }}>
        <Tooltip title="Menu">
          <div
            className="navMenuIconContainer"
            style={{
              boxShadow:
                anchorMenu === null
                  ? ""
                  : "rgba(60, 64, 67, 0.2) 0px .1rem .2rem 0px, rgba(60, 64, 67, 0.05) 0px .1rem .3rem .1rem",
              color: anchorMenu === null ? "black" : "#e57373",
              zIndex: "2",
            }}
            onClick={toggleMenu}
          >
            <BiMenu style={{ cursor: "pointer" }} size={"2.5rem"} />
          </div>
        </Tooltip>
        <Menu
          id="menu-appbar"
          anchorEl={anchorMenu}
          open={Boolean(anchorMenu)}
          onClose={closeMenu}
          PaperProps={{
            style: {
              borderRadius: ".1rem",
              boxShadow:
                "rgba(60, 64, 67, 0.2) 0px .1rem .2rem 0px, rgba(60, 64, 67, 0.05) 0px .1rem .3rem .1rem",
              zIndex: "1",
              transform: "translateX(-.5rem)",
            },
          }}
        >
          <MenuItem sx={{ fontSize: "1.1rem" }} onClick={closeMenu}>
            Contact us
          </MenuItem>
          {location[2] === "analysis" ? (
            <MenuItem sx={{ fontSize: "1.1rem" }} onClick={generateQuery}>
              Query
            </MenuItem>
          ) : (
            <MenuItem sx={{ fontSize: "1.1rem" }} onClick={dashboard}>
              Dashboard
            </MenuItem>
          )}

          <MenuItem sx={{ fontSize: "1.1rem" }} onClick={handleSignOut}>
            Sign out
          </MenuItem>
        </Menu>
      </div>

the necessary imports are as follows

import { Tooltip, Menu, MenuItem } from "@mui/material";

this is what I achieved with the aforementioned code

I'm struggling to differentiate those two elements with box shadow, as I attempted to make that component appear as one cohesive unit but failed. The issue lies in positioning the burger icon above the options paper with appropriate z-index, which proved to be challenging for me.

below is the CSS for the container divs

.navMenu{

  }
  .navMenuIconContainer{
    position: relative;
    width : 3rem;
    height : 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
  }

I would appreciate it if someone could offer a proper solution

here is the link to the sandbox containing my attempt

https://codesandbox.io/s/headless-morning-m9uf6o?file=/src/styles.css

Answer №1

When working with the Menu component as a child of the Modal component, keep in mind that the Modal has a z-index of 1300. To ensure that the burger icon appears above the Menu component, set its z-index to a value higher than 1300.

Answer №2

Check out the latest version of sandcodebox here

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 could be causing the state to not update after the post method is executed?

My form has two inputs: one for text and another for selecting an image from my local PC. The goal is to upload the selected image to cloudinary, use the text URL to save it in the uploadedImageURL state, and then update the form state. The ultimate aim i ...

Ways to arrange comments to display the most recent ones at the top and older ones at the bottom when using Express or React

Currently, I am developing a MERN-stack Application that revolves around an Event model with multiple comments associated with each event. However, I am puzzled about how to organize these comments in such a way that the newest ones appear at the top, whil ...

Get the cookies from the NodeJs API using Next.js version 13.4

Could you please review my code? I have a Next.js and Node API app, and I'm facing an issue with obtaining the cookie from my API in my Next app. The signInUser API that I created should return a generated JWT cookie. However, when I use it in my Next ...

The message shown on items.map stating that parameter 'item' is implicitly assigned the type 'any'

Currently, I am delving into the world of Ionic React with Typescript by developing a basic app for personal use. My current challenge involves dynamically populating an IonSegment from an array. Here is the relevant code snippet: const [items, setItems] ...

Issue with displaying elements at intended layering order when parent element has fixed positioning

My web app features both upper and lower elements (div) with a position: fixed. Each element has child popups also with position: fixed. Even though I want to position the popup above its parent element, using z-index doesn't work due to inheritance ...

Tips for adding a picture to a server and applying CSS filters to enhance it

I recently came across a set of CSS filters that can be applied to images by simply specifying the filter ID. Now, I'm looking to create a button that will allow me to save the edited image (with the filter applied) to a designated file location. I&a ...

Incorporating a filtering search bar in Ionic React to efficiently sort pre-existing lists based on their titles

Struggling to implement a search bar in my Ionic application has been quite challenging. I've searched for examples and tutorials, but most of them are based on Angular with Ionic. The React example in the Ionic docs didn't provide much help eith ...

Achieving consistent width for flex items in each row

Can I ensure that all flex items have the same width? Currently, my code looks like this: .video-container { background-color: blue; min-height: 90vh; display: flex; flex-wrap: wrap; } .video { flex: 1 0 25%; } <div class="video-contain ...

Enhance the glowing spinner in a react typescript application

Recently, I transformed an html/css spinner into a react component. However, it seems to be slowing down other client-side processes significantly. You can see the original design on the left and the spinning version on the right in the image below: This ...

Ways to adjust dimensions depending on zoom level or screen size

Here is the HTML code snippet: <div id="divMainFirst"> <div id="divInnerFirst"> <div id="divTitleHeaderUC"> <span id="spanTitleHeaderUC">Urgent Care Wait Time</span> </d ...

Styling child elements in Angular using css from its parent element

I have a question: Regarding the structure below <component-parent> <first-child> <second-child> <third-child></third-child> </second-child> </first-child> </component-parent> Now I want t ...

Enable multiple machines to access the stream

I have a small camera connected via USB to my Raspberry Pi 3b+. I want to live stream the camera feed over the internet (or local network) to any device that visits a specific address. In terms of software setup, the Raspberry Pi is running a basic Flask ...

You are limited to storing only up to 2 items in the localStorage

My goal is to save items in local storage as an array of objects. Initially, it works perfectly and stores the first element in local storage as needed. However, I am facing an issue where I cannot store more than one element. Below is the code block that ...

Running the gulp uncss command with regex to ignore specific elements is not functioning as expected

I have been attempting to integrate uncss into my gulp workflow. In order to exclude certain classes, such as those added through javascript, I am specifying these classes with "ignore" (specifically, I am trying to remove the css from the jquery plugin m ...

Creating unique custom 404 error pages for specific sub-directories within NextJS using the App Router Structure

Having trouble with my custom 404 error page (= not-found.tsx) files. I have two of them, one within app/(paths) and another within app/(paths)/(jobs)/jobs/(cats). The issue is that the first not-found file should render when a user visits url example myap ...

How to set custom column width for each element using react-masonry

To create a unique grid layout using react-masonry, refer to the documentation provided at https://mui.com/material-ui/react-masonry/ By default, the column widths are equal when generating the grid. For instance, with 3 columns, each column will occupy 3 ...

Implementing a line break within a JavaScript function specifically designed for formatting images

As I am not a javascript developer, the code I have been given for debugging is somewhat challenging. The issue at hand involves an iOS module where a .js CSS file has been set up and images are loading improperly, resulting in the need for horizontal scro ...

Utilizing TypeScript Generics to Dynamically Set Tag Names in React

I am working on a straightforward polymorphic React component that is designed to render only tag names (such as span) and not custom React components (like MyComponent). I believe this can be achieved using JSX.IntrinsicElements. Here is the code snippet ...

Production pages encounter 'get' error when refreshed due to routing issues - Node.js, Express API with webpack and ReactJS frontend

I have set up my webpack configuration to compile my react app, and I am using Node.js as the server with Express middleware. Whenever I try to refresh a route on the production environment, for example /chefs, I receive an error. Below is my server.js s ...

Is it possible to ensure only one value is set as true in useReducer without manually setting the rest to false

I am seeking a more efficient method to ensure that only one value is set to true while setting the rest to false I came across this Python question and answer recommending an enum (I am not very familiar with that concept) Currently, I have the followin ...