• Stars
    star
    558
  • Rank 79,819 (Top 2 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Grid system based on styled-components and flexbox for React

react-styled-flexboxgrid

npm version Build Status NPM Status js-standard-style

Set of React components that implement flexboxgrid.css but with styled-components/emotion. Furthermore, it allows to customize grid configuration like gutter width...

Highly inspired by the excellent react-flexbox-grid which the API is nearly the same than this module.

Demo

Usage

Installation

npm i -S react-styled-flexboxgrid

react-styled-flexboxgrid depends on 2 peer dependencies:

  • react@^0.14.0 || ^15.0.0-0 || ^16.0.0-0
  • prop-types@^15.0.0-0
  • styled-components@2

You should install them in your project.

Basic

import React from 'react'

import {Grid, Col, Row} from 'react-styled-flexboxgrid'

const App = props =>
  <Grid>
    <Row>
      <Col xs={6} md={3}>Hello, world!</Col>
    </Row>
  </Grid>

Grid

The <Grid> component is optional and can help to wrap children in a fixed/fluid container. Use the configuration container for fixed width value.

Props
  • fluid (Boolean): Create a responsive fixed width container or a full width container, spanning the entire width of your viewport. Default: false

Row

Props
  • reverse (Boolean): Use flex-direction: row-reverse. Default: false
  • start
  • center
  • end
  • top
  • middle
  • bottom
  • around
  • between
  • first
  • last (String(xs|sm|md|lg): Align elements to the start or end of row as well as the top, bottom, or center of a column.

Col

Props
  • reverse (Boolean): Use flex-direction: column-reverse. Default: false
  • xs
  • sm
  • md
  • lg (Boolean|Integer):
    • When true, enable auto sizing column.
    • When false, hide colomn for the breakpoint.
    • When integer value, it specify the column size on the grid. (1 to 12)
  • xsOffset
  • smOffset
  • mdOffset
  • lgOffset (Integer): Offset the column.

Configuration

The grid use same defaults than flexboxgrid.css.

You can customize values using <ThemeProvider> component from styled-components. react-styled-flexboxgrid will looks at the flexboxgrid property in the theme.

import React from 'react'

import {ThemeProvider} from 'styled-components'
import {Grid, Col, Row} from 'react-styled-flexboxgrid'

const theme = {
  flexboxgrid: {
    // Defaults
    gridSize: 12, // columns
    gutterWidth: 1, // rem
    outerMargin: 2, // rem
    mediaQuery: 'only screen',
    container: {
      sm: 46, // rem
      md: 61, // rem
      lg: 76  // rem
    },
    breakpoints: {
      xs: 0,  // em
      sm: 48, // em
      md: 64, // em
      lg: 75  // em
    }
  }
}

const App = props =>
  <ThemeProvider theme={theme}>
    <Grid>
      <Row>
        <Col xs={6} md={3}>Hello, world!</Col>
      </Row>
    </Grid>
  </ThemeProvider>

Use with Emotion

To use react-styled-flexboxgrid with emotion, import from 'react-styled-flexboxgrid/emotion':

import { Grid, Col, Row } from 'react-styled-flexboxgrid/emotion'

Related projects

License

MIT

More Repositories

1

material-ui-color-picker

<ColorInput> component for material-ui
JavaScript
90
star
2

yup-locales

Localizations for yup
TypeScript
49
star
3

alpine-wkhtmltopdf

Experimental Alpine Docker Image with wkhtmltopdf headless
43
star
4

angular-io-barcode

Angular wrapper for io-barcode
JavaScript
30
star
5

awesome-pouchdb

A collection of awesome PouchDB libraries, plugins, resources and shiny things.
28
star
6

cf-wkhtmltopdf

Coldfusion Wrapper for wkhtmltopdf
ColdFusion
16
star
7

alpine-nginx

nginx built from source on Alpine Linux
Shell
14
star
8

PDFKitJS

HTML+CSS to PDF in Node.JS
JavaScript
13
star
9

mimetype-to-fontawesome

Convert mimetype to appropriate Font Awesome class name
JavaScript
10
star
10

aor-tinymce-input

<TinyMCEInput> component for admin-on-rest, useful for editing HTML in admin GUIs.
JavaScript
9
star
11

react-native-nprogress

A nanoscopic progress bar. With realistic trickle animations to tell your users that something's happening! Completely inspired by NProgress
TypeScript
9
star
12

handlebars-async

Make Handlebars async!
JavaScript
8
star
13

dotfiles

My dotfiles !
Shell
5
star
14

grunt-smartsprites

grunt smartsprites for nodejs
HTML
4
star
15

react-native-maps-use-cluster

A hook for managing Marker cluster for react-native-maps.
TypeScript
3
star
16

deisrc

Switch between different .deis/client.json files with ease and grace.
JavaScript
3
star
17

gatsby-plugin-sentry

Gatsby plugin to add Sentry error tracking to your site.
JavaScript
3
star
18

scrollReveal.js-0.1.3

scrollReveal.js
JavaScript
3
star
19

easy-i18n

Easy i18n for Node.js
CoffeeScript
3
star
20

datasource-manager

JavaScript
2
star
21

change-url

Tiny module to modify an URL string
TypeScript
2
star
22

ng-confirm

Simple confirm on button with built-in browser confirm.
JavaScript
2
star
23

alpine-envsubst

2
star
24

react-fetchy

TypeScript
2
star
25

select2-browserify

Select2 - For Browserify
JavaScript
2
star
26

react-native-web-spinkit

Replacement for react-native-spinkit when targeting the web.
TypeScript
2
star
27

react-admin-git-provider

Gitlab data provider for React Admin
TypeScript
2
star
28

google-compute-auto-snapshot

Automated creation of google compute disk snapshots and deletion of old ones
Shell
2
star
29

webpack-react-simple-boilerplate

Really simple boilerplate with Webpack for React dev
JavaScript
1
star
30

alpine-nginx-node

Docker will Node.js and nginx installed for building static and serving static apps
1
star
31

docker-owncloudcmd

owncloudcmd
1
star
32

combell-js

TypeScript
1
star
33

react-intl-light

A lighter version of `react-intl`
TypeScript
1
star
34

cfapi-json-gateway

JSON Gateway for Coldfusion Admin API
ColdFusion
1
star
35

docker-mysql-xtrabackup

TypeScript
1
star
36

test-gatsby-preview

Gatsby starter for a Contentful project.
JavaScript
1
star
37

data-proxy

TypeScript
1
star
38

conference-feweb-git

Git: Contrôle des versions, gestion des sources et bien plus encore...
JavaScript
1
star
39

alpine-curl

Dockerfile
1
star
40

now-nextjs-issue

TypeScript
1
star
41

hosted-swagger-ui

JavaScript
1
star
42

aor-color-picker-input

<ColorInput /> component for admin-on-rest, useful for picking color in admin GUIs
JavaScript
1
star
43

sequelize-utils

Set of utilities for Sequelize
CoffeeScript
1
star
44

dottystore

A simple key:value store that supported dotted anotation
TypeScript
1
star
45

test-multer

test repo
JavaScript
1
star
46

s3-img-uploader

Simple cli module for easily upload images to S3.
JavaScript
1
star
47

hubot-commitstrip

CommitStrip commands for Hubot
CoffeeScript
1
star
48

config-templator

Dynamic remplacment in object, inspired by GruntJS config
JavaScript
1
star