Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override Material-UI Popover Paper styles?

Basically, i'm trying to override a style which is automatically introduce in my program. When i use Popover, automatically i have MuiPopover-paper styles in my program, i have to change some styles in this class, but how??

.MuiPopover-paper {
    outline: none;
    position: absolute;
    max-width: calc(100% - 32px);
    min-width: 16px;
    max-height: calc(100% - 32px);
    min-height: 16px;
    overflow-x: hidden;
    overflow-y: auto;
}

code part

const styles = (theme: Theme) => {
  return createStyles({
    notifications: {
      width: 449,
      height: 400,
      overflow: 'auto'
    },
    settings: {
      width: 300,
      height: 360
    }
  })
}
like image 263
Bruno Frigeri Avatar asked Jul 26 '19 21:07

Bruno Frigeri


People also ask

How do you override styles in material UI?

Overriding styles with class names If you want to override a component's styles using custom classes, you can use the className prop, available on each component.

How do you style menu in MUI?

to use the withStyles higher-order component to style the menu. To style the menu items, we can style it with the withStyles higher-order component. We set the color with one from the theme parameter. Then we can use them all in our App component.

How do you set the popover width in material UI?

You can either change the className to style, and it should work or you're going to have to add a const variable and hook it into the withStyle HOC. Then add the height and width to that const, and then call the class you made in that to the className. All these examples are on the material-ui site.

How do you close popover MUI?

I can close a popover by clicking outside of a popover.


1 Answers

One of the ways to overwrite the style of a component is to use the rule name of the classes object prop. As you can see from the MUI API documentation for Popover, you can overwrite the styles applied to the Paper component:

    <Popover classes={{ paper: "MuiPopover-paper" }} />
like image 81
cOkO Avatar answered Oct 22 '22 14:10

cOkO