I am looking to use Flexbox to separate my components on the screen in a way that positions them correctly. I have 3 rows with textfields that need specific ratios related to the full width:
- row 1 : 2, 1, 1
- row 2 : 1, 1
- row 3 : 1, 1, 2
I attempted to achieve this using flexGrow and the width of the Box component but was unsuccessful.
Expected result: https://i.sstatic.net/JYZVa.png
Current result: https://i.sstatic.net/TFl0e.png
The code I used is as follows:
<Box display="flex" p={1} bgcolor="background.paper">
<Box m="0.5em" width={"50%"} bgcolor="grey.300">
<TextField value="Half" fullWidth></TextField>
</Box>
<Box m="0.5em" width={"25%"} bgcolor="grey.300">
<TextField value="Quarter" fullWidth></TextField>
</Box>
<Box m="0.5em" width={"25%"} bgcolor="grey.300">
<TextField value="Quarter" fullWidth></TextField>
</Box>
</Box>
<Box display="flex" p={1} bgcolor="background.paper">
<Box m="0.5em" width={"50%"} bgcolor="grey.300">
<TextField value="Half" fullWidth></TextField>
</Box>
<Box m="0.5em" width={"50%"} bgcolor="grey.300">
<TextField value="Half" fullWidth></TextField>
</Box>
</Box>
<Box display="flex" p={1} bgcolor="background.paper">
<Box m="0.5em" width={"25%"} bgcolor="grey.300">
<TextField value="Quarter" fullWidth></TextField>
</Box>
<Box m="0.5em" width={"25%"} bgcolor="grey.300">
<TextField value="Quarter" fullWidth></TextField>
</Box>
<Box m="0.5em" width={"50%"} bgcolor="grey.300">
<TextField value="Half" fullWidth></TextField>
</Box>
</Box>
Is there a solution to properly align the textfields?