1.0.15 • Published 4 years ago

react-styled-grid-layout-test v1.0.15

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

React Styled Grid Layout

 

\ Lightweight and very simple CSS Grid Layout library based on Styled Components for React, Gatsby and others.

Installation

npm i react-styled-grid-layout

Usage

import { Grid, Row, Col, Cell } from 'react-styled-grid-layout';

Examples

Correct order, everything must be wrapped in <Grid> tag.

<Grid>
    <Col>...</Col>
</Grid>
<Grid>
   <Row>
      <Cell>...</Cell>
   </Row>
</Grid>

\ Simple two columns in one row:

<Grid cols="2">
    <Col>...</Col>
    <Col>...</Col>
    <Col>...</Col>
    <Col>...</Col>
</Grid>

\ Simple four columns grid with media queries and gaps:

<Grid cols="12" gap="10px">
    <Col xxl="3" md="6" sm="12">...</Col>
    <Col xxl="3" md="6" sm="12">...</Col>
    <Col xxl="3" md="6" sm="12">...</Col>
    <Col xxl="3" md="6" sm="12">...</Col>
</Grid>

\ You can easily position content within the <Row> container using align and justify props:

<Grid cols="12" gap="10px">
    <Row height="400px">
        <Cell align="center" justify="center"> Center </Cell>
        <Cell align="center"> Left Center </Cell>
        <Cell align="end" index="2"> Left Bottom </Cell>
    </Row>
</Grid>

\ React function component example:

import React from 'react';
import { Grid, Row, Col, Cell } from 'react-styled-grid-layout';

const Grids = () => {
  return (
    <>
      <Grid cols="4">
        <Col> 1 </Col>
        <Col> 2 </Col>
        <Col> 3 </Col>
        <Col> 4 </Col>
      </Grid>

      <Grid>
        <Row>
          <Cell> 1 </Cell>
          <Cell> 2 </Cell>
        </Row>
      </Grid>
    </>
  );
};

export default Grids;

All props

<Grid>...</Grid>

PropsCSSDefaultTest
rows :numbergrid-template-rowsauto<Grid rows="1fr auto 100px ...">
colsgrid-template-columnsrepeat(12, 1fr)<Grid cols="12">
gapgrid-gap0<Grid gap="25px">

<Col>...</Col>

PropsBreakpointsTest
xxl :number5120px<Col xxl="3">
xl1200px<Col xl="6">
lg992px<Col lg="3">
md768px<Col md="12">
sm576px<Col sm="12">
xs320px<Col xs="12">

\

PropsCSSDefaultTest
row :numbergrid-rowauto<Col row="1">
spangrid-column-end1<Col span="2">
from togrid-column: from / tonone<Col from="1" to="12">
widthmax-widthnone<Col width="50%">
heightmin-heightauto<Col height="500px">
alignalign-self: start, center, endstart<Col align="center">
justifyjustify-self: start, center, endstart<Col justify="center">
texttext-align: left, center, rightleft<Col text="center">

<Row>...</Row>

PropsCSSDefaultTest
heightmin-heightauto<Row height="50px">

<Cell>...</Cell>

PropsCSSDefaultTest
alignalign-self: start, center, endstart<Cell align="center">
justifyjustify-self: start, center, endstart<Cell justify="center">
indexz-index: num1<Cell index="1">
widthmax-widthauto<Cell width="100px">

Github repository

https://github.com/koniecznytomek/react-styled-grid-layout

git clone https://github.com/koniecznytomek/react-styled-grid-layout

Live demo

https://react-styled-grid-layout.netlify.app/

Case study

alt text

alt text

alt text

alt text

1.0.2

4 years ago

1.0.17

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago