Skip to content
Advertisement

How to align Material-UI Menu items?

I use the menu and menu item of material-ui to build a select dropdown menu, but I found one thing strange: the dropdown menu always expand to the left side of the box, as the image shown below: enter image description here

I’ve tried to use the alignItems property inside my <MenuItem> but it didn’t work.

My code is shown below. Can anybody help me to fix this problem? I really appreciate your help!

JavaScript

Advertisement

Answer

The default styles controlling this are in ListItem where it specifies justifyContent: ‘flex-start’.

You can change this to be right aligned with:

JavaScript

Here’s a full working example:

JavaScript

Edit MenuItem align right

Related documentation:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement