Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacing and Margin Utility in React-Bootstrap

I am React Js beginner. Are there spacing and margin utility classes in React Bootstrap like we have in Bootstrap mt-4,p-5,mx-auto etc. I am going through the documentation of react-bootstrap, also searched on many platforms but couldn't find the right answer. Just want to know if they exist.

like image 433
pooja Avatar asked Dec 13 '18 09:12

pooja


People also ask

How do I give a space in react bootstrap?

e - for classes that set margin-right or padding-right in LTR, margin-end or padding-end in RTL. x - for classes that set both *-left and *-right. y - for classes that set both *-top and *-bottom. blank - for classes that set a margin or padding on all 4 sides of the element.

How do you use margins in react?

To add padding and margin to all React Material-UI components, we can use the Box component. We use Material UI's Box component to add a container with margin and padding. We set the margin on all sides with the m prop and we set the top padding with the pt prop.

How do I change the spacing between lines in bootstrap?

If you need to separate rows in bootstrap, you can simply use . form-group . This adds 15px margin to the bottom of row.

What is spacing in bootstrap?

Bootstrap includes a wide range of shorthand responsive margin, padding, and gap utility classes to modify an element's appearance. On this page. Margin and padding. Notation.


2 Answers

You can use Bootstrap, just add the class of Bootstrap to the component and it will work like normal. For example for component Header:

class Header extends React.Component {
 <div className='mt-5'> //margin-top 5px

 {..content here}
 </div>
}

Remember to add the Bootstrap to your project at index.html file

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
like image 159
Tony Bui Avatar answered Sep 19 '22 05:09

Tony Bui


The space utility converts shorthand margin and padding props to margin and padding CSS declarations. The props are named using the format {property}{sides}.

Where property is one of:

m - for classes that set margin

p - for classes that set padding

Where sides is one of:

t - for classes that set margin-top or padding-top

b - for classes that set margin-bottom or padding-bottom

l - for classes that set margin-left or padding-left

r - for classes that set margin-right or padding-right

x - for classes that set both *-left and *-right

y - for classes that set both *-top and *-bottom

blank - for classes that set a margin or padding on all 4 sides of the element

For more information, you can visit: https://mui.com/system/spacing/

like image 27
Joseph Bermudez Avatar answered Sep 21 '22 05:09

Joseph Bermudez