Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MUI - correcting the position in select box dropdown

I'm using MUI component in react js app.

I'm trying to adjust the position of dropdown menu in select component.

As the shown image, the dropdown menu is a bit moved to right. I want to move it back to the left end.

enter image description here

        <Select
            value={value}
            label={label}
            multiple={multiple}
            onChange={onChange}
            MenuProps={{
                PaperProps: {
                    sx: {
                        maxHeight: { md: 500, xs: 300 },
                        width: { xs: '100%', lg: 'unset' },
                        '&.MuiPaper-root': {
                            left: '-8px',
                        },
                    },
                },
            }}
        >
            <MenuItem value={10}>Ten</MenuItem>
            <MenuItem value={20}>Twenty</MenuItem>
            <MenuItem value={30}>Thirty</MenuItem>
            
        </Select>

I tried to move it to the left by writing '&MuiPaper-root': {left: '-8px'}, but it automatically overwrites my code as it is showned in console.

like image 786
Takuya Avatar asked Dec 06 '25 18:12

Takuya


1 Answers

You just need to to add !important flag to prevent MUI from overwriting your styles:

 '&.MuiPaper-root': {
    left: '-8px !important',
  },
like image 170
Artur Minin Avatar answered Dec 08 '25 06:12

Artur Minin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!