Move the Material UI popover to the clicked icon's position

I am looking to create a popover similar to the image linked below. When the icon is clicked, I want the popover to display with the same user interface. https://i.sstatic.net/yvKjF.png

Here is the code snippet that I have been using:

{showPopOver && (
              <Popover
                open={showPopOver}
                onClose={(e) => {
                  if (showPopOver) {
                    e.stopPropagation()
                    toggleModal()
                  }
                }}
                anchorEl={imageRef?.current}
                anchorOrigin={{
                  vertical: `top`,
                  horizontal: `center`,
                }}
                transformOrigin={{
                  vertical: `top`,
                  horizontal: `center`,
                }}
                PaperProps={{
                  style: { width: "400px", height: "300px" },
                }}
              ><POPOVER CONTENTS........>


</popover>
)}

The issue I am facing is that the popover overlaps the icon when it appears.

Can anyone provide guidance on how to position the popover above the icon with the v(callout)?

Any suggestions or solutions to this problem would be greatly appreciated.

Answer №1

In order to adjust the origin of <Popover .>, you can modify it by including the transformOrigin property. Follow this example:

transformOrigin={{ horizontal: "left", vertical: -20 }}

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

Is it possible for me to include additional fields in a vuetify calendar event?

Is there a method to incorporate additional fields, such as a description, in addition to the name and start/end time for an event on the v-calendar's day view? ...

I encountered an error with npm install while attempting to deploy my React website on Netlify

Hi there! I am in need of some assistance. I am encountering an error while trying to host my ready website on Netlify due to an npm install issue. Can anyone guide me on how to resolve this problem? Below are the error comments: 12:28:19 AM: Installing N ...

What is the reason for the consistency in the effects of vertical align: text bottom and vertical align: bottom?

The baseline positioning of a line box is impacted by all elements within that line. .short-box { width: 30px; height: 30px; background-color: pink; display: inline-block; } .box { background-color: ...

A guide on navigating through an array nested within an object

I have been diving into the world of ReactJS, experimenting with different APIs to fetch and manipulate data. Currently, I am working with the Flickr API which returns data structured as "An array inside an object". { "photos": { "page": 1, "page ...

Is it possible that the use of excessive React.Fragment could impact performance negatively?

After a recent review of our company's code, I discovered that the performance is not up to par. One common pattern I noticed in the code is something like this: condition ? <SomeComponent /> : <></> I see that Fragments are being u ...

What is the most effective method for creating posts, pages, and their corresponding URLs using Next.js and MongoDB

Here's a glimpse of my MongoDB data: { "_id": { "$oid": "630f3c32c1a580642a9ff4a0" }, "title": "this is a title", "paragraph": "this is a paragraph" } Now, let's t ...

React: Reload the page just one time when a variable is modified

I am encountering an issue with my isVisible variable that contains a boolean value. Whenever this variable changes, I want to trigger a reload of the component, but just once. If the variable changes again later on, I need to perform another single reload ...

How to organize a scalable business software using React?

Many of us are familiar with enterprise web applications that serve as the backbone for business data. These applications consist of multiple modules accessed through a single login authentication and role-based authorization system. Instead of users loggi ...

Encountering a getStaticProps error while using Typescript with Next.js

I encountered an issue with the following code snippet: export const getStaticProps: GetStaticProps<HomeProps> = async () => { const firstCategory = 0; const { data }: AxiosResponse<MenuItem[]> = await axios.post( ...

Having trouble with the React component "PersistLogin" during testing

I have a simple test set up: describe('App', () => { it('displays headline', async () => { render(<App />, { wrapper: BrowserRouter }); expect(screen.getByText('Welcome to Mentor Blog')).toBeInTheDocument ...

My Gatsby website is being rendered in its HTML form on Netlify

The website build is located at . It appears that the javascript functionality is not working, and only the html version (usually meant for search engines) is being displayed. It seems like this issue is only affecting the home page. You can check out the ...

Utilizing a CSS file within a YAML configuration in R Quarto

Is there a way to reference a css file from a yaml file in my R Quarto Book? The css file defines the theme for my Quarto document, and I want all our Quarto docs to have the same appearance. When I directly call the css file, I can customize aspects like ...

How can I show the configuration in Laravel?

After updating my pages to utilize an extended header for consistent content across all pages, I encountered an issue with the footer configuration. Whenever I attempt to retrieve a configuration from Laravel, it appears as normal text instead of being pro ...

Creating fluid designs for my boxes with CSS to enhance responsiveness

I have designed my HTML file with 8 boxes that appear correctly on desktop, but when viewed on mobile devices, the columns are misaligned and shifted to the right side instead of being centered. How can I make it more responsive? See Preview Here is the ...

What is the reason behind encountering these errors while trying to run my Gatsby development server?

I'm currently working on the part three tutorial provided by Gatsby on their official website and I've encountered a problem. Upon executing the command gatsby new tutorial-part-three https://github.com/gatsbyjs/gatsby-starter-hello-world I rec ...

Issue with Chrome related to svg getScreenCTM function

Check out the jsFiddle demo I am attempting to utilize the getScreenCTM function to retrieve the mouse position based on SVG image coordinates. It seems to work in IE and Firefox, but not in Chrome. When I define the attributes width and height in the SV ...

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

How does CSS affect the size and performance of a website?

Examining the content of this css file (focusing on the last 5 lines specifically): #page section .s_1 { overflow:hidden; width:435px; float:left;} #page section .s_1 h1 { font-size:36pt; color:#001744; line-height:1.1; margin-bottom:64px;height:107px;} # ...

Steps to create a zigzagging line connecting two elements

Is it possible to create a wavy line connecting two elements in HTML while making them appear connected because of the line? I want it to look something like this: Take a look at the image here The HTML elements will be structured as follows: <style&g ...

Choosing a box will cause a dashed rectangle to appear when the mouse is selected

Whenever I try to select an option in my select box, a dotted rectangle appears. How do I remove this feature? https://i.sstatic.net/BzsL2.png I have noticed that many others are also facing the same issue. I tried updating my CSS with some properties ba ...