Grid is a 2-dimensional layout system, meaning that it can handle both columns and rows, that helps you design grid-based user interfaces, unlike <Stack>
which is largely a 1-dimensional system.
Usage
import { Grid } from 'nr1'
Examples
Basic
<> <Grid> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={1}> <div className="nr1-RedBox">1</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={2}> <div className="nr1-RedBox">2</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={6}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnSpan={6}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnSpan={12}> <div className="nr1-RedBox">12</div> </GridItem> </Grid></>
Medium gap type
<> <Grid gapType={Grid.GAP_TYPE.MEDIUM}> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> </Grid></>
Small gap type
<> <Grid gapType={Grid.GAP_TYPE.SMALL}> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={3}> <div className="nr1-RedBox">3</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> </Grid></>
Columns
<Grid> <GridItem columnStart={1} columnEnd={6}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={2} columnEnd={7}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={3} columnEnd={8}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={4} columnEnd={9}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={5} columnEnd={10}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={6} columnEnd={11}> <div className="nr1-RedBox">6</div> </GridItem> <GridItem columnStart={7} columnEnd={12}> <div className="nr1-RedBox">6</div> </GridItem></Grid>
Collapse gap
<> <Grid> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4} collapseGapBefore> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4} collapseGapBefore collapseGapAfter> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4} collapseGapAfter> <div className="nr1-RedBox">4</div> </GridItem> <GridItem columnSpan={4}> <div className="nr1-RedBox">4</div> </GridItem> </Grid></>
Props
REQUIREDnode | Grid items to display.Up to 12 items are allowed. |
string | Appends class names to the component.Should be used only for positioning and spacing purposes. |
boolean | Expands the grid to occupy all available height. |
boolean | Expands the grid to occupy all available width. |
enum | Size of the gap between columns and rows. |
enum[] | Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like <Array of |
object | Inline style for custom styling.Should be used only for positioning and spacing purposes. |
string | Adds a Note: You might not see |