Getting started
Step 1
Step 2
Include Modernizr and at least add JS - No JS detection
and flexbox detection
if you’re gonna use flexbox.
Step 3
Create a SCSS file, something like:
Recommendations
Clean CSS
Use grunt-contrib-cssmin to eliminate duplicate code. Duplicate code is generated because Illusion doesn’t know whether you already used a specific mixin in an element when you use it again.
Autoprefixer
Use autoprefixer to add the browser prefixes you need for your project.
Base styling
To stop all the copy pasting in this world we added some base styling in two levels.
Level 1: Extendalize
The first level we call “Extendalize” and it basically extends Normalize styling the way we think it should be.
By default the extendalize styling is set to false and can be configured using variables.
Enable all extendalize features:
Enable individual extendalize features:
Disable individual extendalize features:
Level 2: Element styling
The second level adds default styling for certain elements. The following elements are available:
Body fallback
For browsers that do not support CSS calc()
there’s an option to set the body width to make it look better on those older browsers.
Enable the body fallback styling by setting the following variable:
Forms
Default form styling is available.
Mixins
All settings are controlled by setting your own variables and load them before the Illusion variables are loaded.
Illusion comes with a great mixin and function library. All the parameters inside mixins are overwriteable.
@mixin breakpoint
Media querie shortcut. Sets a temporary global $inside-breakpoint
variable to be used inside other mixins.
Arguments
Name | Type | Default | Description |
---|---|---|---|
width |
string |
- | min-width amount |
width--max |
string |
false |
max-width amount for (min-width) and (max-width) media query |
SCSS
CSS
@mixin button
Can be used inside your own @mixin button();
and other elements that should behave like a button. No styling is provided.
Arguments
Name | Type | Default |
---|---|---|
appearance |
string |
none |
display |
string |
inline-block |
vertical-align |
string |
|
cursor |
string |
pointer |
SCSS
CSS
@mixin clearfix
Clears top and bottom floats.
Still using single colon for better browser compatibility.
Arguments
Name | Type | Default | Description |
---|---|---|---|
reset |
boolean |
false |
Hides the pseudo elements. Useful when using flex-wrap |
SCSS
CSS
@mixin collapse
Use as direct child of @include span
element. Make sure there’s no padding on the parent element
Arguments
Name | Type | Default | Description |
---|---|---|---|
sides |
string |
both |
Choose which side(s) to collapse gutter. Defaults to ‘both’ |
multiplier |
number |
1 |
Defaults to 1 and can be set to any number dividable by 0.5 |
fromto |
list |
false to false |
Set starting and stopping breakpoints. Accepts single value: @include collapse(both, 1, $bravo) or list: @include collapse(both, 1, $bravo to $charlie) . The second (to) value only means that Illusion is not adding more media queries. The styling is not being reset on this ‘to’ breakpoint |
gutter |
string |
false |
Custom gutter value for Illusion to calculate (calc() ) with. |
SCSS
CSS
@mixin container
Shouldn’t be nested. Adds clearfix when used without flexbox and removes clearfix when used as flexbox. Adds a max-width and left and right padding following the responsive gutters.
Arguments
Name | Type | Default | Description |
---|---|---|---|
type |
string |
$illusion-grid-container-type |
Choose between clearfix (for floats) or flexbox container. Defaults to clearfix container. |
alignment |
string |
center |
Align container to left, center or right |
Dependencies
For flexbox to work properly it uses Modernizr .flexbox.flexwrap
SCSS
CSS
@mixin content-block
Adds a margin bottom to element and removes the margin bottom from the last element in it’s parent.
Arguments
Name | Type | Default | Description |
---|---|---|---|
spacing |
string |
$line-height |
The amount of margin |
location |
string |
bottom |
Can be either bottom or top |
SCSS
CSS
@mixin coverall
Cover entire closest element that has position:
absolute
or relative
.
Arguments
Name | Type | Default | Description |
---|---|---|---|
offset |
string |
0 |
Default offset for all four directions |
top |
string |
true |
Separate offset for top |
right |
string |
true |
Separate offset for right |
bottom |
string |
true |
Separate offset for bottom |
left |
string |
true |
Separate offset for left |
position |
string |
absolute |
Defaults to absolute |
reset |
string |
false |
Resets all properties |
SCSS
CSS
@mixin flexbox
Style only when browser supports flexbox.
Arguments
Name | Type | Default | Description |
---|---|---|---|
horizontal |
string |
$flexbox-horizontal |
Flex when viewport reached this amount |
vertical |
string |
$flexbox-vertical |
Flex when viewport reached this amount |
Dependencies
For flexbox to work properly it uses Modernizr .flexbox
and .flexboxlegacy
SCSS
SCSS
@mixin fluid-type
Fluid font-size between breakpoints
Arguments
Name | Type | Default | Description |
---|---|---|---|
min-value |
string |
$fluid-type-min-value |
The minimum font-size |
max-value |
string |
$fluid-type-max-value |
The maximum font-size |
min-screen |
string |
$fluid-type-min-screen |
Breakpoint for fluid-type to kick in |
max-screen |
string |
$fluid-type-max-screen |
Breakpoint for fluid-type to stop |
SCSS
SCSS
@mixin font-smoothing
Only use for light text on dark backgrounds.
SCSS
CSS
@mixin gallery
Shortcut to create gallery-style grids. Adds clearing on nth-child items.
Arguments
Name | Type | Default | Description |
---|---|---|---|
span |
list |
- | Set how many columns should be spanned. Accepts single value: @include gallery(6) or list: @include gallery(4 of 12) . Amount of columns defaults to $illusion-grid-container |
fromto |
list |
false to false |
Set starting and stopping breakpoints. Accepts single value: @include gallery(6, $bravo) or list: @include gallery(6, $bravo to $charlie) . The second (to) value only means that Illusion is not adding more media queries. The styling is not being reset on this ‘to’ breakpoint |
multiplier |
number |
1 |
Gutter multiplier. defaults to 1 and can be set to any number dividable by 0.5 |
bottom |
boolean |
true |
Set to false if you don’t want bottom gutters |
defaults |
boolean |
true |
If set to false the mixin won’t add the float and margin property on :first-child and :last-child for cleaner code |
gutter |
string |
false |
Custom gutter value for Illusion to calculate (calc() ) with. |
SCSS
CSS
Breakpoints use
It’s best not to use this mixin inside a breakpoint since the mixin itself is creating media queries. So to avoid creating a LOT of duplicate code rather use the mixin itself to create breakpoints:
@mixin hover
Shortcut for styling both hover and focus.
SCSS
CSS
@mixin js-disabled
If you need styling that only applies to browsers that do not support JavaScript. Progressive enhancement for the win!
SCSS
CSS
@mixin js-enabled
If you need styling that only applies to browsers that support JavaScript. Progressive enhancement for the win!
SCSS
CSS
@mixin modernizr
If you need styling that only applies to browsers that support certain features. Progressive enhancement for the win!
Arguments
Name | Type | Default | Description |
---|---|---|---|
classes |
list |
- | Comma separated list of modernizr classes |
SCSS
CSS
@mixin no-flexbox
Style only when browser does not support flexbox.
Dependencies
For flexbox to work properly it uses Modernizr .flexbox
and .flexboxlegacy
SCSS
SCSS
@mixin pseudo
Arguments
Name | Type | Default | Description |
---|---|---|---|
pseudo |
string |
after |
Either before or after |
parent-position |
string |
relative |
Set to false if you don’t want to set the parent’s position . Set to fixed or absolute if you don’t want it to be relative |
position |
string |
absolute |
Set to false if you don’t want to set the pseudo element’s position . Set to static or relative if you don’t want it to be absolute |
content |
string |
" " |
Defaults to a space but can be anything you want it to be |
display |
string |
block |
Defaults to display: block but can be anything you want it to be |
SCSS
CSS
@mixin ratio-block
Create blocks that keep set aspect ratio. Blocks will grow when content exceeds the content area. To stop this add an absolute positioned child the the ratio block.
Arguments
Name | Type | Default | Description |
---|---|---|---|
ratio |
list |
16 by 9 |
Width to height ratio |
overflow |
string |
hidden |
Hides overflowing content when an absolute positioned child exceeds the content area |
SCSS
CSS
@mixin reset
Arguments
Name | Type | Default |
---|---|---|
margin |
string |
0 |
padding |
string |
0 |
list-style |
string |
none |
border |
string |
none |
background |
string |
transparent |
SCSS
CSS
@mixin row
Arguments
Name | Type | Default | Description |
---|---|---|---|
type |
string |
$illusion-grid-container-type |
Choose between clearfix (for floats) or flexbox container. Defaults to clearfix container. |
SCSS
CSS
@mixin shift
Visually change the order of elements.
Arguments
Name | Type | Default | Description |
---|---|---|---|
shift |
list |
- | Set how many columns should be shifted. Accepts single value: @include shift(2) or list: @include shift(3 of 12) . Amount of columns defaults to $illusion-grid-container |
fromto |
list |
false to false |
Set starting and stopping breakpoints. Accepts single value: @include shift(6, $bravo) or list: @include shift(6, $bravo to $charlie) . The second (to) value only means that Illusion is not adding more media queries. The styling is not being reset on this ‘to’ breakpoint |
multiplier |
number |
1 |
Gutter multiplier. defaults to 1 and can be set to any number dividable by 0.5 |
defaults |
boolean |
true |
If set to false the mixin won’t add the position property |
gutter |
string |
false |
Custom gutter value for Illusion to calculate (calc() ) with. |
SCSS
CSS
Breakpoints use
It’s best not to use this mixin inside a breakpoint since the mixin itself is creating media queries. So to avoid creating a LOT of duplicate code rather use the mixin itself to create breakpoints:
@mixin spacing
Add spacing that follows the responsive breakpoints so you don’t have to worry about that yourself.
Arguments
Name | Type | Default | Description |
---|---|---|---|
sides |
list |
all minus none |
Accepts all minus [top, right, bottom, left] , vertical , horizontal , top , right , bottom and left |
type |
text |
padding |
Accepts padding or margin |
multiplier |
number |
1 |
Defaults to 1 and can be set to any number dividable by 0.5 |
fromto |
list |
false to false |
Set starting and stopping breakpoints. Accepts single value: @include spacing(6, padding, 1, $bravo) or list: @include spacing(6, padding, 1, $bravo to $charlie) . The second (to) value only means that Illusion is not adding more media queries. The styling is not being reset on this ‘to’ breakpoint |
lastchildnone |
boolen |
false |
If set to true :last-child will not have the set spacing |
minus |
number |
0 |
Substract an amount of pixels off of the spacing. If an element has a 2 pixel border you’d best substract 2 pixels form the spacing to stay inside the 8 pixel grid |
SCSS
CSS
@mixin span
…
Arguments
Name | Type | Default | Description |
---|---|---|---|
span |
list |
- | Set how many columns should be spanned. Accepts single value: @include span(6) or list: @include span(4 of 12) . Amount of columns defaults to $illusion-grid-container |
fromto |
list |
false to false |
Set starting and stopping breakpoints. Accepts single value: @include span(6, $bravo) or list: @include span(6, $bravo to $charlie) . The second (to) value only means that Illusion is not adding more media queries. The styling is not being reset on this ‘to’ breakpoint. |
multiplier |
number |
1 |
Gutter multiplier. defaults to 1 and can be set to any number dividable by 0.5 |
bottom |
boolean |
false |
When set to true it also adds a bottom gutter |
defaults |
boolean |
true |
If set to false the mixin won’t add the float and margin property on :first-child and :last-child |
omega |
number |
null |
Used by the gallery mixin |
gutter |
string |
false |
Custom gutter value for Illusion to calculate (calc() ) with. |
SCSS
CSS
Breakpoints use
It’s best not to use this mixin inside a breakpoint since the mixin itself is creating media queries. So to avoid creating a LOT of duplicate code rather use the mixin itself to create breakpoints:
@mixin svg-background
Add an SVG icon as background to an element. Especially useful when trying to override 3rd party generated markup.
Arguments
Name | Type | Default | Description |
---|---|---|---|
svg |
string |
- | Accepts anything that nomally goes inside the <svg></svg> element. Although try to only use small single element SVG files for performance. Only use if you can’t use a real SVG instead |
color |
string |
$svg-background-color |
Color of the SVG. SVGs can only be one color |
width |
number |
$svg-background-width |
The width the SVG background should be displayed as |
height |
number |
$svg-background-height |
The height the SVG background should be displayed as. Set to false if it’s the same as width |
viewboxWidth |
number |
$svg-background-viewboxWidth |
The actual viewboxWidth number. See original SVG file for this number |
viewboxHeight |
number |
$svg-background-viewboxHeight |
The actual viewboxHeight number. See original SVG file for this number. Set to false if it’s the same as width |
background-position |
string |
$svg-background-position |
SVG background-position |
background-repeat |
string |
$svg-background-repeat |
SVG background-repeat |
SCSS
CSS
@mixin transitation
Shortcut to set one or more transition properties.
Arguments
Name | Type | Default | Description |
---|---|---|---|
transitions |
list |
- | Comma separated list. Each item can have three sub-items and will fall back to the default values. |
SCSS
CSS
@mixin triangle
CSS only triangles using borders.
Arguments
Name | Type | Default | Description |
---|---|---|---|
direction |
string |
right |
Direction of triangle |
size |
string |
4px |
Size of triangle |
color |
string |
false |
Defaults to text color |
SCSS
CSS
@mixin visually-hidden
Visually hide or show elements while keeping the element accessible for screenreaders.
Arguments
Name | Type | Default |
---|---|---|
position |
string |
absolute |
overflow |
string |
hidden |
backface-visibility |
string |
hidden |
clip |
string |
rect(0 0 0 0) |
height |
string |
1px |
width |
string |
1px |
margin |
string |
-1px |
padding |
string |
0 |
border |
string |
none |
SCSS
CSS
@mixin visually-shown
Visually show elements that were visually hidden before.
Arguments
Name | Type | Default |
---|---|---|
position |
string |
static |
overflow |
string |
visible |
backface-visibility |
string |
visible |
clip |
string |
auto |
height |
string |
auto |
width |
string |
auto |
margin |
string |
0 |
padding |
string |
0 |
border |
string |
none |
SCSS
CSS
Functions
@function spacing
Returns set spacing or calculate current spacing when inside breakpoint
Accepts a value of 0.5, 1 or 2. If used in @include breakpoint it uses that current gutter. Also possible to define which ‘size’ it should use.