1.1.0 • Published 7 years ago

react-native-view v1.1.0

Weekly downloads
34
License
MIT
Repository
github
Last release
7 years ago

react-native-view

A lightweight View component that can be styled quickly.

Installation

$ npm install react-native-view --save

then

import View from 'react-native-view';
/*...*/
<View vcenter hcenter>
/*...*/
</View>

Usage

Align content

Example

  • center children horizontally
<View hcenter>
/*...*/
</View>

alt text

  • align children to the left
<View hstart>
/*...*/
</View>

alt text

  • center children horizontally and vertically
<View vcenter hcenter>
/*...*/
</View>

alt text

Available props:

propdescription
hstartAlign children to the left
hcenterCenter children horizontally
hendAlign children to the right
vstartAlign children to the top
vcenterCenter children vertically
vendAlign children to the bottom
flexApply flex: 1
rowBecomes a row (column by default)
stretchStretch the view to fill parent
spreadSpread children evenly along the orientation with padding
pushSpread children evenly along the orientation without padding

More examples:

  • spread
<View spread hcenter>
/*...*/
</View>

alt text

  • push
<View push hcenter>
/*...*/
</View>

alt text

Padding

By default paddings can be set using breakpoints:

namevalue in px
sm5
md15
lg30
xl45

Also, you can specify where paddings are applied using directional suffixes: l - left | r - right | t - top | b - bottom:

Example

  • 15px padding top and left

<View mdpt mdpl>
</View>

alt text

  • 5px padding on all sides

<View smp>
</View>

alt text

License

MIT