When the page loads i want to InputLabel
to be like in the second picture, but I didn't find any InputLabel
props to do it,i did use the focused
prop but it didn't work the way i wanted
And one more question according to the M-Ui docs when shrink
prop is true the InputLabel
should shrink but it's doing the opposite (that's the result I want but I thought shrink={false}
would do that)
<FormControl className={styles.formControl} variant="outlined">
<InputLabel shrink={true} focused={true}>States</InputLabel>
<Select native
value={value}
onChange={inputEvent}
label="States"
>
{fetchedStates.map((states, i) => (
<option key={states + i} value={states}>
{states}
</option>
))}
</Select>
</FormControl>
You can use the autoFocus
prop to keep the focus on your Select
component.
<Select
autoFocus
open={this.state.open}
value={this.state.age}
onChange={this.handleChange}
>
Demo: https://codesandbox.io/s/material-demo-w6dyf?file=/demo.js
Reference: https://github.com/mui-org/material-ui/issues/9599#issuecomment-437697170
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.