You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
greenkeeper[bot] ced45b53a6
fix(package): update object-values to version 2.0.0 (#26)
10 months ago
bin increase column width precision to 5 decimal places (#22) 3 years ago
dist increase column width precision to 5 decimal places (#22) 3 years ago
utils increase column width precision to 5 decimal places (#22) 3 years ago
.gitignore 3.0.0 (#17) 3 years ago
.npmrc banish package lock 3 years ago
.travis.yml test tweak 4 years ago
LICENSE 3.0.0 (#17) 3 years ago
index.js exclude option (#19) 3 years ago
package.json fix(package): update object-values to version 2.0.0 (#26) 10 months ago increase column width precision to 5 decimal places (#22) 3 years ago
test.js raw test 3 years ago
util.js 3.0.0 (#17) 3 years ago
utils.js exclude option (#19) 3 years ago


Customizable, functional css utilities built using gr8-util. Includes:


stylesheet usage

The simplest way to use gr8 is to include the gr8.css stylesheet in your project:

<link rel="stylesheet" href="dist/gr8.css" />

javascript usage

Use the gr8 function to generate utilities:

var gr8 = require('gr8')
var css = gr8()

Detailed usage →


Default utilities:




























.dev{outline:1px solid #912eff}
.dev > * {outline:1px solid #5497ff}
.dev > * > * {outline:1px solid #51feff}
.dev > * > * > * {outline:1px solid #ff0000}
.dev > * > * > * * {outline:1px solid #00ff00}


css = gr8([opts])

Generate utilities and return a string of css. opts accepts the following values:

Value Options

  • opts.spacing [Mixed] values for margin & padding utilities
  • opts.fontSize [Mixed] values for font-size utilities
  • opts.lineHeight [Mixed] values for line-height utilities
  • opts.size [Mixed] values for width & height utilities
  • opts.viewport [Mixed] values for viewport utilities
  • opts.zIndex [Mixed] values for zIndex utilities
  • opts.flexOrder [Mixed] values for flex-order utilities
  • opts.opacity [Mixed] values for opacity utilities
  • opts.aspectRatio [Mixed] values for aspect ratio utilities
  • opts.textColumn [Mixed] values for text columns utilities

Selector Options

  • opts.selector [Function] css selector template function
  • opts.breakpoints [Object] values for breakpoint utilities
  • opts.breakpointSelector [String | Function] selector shortcut or css selector template function

Custom Utilities Options

  • opts.utils [Array] custom gr8-util utilities
  • opts.exclude [Array] keys of default utilities to exclude

Value Options

Value options customize numeric gr8 utilities. They accept Numbers, Strings, Arrays, or Objects. Typically Arrays of Numbers will be used. Refer to gr8-util for details on all possible ways to format values.


var css = gr8({
  spacing: [0, 1, 2, 3, 4],
  fontSize: [1, 1.2, 1.6, 2.4, 3.2, 6.4],
  lineHeight: [1, 1.5],
  size: [0, 100],
  viewport: [50, 100],
  zIndex: [0, 1, 2, 3, 4],
  flexOrder: [0, 1, 2, 3, 4],
  opacity: [0, 25, 50, 75, 100],
  aspectRatio: [25, 50, 75, 100],
  textColumn: [1, 2, 3, 4]

Selector Options

Selector options control selectors & breakpoints.


var css = gr8({
  selector: s => `.${s}`,
  breakpoints: {
    sm: 768,
    md: 1024,
    lg: 1280
  breakpointSelector: 'attribute'


Function expects a selector name as input and returns a css selector string as output. For example, to use an attribute selector instead of classes:

var css = gr8({
  selector: s => `[gr8~="${s}"]`


  /* etc... */


Object keys are used in selector names and object values are used to define the media queries. Object values can either be integers (which results in a min-width media queries), or object values can be media query strings. Pass false to disable breakpoint utilities entirely:

var css = gr8({
  breakpoints: {
    small: 1024,
    medium: '(min-width:768px) and (max-width:1280px)',
    'not-big': '(max-width:1024px)',
    portrait: '(orientation:portrait)'


  @media (min-width:1024px) {
    /* etc... */  
  @media (min-width:768px) and (max-width:1280px) {
    /* etc... */  
  @media (max-width:1024px) {
    /* etc... */  
  @media (orientation:portrait) {
    /* etc... */  

Note: If you care about valid attribute selectors, prepend data- to your breakpoint keys.


By default, attribute selectors are generated for breakpoint utilities (as seen above). Use prefixed classes instead by passing in the 'class' shortcut, or provide a selector function for more granular control:

'class' Shortcut

var css = gr8({
  breakpointSelector: 'class'


  @media (min-width:768px) {
    /* etc... */
  @media (min-width:1024px) {
    /* etc... */
  @media (min-width:1280px) {
    /* etc... */

Selector Function

var css = gr8({
  breakpointSelector: key => s => `.gr8-${key}-${s}`


  @media (min-width:768px) {
    /* etc... */
  @media (min-width:1024px) {
    /* etc... */
  @media (min-width:1280px) {
    /* etc... */

Custom Utilities Options

gr8-util is a little function for generating functional css utilities. Given a plain object, concise css utilities are generated. All the utilities in gr8 are built using this.

Use the utils option to pass an array of gr8-util objects to extend the gr8 output with custom utilities:

var bgcolor = {
  prop: {
    bgc: 'background-color'
  vals: ['red', 'blue', 'green']

var fontcolor = {
  prop: {
    fc: 'color'
  vals: ['red', 'blue', 'green']

var css = gr8({
  utils: [


  /* etc... */

  @media (min-width:768px) {
    /* etc... */

  @media (min-width:1024px) {
    /* etc... */

  @media (min-width:1280px) {
    /* etc... */

Refer to gr8-util for further documentation on generating custom utilities.


Use the exclude option to remove some of the default utilities. Accepts an array with any of the following values:

column, margin, padding, opacity, background, flex, display, float, overflow, positioning, size, typography, miscellaneous, development


For more advanced use cases, some additional methods are proxied:

// direct access to gr8-util
var gr8util = require('gr8/util')
var css = gr8util({options})
// direct access to gr8-utils
var gr8utils = require('gr8/utils')
var css = gr8utils({options})

// or even lower level
gr8utils.generate(gr8utils.utils, gr8utils.defaults)


gr8 is developed and iterated-on primarily for use within projects at Folder Studio. It shares similarities with other functional css libraries like tachyons or basscss, but diverges in its minimalism and customizability. gr8 provides no colors, no borders, no font-families, etc out of the box, but instead provides ways to quickly define your own utilities for things like these using plain objects. It facilitates creating coherent design systems without imposing one by default.

In any case, I hope you like it and perhaps find it useful!


  • Advanced documentation
  • Website

See Also