Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Margin or Padding Shorthand in React Native

How to define margin/padding shorthand in React Native?

margin: 10px 20px; 
like image 738
Jeaf Gilbert Avatar asked Feb 23 '18 19:02

Jeaf Gilbert


People also ask

What is the difference between padding and margin in React Native?

The main difference between margin and padding is that margin helps to create space around the element outside the border, while padding helps to create space around the element inside the border.

Can we give margin in percentage in React Native?

minWidth ​ minWidth is the minimum width for this component, in logical pixels. It works similarly to min-width in CSS, but in React Native you must use points or percentages. Ems and other units are not supported.


1 Answers

When using plain React Native styles you can rewrite your css above to

 {   marginVertical: 10,   marginHorizontal: 20 } 

Otherwise the above syntax can be achieved if you're using something like styled-components, which uses css-to-react-native under the hood.

like image 177
rk1 Avatar answered Sep 20 '22 03:09

rk1