Home

Awesome

react-native-view

A lightweight View component that can be styled quickly.

NPM

Installation

$ npm install react-native-view --save

then

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

Usage

Align content

Example

<View hcenter>
/*...*/
</View>

alt text

<View hstart>
/*...*/
</View>

alt text

<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:

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

alt text

<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

<View mdpt mdpl>
</View>

alt text

<View smp>
</View>

alt text

License

MIT