You can fetch Trowel Layouts with npm, yarn or bower.
# With bower
$ bower install --save trowel-layouts
# With npm
$ npm install --save trowel-layouts
# With yarn
$ yarn add trowel-layouts
You can also download a zip archive right here.
The main scss file to include to your main .scss
file is located at the ./src/scss/Layouts.scss
. As a Trowel Component, it also requires two dependencies to compile the scss code. Here an scss installation snippet.
// Trowel core (need to be imported first)
@import './path/to/dependencies/trowel-core/src/trowel';
// Trowel Layouts
@import './path/to/dependencies/trowel-layouts/src/scss/layouts';
Use the .container
class to contain your content in a fixed width.
<div class="container">
...
</div>
With the $container--width
you can control the width of the container, and for example do fluid containers by setting up 100%
as designed by default on the flag -fluid
.
<div class="container container--fluid">
...
</div>
You can layout your content as grid, by first creating a .grid
DOM element, then for each column a .grid__col
and then specify the size of the column depending of the viewport width configured in the $trowel-config
variable like .grid__col--xs-2
.
<div class="grid">
<div class="grid__col grid__col--xs-2 grid__col--sm-10"></div>
<div class="grid__col grid__col--xs-4 grid__col--sm-2"></div>
<div class="grid__col grid__col--xs-6 grid__col--sm-4"></div>
<div class="grid__col grid__col--xs-12 grid__col--sm-8"></div>
</div>
You can also create a grid with flexbox. Wrap your columns with a .flex-grid
DOM element. Then for each col use the .flex-grid__col
class.
You will be able to custom the behavior of your flex-grid through *Trowel variables* but by default a `.flex-grid__col--grow-1` element-modifier class is available to make a column fill all the remaining space available.
<div class="flex-grid">
<div class="flex-grid__col">
<div class="grid-showoff">col</div>
</div>
<div class="flex-grid__col flex-grid__col--grow-1">
<div class="grid-showoff">col</div>
</div>
<div class="flex-grid__col">
<div class="grid-showoff">col</div>
</div>
<div class="flex-grid__col">
<div class="grid-showoff">col</div>
</div>
</div>
You can override the global syntax config for a specific component with the following variables
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$layout--synthax |
null |
syntax config for .container , .grid and .flex-grid blocks |
You can avoid the generation of some css with the following variables
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$container--enable |
true |
enable the generation of style rules for the .container block |
$grid--enable |
true |
enable the generation of style rules for the .grid block |
$flexgrid--enable |
true |
enable the generation of style rules for the .flex-grid block |
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$container--padding-x |
1rem |
Sets the left and right padding for the .container block |
$container--width |
( |
Sets the width for the .container block |
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$grid–gutter | $container--padding-x |
sets the gutter space between two col |
$grid–columns | 12 |
not a trowel variable sets the max numbers of columns on a grid row |
VARIABLE | DEFAULT VALUE | DESCRIPTION |
---|---|---|
$flexgrid--gutter |
0.5em |
sets the gutter space between two col |
$flexgrid--flex-wrap |
wrap |
sets the flex-wrap property on block |
$flexgrid--align-items |
null |
sets the align-items property on block |
$flexgrid--justify-content |
null |
sets the justify-content property on block |
$flexcol--flex-shrink |
null |
sets the flex-shrink property on .flex-grid__col elements |
$flexcol--flex-basis |
null |
sets the flex-basis property on .flex-grid__col elements |
$flexcol--flex-grow |
( |
sets the flex-grow property on .flex-grid__col elements |