1.0.9 • Published 3 years ago

sc-css-grid-system v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

sc-css-grid-system

Simple CSS grid system component built with styled component for react.

Demo

storybook link

Installation

Using npm:

$ npm install sc-css-grid-system --save-dev

Usage

sc-css-grid-system utilizes the power of CSS grid and styled-components to easily create responsive grids.


For a simple 12 column layout:

import {Grid} from 'sc-css-grid-system';

function CssGridSystem() {
    return (
        <Grid xs={12}>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>
            <div>9</div>
            <div>10</div>
            <div>11</div>
            <div>12</div>
        </Grid>
    );
}

Render as: 12 column layout


Grid column span:

import {Grid, GridCol} from 'sc-css-grid-system';

function CssGridSystem() {
    return (
        <Grid xs={5} gap={30}>
            <GridCol>1</GridCol>
            <GridCol xs={2}>2</GridCol>
            <GridCol>3</GridCol>
            <GridCol>4</GridCol>
        </Grid>
    );
}

render as: col span example


Responsive Grid:

import {Grid} from 'sc-css-grid-system';

function CssGridSystem() {
    return (
        <Grid xs={2} sm={3} md={4} lg={6} xl={12} gap={30}>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
            <div>5</div>
            <div>6</div>
            <div>7</div>
            <div>8</div>
            <div>9</div>
            <div>10</div>
            <div>11</div>
            <div>12</div>
        </Grid>
    );
}

render as: Hnet-image (1)


Responsive Grid Gap:

import {Grid} from 'sc-css-grid-system';

function CssGridSystem() {
    return (
        <Grid xs={4} gap={{xs: 10, sm: 25, md: 40, lg: 60, xl: 80}>
            <div>1</div>
            <div>2</div>
            <div>3</div>
            <div>4</div>
        </Grid>
    );
}

render as:

responsive-grid-gap


**Breakpoints follows mobile first approach. Just like you would do in any other popular frameworks. ***

Grid Breakpoints

xssmmdlgxl
Default≥576px≥768px≥992px≥1200px

Props

Grid Props

NameTypeDescription
xsnumberdefault
smnumbernumbers of columns when screen is >=576px
mdnumbernumbers of columns when screen is >=768px
lgnumbernumbers of columns when screen is >=992px
xlnumbernumbers of columns when screen is >=1200px
gapnumbergap/gutter between grid rows and columns
rowGapnumbergap/gutter between grid rows
colGapnumbergap/gutter between grid columns
colWidthnumberminimum column width

GridCol Props

NameTypeDescription
xsnumberdefault
smnumbermake an element span n columns when screen is >=576px
mdnumbermake an element span n columns when screen is >=768px
lgnumbermake an element span n columns when screen is >=992px
xlnumbermake an element span n columns when screen is >=1200px

License

MIT

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago