gridus
A semantic flexbox grid made with stylus. It provides seven mixins with the higher powers of flexbox.
Note: Is fully recommended the use of autoprefixer-stylus along with gridus, because it adds all vendor-prefixers necessary to flexbox works on every modern browser.
Table of contents
Installation
First of all install the gridus package using npm.
$ npm install gridus
Alternatively, you can install gridus with yarn.
$ yarn add gridus
Import
The easiest way to use gridus is by importing the file directly.
@import 'node_modules/gridus/gridus'
Stylus CLI
To use gridus with the stylus cli you can use the following command.
$ stylus src/styl --out dist/css --use gridus
Stylus API
Simply require the stylus module and type. See the documentation for more info.
Alternatively, you can use the render function.
stylus;
Gulp
To use gridus with gulp, you can use gulp-stylus and include gridus in use option.
const gulp = ;const stylus = ;const gridus = ;gulp
Support
Gridus has the same support that flexbox feature has. See the support at Can I Use.
Basic usage
In the parent node of all grids you must specify the behaviour of the container, if it will behaviour like a column or like a row.
// The grid will behave like a row.row ) // The grid will behave like a column.column )
After that you can specify the behaviour of the cells by adding as many as you want mixins in the container.
.row ) ) // optional ) // optional .column ) ) // optional ) // optional
After that just create the cells and it's behaviuor.
.cell ) ) // optional ) // optional
Mixins
Align
The align mixin accepts three value 'start', 'center' and 'end'. If passed any different value a error will be throwed.
'start' value
If included in a row will make the elements be aligned horizontally on the top. If included in a column will make the elements be aligned vertically on the left.
.align-start 'start')
The output from code above is.
'center' value (default)
If included in a row will make the elements be aligned horizontally on the center. If included in a column will make the elements be aligned vertically on the center.
.align-default ).align-center 'center')
The output from code above is.
'end' value
If included in a row will make the elements be aligned horizontally on the bottom. If included in a column will make the elements be aligned vertically on the right.
.align-end 'end')
The output from code above is.
Cell
The cell mixin accepts four kinds of parameters.
Flex value (default)
Create a cell that will automatic size inside his parent.
.cell-default ) .cell-flex 'flex')
The output from code above is.
Fraction or percent
The size of the cell. Example: 2/5 will occupy 2 cells of a 5 cells grid.
.cell-fraction 2/5)
The output from code above is.
The minimum with of the cell
The minimum width of a cell. In that way the cells will have the minimum width specified but will occupy all the free space and have the same size in different screens.
.cell-unit 200px)
The output from code above is.
Column
The mixin column will make a container of cells behave like a column.
.column )
The output from code above is.
Gutter
The gutter mixins accepts two parameters, the first is the size of the gutter and the second is type of the gutter (inside or outside). By default the size is 1rem and the type is inside.
.gutter-default ) .gutter-size 10px) .gutter-size-outside 10px, 'outside')
The output from code above is.
Justify
The justify mixin accepts five different values 'center', 'left', 'right', 'between' and 'around'. Between and around will distribute the space between the elements or around the elements.
.justify-default ) .justify-start 'start') .justify-end 'end') .justify-center 'center') .justify-around 'around') .justify-between 'between')
The output from code above is.
Offset
The mixin offset will add a margin left to the cell, so this just works together with the row mixin.
.offset-fraction 2/5) .offset-unit 200px)
The output from code above is.
Row
The mixin row will make a container of cells behave like a row.
.row )
The output from code above is.
Contribute
See the contributing file.