react-native-gridstrap
The Bootstrap grid implementation for React Native
Installation
yarn add react-native-gridstrap
or
npm install react-native-gridstrap --save
Usage
Please take a look at the bro-tip below.
const Grid = // gutter size
The result of the makeGrid
function is an Object
with the following properties:
- The
Container
,Row
andCol
components:
PureComponent ... { return <GridContainer> <GridRow> <GridCol> <Text>Hey it works</Text> </GridCol> <GridCol> <Text>Yes! Sure it does</Text> </GridCol> </Gridrow> </GridContainer> }
- A set of margin and padding styles, following the gutter size definition, defined in the
styles
object. Variation is from1
to10
and includes padding and margin left, top, bottom, right, horizontal and vertical.
Example of a margin left of 9.75 times the gutter size:
stylesml975
Each variation has the 0.25
, 0.5
, 0.75
and, of course, the 1
size. Without the decimal dot.
Component props
All the components might include the style
prop to better customization if necessary.
Container
fluid
Include this prop in order to remove the gutter padding and make the container fill the width of the parent element, just like .container-fluid
on the web.
Row
No additional props.
Col
offset
Include this prop, as a number
, to make an offset column - just like the .col-offset
on the web. The offset is defined as the flex
attribute in the component style. Of course, if this prop is specified, no child
component will be rendered.
proportion
How much space from the row will this col
take. Defaults to 1
.
Bro tip
Generate the grid in another file, then just include it in your views.
Create a grid.js
file:
const Container Row Col styles =
And then, in MyView.js
:
PureComponent { return <Container fluid> <Row style=stylesmt5> <Col> <Text>It works!</Text> </Col> </Row> </Container> }