By design, clicking on a material-ui <Select> component (or alternatively a <TextField select> component), causes the menu items to appear in a position which covers the originating Select/TextField element.
<Select ...>   <MenuItem value={10}>Ten</MenuItem>   <MenuItem value={20}>Twenty</MenuItem>   <MenuItem value={30}>Thirty</MenuItem> </Select> Is it possible to override this positioning (whether with JSS or with a new composition) such that the menu items align themselves directly under the originating Select/TextField element?
Any guidance would be appreciated. Thank you.
By design, clicking on a material-ui <Select> component (or alternatively a <TextField select> component), causes the menu items to appear in a position which covers the originating Select/TextField element.
Material UI has other types of Select(native) also where you can just use plain HTML required attribute to mark the element as required. It also works with non-native Select, as it is placed in the FormControl tag. When I place the "required" in the FormControl I get the " * " so it looks required.
anchorEl: It is used to set the position of the menu.
Menus display a list of choices on temporary surfaces. A menu displays a list of choices on a temporary surface. It appears when the user interacts with a button, or other control.
Use MenuProps attribute of Select element
     <Select             MenuProps={{               anchorOrigin: {                 vertical: "bottom",                 horizontal: "left"               },               transformOrigin: {                 vertical: "top",                 horizontal: "left"               },               getContentAnchorEl: null             }}      >       <MenuItem value={10}>Ten</MenuItem>       <MenuItem value={20}>Twenty</MenuItem>       <MenuItem value={30}>Thirty</MenuItem>     </Select> The position of <MenuItems> is default under the Material-ui <Select> in Mui v5.
If want to change position, code sample :
<Select> and set menu items position:        <Select           ...           MenuProps={{             anchorOrigin: {               vertical: "bottom",               horizontal: "left"             },             getContentAnchorEl: null           }}         > <TextField select> and set menu items positon:      <TextField         ...         select={true}         SelectProps={{           MenuProps: {             anchorOrigin: {               vertical: "bottom",               horizontal: "left"             },             getContentAnchorEl: null           }         }}       > Code Sample :
Hope to help you !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With