I used MaterialUI's Grid in my React app to split my page into two panes. The right side has two input boxes and a submit button. I'm using spacing={3} to provide spacing among the inputs and the button.
Initial code - https://codesandbox.io/s/cool-morning-mh302
Next, I used react hook form to add a form around the right Grid elements - https://codesandbox.io/s/fervent-chaum-0qgb6
Problem: Adding the <form> removes the spacing provided by the Grid. How can I wrap the input and button within <form> without affecting the original layout (styling/spacing provided by the Grid)?
UPDATE: As one of the answer suggests, I prefer not to hoist the <form> before the Grid.
- I feel it is hacky to apply it to non-form elements.
- In the future, I might have to support two forms inside the grid.