Home

Awesome

Gridlover Mixin

I built this mixin to help generate CSS files inspired by Gridlover's tool which lets you create typography with modular scale and vertical rhythm. These mixins only supplement the hard work Tuomas Jomppanen & Ville Vanninen have already done at www.gridlover.net, be sure to check it out.

Setup

Install the appropriate Stylus, SASS, or LESS preprocessor.

Add the correct rhythm mixin file to your project.

Then add the following file to the top of your main stylesheet. The example below uses Stylus, so be sure to change the syntax to match your chosen CSS preprocessor.

// Configure variables here
$unit = "px"
$base-font-size = 16px
$line-height-scale = 1.5
$font-scale = 1.5

@import 'rhythm'

If you are using ems or rems, then you will want to set the base rhythm of your document using the following.

html {
	rhythm: "base"
}

Usage

Use the rhythm mixin to set the vertical rhythm of each typographical element.

Arguments should be passed through as the font-size multiplier, margin-top multiplier, margin-bottom multiplier.

rhythm: font-size [, margin-top, margin-bottom, line-height]

For example

h1 {
	rhythm: 2, 1, 1
}

Outputs

h1 {
  font-size: 36px;
  line-height: 48px;
  margin-top: 24px;
  margin-bottom: 24px;
}

Custom line-height

By default the mixin calculates the appropriate line-height based on the computed font-size however if you wish to set this explicitly you can define it as the last argument in the mixin (unfortunately this feature only works in SASS and Stylus currently).

For example

p {
	rhythm: 0, 1, 1, 2 // each line of text will span two line heights
}

Configure

Change the default configuration for your project using the following variables.

Example

$unit = "rem"
$base-font-size = 14px
$line-height-scale = 1.5
$font-scale = 1.618
$true-scale = true

Changelog

v2.0.0 (Mar 30 2016)

v1.4.0 (Mar 26 2016)

v1.3.0 (Jul 20, 2015)

v1.2.0 (Aug 3, 2013)

v1.1.0 (Jul 29, 2013)

v1.0.0 (Oct 26, 2012)

v0.1.0 (Oct 23, 2012)

Special thanks

Thanks to:

License

This is licenced under the MIT License