Grid system

Flexy is a grid system and a general purpose layout tool based on Flex. It can be used to build page level layout as well as component level one. It is why it is not called "grid" but "flexy".

Get started

Import


@import 'settings-tools/all-settings';
@import 'layouts/l.container'; // you generally want the container as well
@import 'layouts/l.flexy';

How it works

The example below creates four equal-width columns at small, medium, large, and extra large breakpoints using our predefined grid classes.

Container rules

ml-container defines the overall grid context at the top level and applies the proper margin and our default max-width. You can also remove this max width, by using the grid modifier class ml--container--fluid. See the default container.

Columns

ml-flexy__col defines individual columns inside the grid. With Flexbox columns widths are set in percentages relative to their parent element so columns without a specific width will automatically be equal. For example, four instances of ml-flexy__col will give you four equal width columns — each 25% of the parent from the small breakpoint on up.

Gutters

In most cases, you will need gutters.

When used with gutters, .ml-flexy uses the negative margin pattern: each column as a padding measuring half a gutter width, and the containing .ml-flexy as a negative margin equal to half a gutter width on both sides as well.


<div class="ml-flexy ml-flexy--gutter">
<div class="ml-flexy__col">col 1</div>
<div class="ml-flexy__col">col 2</div>
</div>

Tokens

Token nameDescriptionValue
size.gutter.screen.sThe gutter width for smallest devices and up1mu 16px
size.gutter.screen.mThe gutter width for screen m and up2mu 32px

Reminder: mu = MagicUnit. Ex: 3.5mu = MagicUnit * 3.5

Columns options

Widths

You can apply specific columns width using .ml-flexy__col modifiers:

ModifierWidth
.ml-flexy__col--1of128.3333%
.ml-flexy__col--1of616.6666%
.ml-flexy__col--1of425%
.ml-flexy__col--1of333.3333%
.ml-flexy__col--1of250%
.ml-flexy__col--2of366.6666%
.ml-flexy__col--3of475%
.ml-flexy__col--5of683.3333%
.ml-flexy__col--11of1291.66666%
.ml-flexy__col--initialwidth of the column content
.ml-flexy__col--fillfill the available width
.ml-flexy__col--full100%

Responsive modifiers

Apply widths to breakpoints using the @from-XX suffix to the widths modifiers.

The available breakpoints modifiers are:

ModifierBreakpointCorresponding device
ml-flexy__col--[size] (no modifier)From 0px and upMobile / All
ml-flexy__col--[size]@from-mm: From 680px and upFablet / Small tablet and up
ml-flexy__col--[size]@from-ll: From 1024px and upLandscape tablets, laptops
ml-flexy__col--[size]@from-xlxl: From 1280px and upLaptops (depending on settings)
ml-flexy__col--[size]@from-xxlxxl: From 1920px and upDesktop

Alignment

You can align columns in a ml-flexy using the ml-flexy--items-[xxx] modifiers.

Available modifiers are:

ModifierValueBehavior
default (no modifiers)align-items: flex-startTop alignment
ml-flexy--items-endalign-items: flex-endBottom alignment
ml-flexy--items-centeralign-items: centerVertically centered
ml-flexy--items-startalign-items: flex-startTop alignment
ml-flexy--items-stretchalign-items: stretchAll columns use the same height

Pushing a column to the left

You can push a column using the ml-flexy__col--push-[XofY] modifiers.


<div
class="
ml-flexy__col
ml-flexy__col--1of3
ml-flexy__col--push-1of3"
>
<!-- column content -->
</div>

All columns widths (numerical) are available as push values from 1of12, 1of6, 1of4 ... to 11of12.

Responsive push modifiers

Apply widths to breakpoints using the @from-XX suffix to the width modifiers.

The available breakpoints modifiers are:

ModifierBreakpointCorresponding device
ml-flexy__col--push-[size] (no modifier)From 0px and upMobile / All
ml-flexy__col--push-[size]@from-mm: From 680px and upFablet / Small tablet and up
ml-flexy__col--push-[size]@from-ll: From 1024px and upLandscape tablets, laptops
ml-flexy__col--push-[size]@from-xlxl: From 1280px and upLaptops (depending on settings)
ml-flexy__col--push-[size]@from-xxlxxl: From 1920px and upDesktop

Reset pushed modifiers

For a specific a breakpoint you can reset the pushed column using mc-flexy__col--push--reset@from-XX.


<div
class="
ml-flexy__col
ml-flexy__col--1of12
ml-flexy__col--push-1of12@from-l
ml-flexy__col--push-reset@from-xl
"
>
<!-- column content -->
</div>

Nesting flexy grids

You can either nest flexy grids by creating a new .ml-flexy grid inside a column, or by directly applying a .ml-flexy class on a .ml-flexy__column element.

Columns order

Use the ml-flexy__col--last and ml-flexy__col--first modifier to reorder columns.

Use flexy to center vertically and horizontally

Use the ml-flexy--space-around and the ml-flexy--items-center modifier on a ml-flexy element to center vertically and horizontally elements.