how to disable autocomplete auto position?
want to show autocomplete options always bottom.
https://codesandbox.io/s/material-demo-forked-t1luy?file=/demo.js
how to disable autocomplete auto position?
want to show autocomplete options always bottom.
https://codesandbox.io/s/material-demo-forked-t1luy?file=/demo.js
Add popper props with modifiers:
<Autocomplete
id="combo-box-demo"
options={top100Films}
/* ...yourProps */
componentsProps={{
popper: {
modifiers: [
{
name: 'flip',
enabled: false
},
{
name: 'preventOverflow',
enabled: false
}
]
}
}}
renderInput={(params) => (
<TextField {...params} label="Combo box" variant="outlined" />
)}
/>
For the current latest version of MaterialUI, you can use the property disablePortal
to achieve behavior when a popup with a list of options will always be shown on the bottom
Should be something like this
<Autocomplete
id="combo-box-demo"
options={top100Films}
getOptionLabel={(option) => option.title}
style={{ width: 300, paddingTop: 300 }}
disablePortal={true}
renderInput={(params) => (
<TextField {...params} label="Combo box" variant="outlined" />
)}
/>
For MUI v5, if you're trying to use the "disablePortal" prop, as it should work on previous versions of MUI, what worked for me is to simply remove the "disablePortal" prop, which automatically set the placement of the dropdown list to "bottom" for any number of elements in the list.
You can do it with flexbox
You can wrap your Autocomplete
component with a div
and add the below style
<div style={{display: 'flex', alignItems: 'flex-end'}}>
<Autocomplete
id="combo-box-demo"
options={top100Films}
getOptionLabel={(option) => option.title}
style={{ width: 300}}
renderInput={(params) => (
<TextField {...params} label="Combo box" variant="outlined" />
)}
/>
</div>