I have these components here:
Sandbox: https://codesandbox.io/s/6ipdf?file=/demo.js:78-129
JavaScript
x
36
36
1
<FormControl sx={{ m: 1 }} variant="standard">
2
<InputLabel htmlFor="demo-customized-textbox">Age</InputLabel>
3
<BootstrapInput id="demo-customized-textbox" />
4
</FormControl>
5
<FormControl sx={{ m: 1 }} variant="standard">
6
<InputLabel id="demo-customized-select-label">Age</InputLabel>
7
<Select
8
labelId="demo-customized-select-label"
9
id="demo-customized-select"
10
value={age}
11
onChange={handleChange}
12
input={<BootstrapInput />}
13
>
14
<MenuItem value="">
15
<em>None</em>
16
</MenuItem>
17
<MenuItem value={10}>Ten</MenuItem>
18
<MenuItem value={20}>Twenty</MenuItem>
19
<MenuItem value={30}>Thirty</MenuItem>
20
</Select>
21
</FormControl>
22
<FormControl sx={{ m: 1 }} variant="standard">
23
<InputLabel htmlFor="demo-customized-select-native">Age</InputLabel>
24
<NativeSelect
25
id="demo-customized-select-native"
26
value={age}
27
onChange={handleChange}
28
input={<BootstrapInput />}
29
>
30
<option aria-label="None" value="" />
31
<option value={10}>Ten</option>
32
<option value={20}>Twenty</option>
33
<option value={30}>Thirty</option>
34
</NativeSelect>
35
</FormControl>
36
I want the first input(the text input) to take all the remaining space on the page, how do I do that?
Advertisement
Answer
You can wrap the form control components using Box instead of the current div
.
JavaScript
1
8
1
<Box display="flex">
2
<FormControl sx={{ m: 1, flexGrow: 1 }} variant="standard">
3
<InputLabel htmlFor="demo-customized-textbox">Age</InputLabel>
4
<BootstrapInput id="demo-customized-textbox" />
5
</FormControl>
6
7
</Box>
8
If you think the select components have the large width, then you can set the custom width.
Refer to flexbox