2

Material ui select how to make a dropdown so that it falls out to the top, now it always falls down I want to make it go up through api or something else but it doesn’t work

https://codesandbox.io/s/cool-zhukovsky-0ovd2q?file=/demo.tsx enter image description here

import * as React from "react"; import Box from "@mui/material/Box"; import InputLabel from "@mui/material/InputLabel"; import MenuItem from "@mui/material/MenuItem"; import FormControl from "@mui/material/FormControl"; import Select, { SelectChangeEvent } from "@mui/material/Select"; export default function BasicSelect() { const [age, setAge] = React.useState(""); const handleChange = (event: SelectChangeEvent) => { setAge(event.target.value as string); }; return ( <Box sx={{ position: "relative", top: "200px", minWidth: 10 }} > <FormControl fullWidth> <InputLabel id="demo-simple-select-label">Age</InputLabel> <Select labelId="demo-simple-select-label" id="demo-simple-select" value={age} label="Age" onChange={handleChange} > <MenuItem value={10}>Ten</MenuItem> <MenuItem value={20}>Twenty</MenuItem> <MenuItem value={30}>Thirty</MenuItem> </Select> </FormControl> </Box> ); } 

1 Answer 1

2

You can use MenuProps like this:

 <Select labelId="demo-simple-select-label" id="demo-simple-select" value={age} label="Age" onChange={handleChange} MenuProps={{ anchorOrigin: { vertical: "top", horizontal: "right" }, transformOrigin: { vertical: "bottom", horizontal: "right" }, sx: { mt: "-15px", ml: "5px" } }} > 
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, where did you find this property, I can't find it in the documentation( anchorOrigin and transformOrigin
Hey! You can find MenuProps here mui.com/material-ui/api/select, but the other here mui.com/material-ui/api/popover it is weird because they do not appear in the Select props

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.