Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertically aligning the button with the TextField in React Material-UI

I am using the Material-UI library for React. I am trying to make a simple form that looks like:

enter image description here

However, I can't figure out how to align the button with the TextField. I tried changing the margin-top but it increases the margin of the entire wrapper. Below is the code sandbox for it.

Any tips on getting this fixed?

https://codesandbox.io/embed/material-demo-y5eg7?fontsize=14&hidenavigation=1&theme=dark

like image 424
Dawn17 Avatar asked Jan 22 '20 22:01

Dawn17


People also ask

How do I vertically align text in material UI?

The Typography component can be vertically centered by adding display: 'flex' and alignItems: 'center' . In the Box component (and all components except Stack), default flexDirection is 'row'.

How do you align buttons in material UI?

We can align the buttons horizontally as well as vertically. We can center the button by using the following methods: text-align: center – By setting the value of text-align property of parent div tag to the center. margin: auto – By setting the value of margin property to auto.

How do you align vertically in react?

To center a component horizontally and vertically in React. js, set its display property to flex and its alignItems and justifyContent properties to center . The components's content will be horizontally and vertically centered. Copied!

How do you align a button to the right in material UI react?

Float Right or Left in MUI with Justify Content With display=”flex” applied to the MUI Box component, we can use justifyContent=”space-between” to move a Button to the far left and to the far right.


1 Answers

In your styles.css file you can add {position: relative; top: 10px} to the small-button className then adjust the top value until you are happy with the position alternatively you might be able to wrap the row in a div and use {display:flex; flex-direction:row; justify-content:center;} to align them all.

like image 199
Josh Avatar answered Sep 28 '22 03:09

Josh