You can use it without helper classes (like s-grid-cell-sm-4 etc.) and with helper classes which is good if you want a quick prototype of something.
You can extend custom classes and use the grid() and cell() functions to create your custom styles. It is a very clean and simple usage case. It is also a recommended one because you will keep your html code clean and you can structure your styles as you want.
These are main Stylus functions used in sGrid. You will find more examples below.
To use helper classes you need to import s-grid-classes.styl file. You can change main classes names in settings. If you remember Bootstrap or Foundation grid classes and you know how to use it you will understand exactly what to do. It is very similar to other CSS grids usage but here we use Flexbox.
Main grid classes:
Main cell classes:
You can also use autogenerated grid helper classes like those from Bootstrap or Foundation. By default you have 12 column based grid. You can change it in settings. See how in 'Overwrite settings'.
S-Grid generated helper classes:
Stylus code:
section
grid()
div
padding rem-calc(15)
cell(1, 4)
&.other-cell
cell(2, 4, 'bottom')
&.different-cell
cell(1, 3, g: 30px)
HTML code:
<section>
<div>Lorem ipsum</div>
<div>Lorem ipsum</div>
<div class="other-cell">Lorem ipsum</div>
<div>Lorem ipsum</div>
<div class="different-cell">Lorem ipsum</div>
</section>
HTML code:
<section class="s-grid-top">
<div class="s-grid-cell s-grid-cell-md-6">Lorem ipsum</div>
<div class="s-grid-cell s-grid-cell-md-6">Lorem ipsum</div>
<div class="s-grid-cell s-grid-cell-bottom s-grid-cell-md-12">Lorem ipsum</div>
<div class="s-grid-cell s-grid-cell-md-8">Lorem ipsum</div>
<div class="s-grid-cell s-grid-cell-center s-grid-cell-md-4 s-grid-cell-offset-md-4">Lorem ipsum</div>
</section>
Effect:
You can overwrite the settings (from s-grid-settings.styl file), just place your settings after s-grid-settings import. In your main .styl file do something like this:
// main s-grid settings file:
@import 's-grid-settings'
// my new settings goes here:
base-font-size = 16 // base font size it is 16px by default it is used to calculate rem sizes
gutter = 20px // gutters size
columns = 12 // how many columns you need in your grid (usage with helper classes)
gridClassName = 's-grid' // main grid wraper class name (usage with helper classes)
cellClassName = 's-grid-cell' // main grid cell class name (usage with helper classes)
breakpoints = { // media queries breakpoints
sm: 0,
md: 640px,
lg: 1200px,
xlg: 1440px,
xxlg: 1920px
}
// s-grid imports:
@import 's-grid-functions'
@import 's-grid-classes'
// ...
// my app styles here..
// ...