What is the best way to place Material UI Popper at the bottom right corner of the screen?

Currently utilizing Material UI version 4.9.1 which includes a React component called Popper, based on Popper.js version 1.14.1.

The goal is to display a small square card at the bottom right corner of the browser.

Ordinarily, using plain CSS, the following can be done.

.card {
    position: 'fixed';
    bottom: 0;
    right: 0;
}

Attempts have been made to achieve the same using the Popper component without success. The current implementation is as follows.

<Popper
    open={anchor !== null}
    placement="bottom-end"
    anchorEl={anchor}
    popperOptions={{positionFixed: true}}
    modifiers={{
        // Potential need for modifiers?...
    }}
>
    {/* card component */}
</Popper>

Setting anchor = document.body upon button click, along with the following styles in index.html.

html, body {
    width: 100%;
}

Despite these configurations, the Popper appears in the top right corner with these styles applied to the div.

position: fixed;
top: 0px;
left: 0px;
transform: translate3d(1164px, 5px, 0px);
will-change: transform;

Any insights on what might be missing in this implementation?

Answer №1

Take a look at the offset documentation

<Popper
  className='popper-root'
  open={open}
  anchorEl={anchorEl}
  placement='bottom-end'
  modifiers={{
    offset: {
    enabled: true,
    offset: '0, 30'
   }
  }}
>

Answer №2

Consider applying css directly to the Popper element.

<Popper
    open={anchor !== null}
    style={{ position: 'fixed', bottom: 0, right: 0, top: 'unset', left: 'unset' }}
>
    {/* card component */}
</Popper>

However, creating your own component may be a better solution as this functionality doesn't seem too complex to implement without using Popper.

Answer №3

To address the issue, simply delete the anchorEl={anchor} prop or set it to undefined. This way, the popper content will become a child of the <body> tag. Also, be sure to review the disablePortal prop (default is false) as mentioned in the official documentation: https://material-ui.com/api/popper/#props.

I hope this solution resolves the problem for you!

Answer №4

If there isn't sufficient room under the body, the Popper can show up in the upper corner. It could be wrapping around and showing up at the top instead. Experiment with setting the height of your body to 50% to see if it displays below it.

Answer №5

When utilizing the @mui/x-date-pickers module version "^6.5.0", be sure to include the following in the slotProps:

popper: {
          placement: "bottom",
         },

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

Retrieving JSON information and refreshing the display

Currently, I am utilizing OnsenUI in conjunction with AngularJS to create a searching application. On page1, the user inputs the data they wish to search for. Upon clicking the search button, page1 is added to the stack and a background GET request is trig ...

Player using unexpected options instead of Video.js options

I have created a basic HTML page with a small JavaScript snippet to function as a playlist, and it was working perfectly fine. However, when I integrated Video.js into the mix, an issue arose. Sometimes, upon reopening the page, the player fails to load p ...

Unforeseen Issues Arising from Media Queries

Trying out some new styling for different screen sizes based on the bootstrap grid system dimensions. Facing an issue where only certain styles apply while others don't seem to take effect. Here's a snippet of the CSS: @media only screen and ( ...

Retrieving data from the database without the need to reload the page

Hi there! I have a PHP script that fetches data from a database and I want to display this data within a div element with a "link" class without having to reload the page. Check out the code snippet below: <? include('config.php'); $rs = m ...

"Entering a text message will prompt the appearance of the on-screen keyboard in capital

Our website is optimized for use on Android tablets. I have added the following CSS to the input's class: text-transform: uppercase; While this successfully displays typed letters in uppercase, it does not change the appearance of the on-screen keyb ...

Depending on external software packages

Can you explain the potential risks associated with using third-party packages and npm in a broader sense? If I were to install a third-party package like semantic-ui-react using npm, is there a possibility that I may not be able to use it on my website i ...

Command in Selenium Webdriver for initiating a mouse click

Currently, I am in the process of writing tests for a Java application that has been created with the Vaadin framework. To conduct these tests, I have opted to utilize the Robot Framework. In certain instances, I must implement robot framework commands suc ...

Attempting to center two divs to start at the same point

I've been attempting to center align two divs and have them start at the same position using CSS. Below is the inline CSS code. The first div is named container and the second div is named descriptionarea. #container { width: 60%; ...

How can I achieve the functionality of an image changing when clicked and going back to its original state upon release with the help of HTML

I am facing an issue with styling an element to look like a button and function as a clickable link. My goal is to create a visual effect of a pressed button when it is clicked, while also loading the target page. For reference, here is a (non-working) J ...

The positioning of drawings on canvas is not centered

I'm facing an issue while attempting to center a bar within a canvas. Despite expecting it to be perfectly centered horizontally, it seems to be slightly off to the left. What could possibly be causing this discrepancy? CSS: #my-canvas { border: ...

Fluid percentage-based layout

I have four separate Divs that I would like to position on my page in a specific layout. Here is an image showing how I want them positioned: https://i.sstatic.net/KBZ1U.png In the future, I plan to add multiple svg files to Div 4 and I want it to be scro ...

"Navigation Side Menu: w3-sidebar with hamburger toggle feature

If you are looking to implement the w3-sidebar, you can find it here: https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_sidebar_over The existing code uses a "hanburger" icon to open the side menu and a "Close X" menu item to close it. To simpl ...

Verify that a certain number of checkboxes are left unchecked

I have a collection of checkbox input elements in my HTML: <input type="checkbox" id="dog_pop_123"> <input type="checkbox" id="cat_pop_123"> <input type="checkbox" id="parrot_pop_123"> My requirement is to check if none of these checkbo ...

The initial value for the `useState` is not defined at the

Here's a simplified version of my requirement that demonstrates the issue. The ColorBox component receives a prop called "isVisible" from the ShowColorComponent component, which is used to initially set the state of the ColorBox.visible variable. impo ...

Using VueJS to showcase user input in a dynamic list and a pop-up modal

I am attempting to achieve the following: Use a v-for loop to display form input (name, position, company) as an unordered list, showing only the name input and a button for each person When a button is clicked, a modal will appear displaying all the data ...

The Bootstrap glyphicon content breaks when using ASP.NET MVC minification

When working with asp.net, I noticed that minification tends to disrupt the display of bootstrap UTF symbols. For example, here is what it looks like in the original file: .glyphicon-edit:before { content: "\e065"; } And here is how it appears in ...

How can I verify if a date is after the current date using Node.js?

I am struggling to set up date validation that ensures the date is after the current date. This is what I have attempted so far: Router.post('/home', [ check('due_date') .isDate() .isAfter(new Date.now()) .wi ...

Is it possible to invoke an action within a reducer function?

I'm attempting to trigger an action in the redaction process and struggling to grasp the concept. ... import { loaderStart, loaderStop } from '../actions/loaders'; const loaders = dispatch => ({ loaderStart: text => dispatch(loader ...

It appears that using JQuery's .when and .done functions may result in the code executing before the script has finished loading

Since updating the hard-coded <script> with JQuery promises, I have been encountering these errors frequently: https://i.stack.imgur.com/xkWAk.png The issue seems to be inconsistent in replicating. Sometimes, the error occurs while loading the page ...

Alert: Attempting to invoke the setState method on an unmounted component

While running unit tests with Jest, I encountered a warning when attempting to change the setState input value. The warning message says: "Can't call setState on a component that is not yet mounted. This is a no-op, but it might indicate a bug in you ...