[Autocomplete] How to customize the popper width?
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Summary 💡
Currently, the PopperComponent
width is always set to anchorEl.clientWidth
:
I would like to be able to customize that so the dropdown can be a different width. It would probably make sense to also expose the placement
of the popper. I’m not sure if it makes more sense to just expose PopperProps
– I saw in this issue that you’re not the biggest fan of that approach: https://github.com/mui-org/material-ui/issues/18885#issuecomment-566494202
Examples 🌈
The search box on the material-ui docs is an example of where the dropdown is a different width than
Motivation 🔦
I have content in my dropdown that is wider than the search box and it currently has an annoying wrap. Also, having the textbox width expand with css like in the material-ui documentation can result in a mis-aligned and too-small popper.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:8 (3 by maintainers)
This worked for me (as a new component created outside of a render function):
then
You can provide a custom
PopperComponent
prop to change the positioning logic.