This is NOT-JUST-ANOTHER-GRID-LAYOUT library! We are trying to simplify flexbox with easier approach.
npm install react-native-easy-grid --save
import { Col, Row, Grid } from "react-native-easy-grid";
<Grid>
<Col></Col>
<Col></Col>
</Grid>
Note: If you don't assign the size property, it defaults to equal width (or height) with its siblings
<Grid>
<Row></Row>
<Row></Row>
</Grid>
<Grid>
<Row size={75}></Row>
<Row size={25}></Row>
</Grid>
This is exactly same as
<Grid>
<Row size={3}></Row>
<Row size={1}></Row>
</Grid>
Same concept applies to
<Col />
<Grid>
<Col></Col>
<Col></Col>
<Col></Col>
</Grid>
<Grid>
<Row size={2}></Row>
<Row size={1}></Row>
<Row size={1}></Row>
</Grid>
1 | 2 |
3 |
<Grid>
<Col>1</Col>
<Col>
<Row>2</Row>
<Row>3</Row>
</Col>
</Grid>
<Grid>
<Col style={{ width: 40 }}> Fixed width </Col>
<Col> Fluid width </Col>
</Grid>
<Grid>
<Row style={{ height: 40 }}> Fixed width </Row>
<Row> Fluid width </Row>
</Grid>
Do you think anything could be simpler than that? This repo is part of our bigger project called NativeBase.io. Do check that!
Note: If you're using
<Row />
inside a<ScrollView />
, the height of the component would be flexible according to the content, though you can always apply theheight
styling.