I am trying to customize the positioning of the Select component which opens the menu as a modal by default. I need a way to make it render inline below the controlling input. I have found this library https://iulian-radu-at.github.io/react-select-material-ui/?path=/story/reactselectmaterialui--with-and-without-fullwidth-set based on Material-UI Select, though it unfortunately doesn't work for me as I have a lot of custom styling built for my component. I have seen that the ButtonGroup component can somewhat achieve this, though I would like to avoid that as an option, because of the custom styling that I have already done. I would love to hear any suggestions, I am sure I am not the only person who has this problem. Thanks!
const useStyles = makeStyles((theme) => ({
root: {
backgroundColor: theme.palette.background.white,
margin: theme.spacing(1),
width: ({ inputWidth }) => (inputWidth ? inputWidth : `inherit`),
},
}))
export const Dropdown = ({
serviceIndex,
label,
fieldName,
value,
inputWidth,
options,
updateValue,
}) => {
const classes = useStyles({ inputWidth })
const handleChange = (event) => {
/* logic handling updates here */
}
return (
<FormControl variant="outlined" className={classes.root}>
<Box>
<InputLabel id={`select-outlined-${label}-${serviceIndex}`}>
{label}
</InputLabel>
</Box>
<Select
labelId={`select-outlined-label-${label}-${serviceIndex}`}
id={`select-outlined-label-${label}-${serviceIndex}`}
value={value || options[0]}
onChange={handleChange}
label={label}
>
{_.map(options, (option, i) => (
<MenuItem key={i} value={option}>
{option}
</MenuItem>
))}
</Select>
</FormControl>
)
}