Display Utils

Introduction

NPM version Dependency Status

A collection of dynamically generated css display utility classes.

Class names follow the Emmet abbreviation syntax, with colons (':') replaced by two dashes (--) to follow BEM naming conventions (It modifiies the user agent's default display). E.g., the display: none utility class name is .u-d--n.

Available classes

  • .u-d--b (display: block)
  • .u-d--f (display: flex)
  • .u-d--if (display: inline-flex)
  • .u-d--i (display: inline)
  • .u-d--ib (display: inline-block)
  • .u-d--inher (display: inherit)
  • .u-d--init (display: initial)
  • .u-d--li (display: list-item)
  • .u-d--n (display: none)
  • .u-d--tb (display: table)
  • .u-d--iteb (display: inline-table)
  • .u-d--tbcp (display: table-caption)
  • .u-d--tbcl (display: table-column)
  • .u-d--tbclg (display: table-column-group)
  • .u-d--tbhg (display: table-header-group)
  • .u-d--tbfg (display: table-footer-group)
  • .u-d--tbr (display: table-row)
  • .u-d--tbrg (display: table-row-group)
  • .u-d--tbc (display: table-cell)
  • .u-d--rb (display: ruby)
  • .u-d--rbb (display: ruby-base)
  • .u-d--rbbg (display: ruby-base-group)
  • .u-d--rbt (display: ruby-text)
  • .u-d--rbtg (display: ruby-text-group)

Installation

Using npm:

npm i -S jigsass-utils-display

Usage

Import JigSass Utils Display into your main scss file near its very end, together with all other utilities (utilities should always be the last to be imported).

@import 'path/to/jigsass-utils-display/scss/index';

Like all other JigSass Utils, JigSass Display does not automatically generate any CSS when imported. You would need to explicitly indicate that each individual display class should actually be generated in each component or object it is used in (clarification: This will include style declarations inside .foo and .bar):

// _c.foo.scss
.foo {
  @include jigsass-util(u-d, $modifier: b); // <-- display: block

  ...
}
// _c.bar.scss
.bar {
  @include jigsass-util(u-d, $modifier: ib);  // <-- display: inline-block
  @include jigsass-util(
    u-d,
    $modifier: f,
    $from: large
  ); // <-- display: flex from large bp an on.

  ...
}

Doing so helps us a great deal with portability, as no matter where we import component or object partials, the correct utility classes will be generated. Think of it as a poor man's dependency management.

Developer communication is also assisted by including "dependencies" wherever they are required, as anyone going through a partial, can easily understand how it should be marked up with just a glance.

As far as bloat goes, just don't worry about it - the actual styles will only be generated once, at the location in the cascade where the Jigsass Clearfix partial was imported into the main file.

JigSass Display classes are responsive-enabled, using JigSass MQ and the breakpoints defined in the $jigsass-breakpoints variable.

Based on the breakpoint arguments passed to jigsass-util when including a display class, responsive modifiers are generated according to the following logic:

.u-d--<modifier>[-[-from-<breakpoint-name>][-until-<breakpoint-name>][-misc-<breakpoint-name>]]

So, assuming the medium, large and landscape breakpoints are defined in $jigsass-breakpoints as 600px, 1024px and (orientation: landscape) respectively,

@include jigsass-util(u-d, $modifier: f);

will generate the .u-d--f class, which is not limited to any media-query.

@include jigsass-util(u-d, $modifier: f, $until: medium);

will generate the .u-d--f--until-medium class, which will be in effect at (max-width: 37.49em) and will override styles in the default class until that point.

@include jigsass-util(u-d, $modifier: f, $from: large, $misc: landscape);

will generate the .u-d--f--from-large-when-landscape class, which will go into effect at (min-width: 64em) and (orientation: landscape) and will override styles in the default class under these conditions.

License: MIT

u-d--b (block)

A util to modify an element's display property value to block.

Include with:

@include jigsass-util(u-d, $modifier: block[, $from, $until, $misc]);

Example

<div class='fpo u-d--b'>
  This div is display value is set to: <em>block</em>.
</div>

u-d--cp (compact)

A util to modify an element's display property value to compact.

Include with:

@include jigsass-util(u-d, $modifier: compact[, $from, $until, $misc]);

Example

<div class='fpo u-d--cp'>
  This div is display value is set to: <em>compact</em>.
</div>

u-d--f (flex)

A util to modify an element's display property value to flex.

Include with:

@include jigsass-util(u-d, $modifier: flex[, $from, $until, $misc]);

Example

<div class='fpo u-d--f'>
  This div is display value is set to: <em>flex</em>.
</div>

u-d--if (inline-flex)

A util to modify an element's display property value to inline-flex.

Include with:

@include jigsass-util(u-d, $modifier: inline-flex[, $from, $until, $misc]);

Example

<div class='fpo u-d--if'>
  This div is display value is set to: <em>inline-flex</em>.
</div>

u-d--i (inline)

A util to modify an element's display property value to inline.

Include with:

@include jigsass-util(u-d, $modifier: inline[, $from, $until, $misc]);

Example

<div class='fpo u-d--i'>
  This div is display value is set to: <em>inline</em>.
</div>

u-d--ib (inline-block)

A util to modify an element's display property value to inline-block.

Include with:

@include jigsass-util(u-d, $modifier: inline-block[, $from, $until, $misc]);

Example

<div class='fpo u-d--ib'>
  This div is display value is set to: <em>inline-block</em>.
</div>

u-d--inher (inherit)

A util to modify an element's display property value to inherit.

Include with:

@include jigsass-util(u-d, $modifier: inherit[, $from, $until, $misc]);

Example

<div class='fpo u-d--inher'>
  This div is display value is set to: <em>inherit</em>.
</div>

u-d--init (initial)

A util to modify an element's display property value to initial.

Include with:

@include jigsass-util(u-d, $modifier: initial[, $from, $until, $misc]);

Example

<div class='fpo u-d--init'>
  This div is display value is set to: <em>initial</em>.
</div>

u-d--li (list-item)

A util to modify an element's display property value to list-item.

Include with:

@include jigsass-util(u-d, $modifier: list-item[, $from, $until, $misc]);

Example

<div class='fpo u-d--li'>
  This div is display value is set to: <em>list-item</em>.
</div>

u-d--n (none)

A util to modify an element's display property value to none.

Include with:

@include jigsass-util(u-d, $modifier: none[, $from, $until, $misc]);

Example

<div class='fpo u-d--n'>
  This div is display value is set to: <em>none</em>.
</div>

u-d--rb (ruby)

A util to modify an element's display property value to ruby.

Include with:

@include jigsass-util(u-d, $modifier: ruby[, $from, $until, $misc]);

Example

<div class='fpo u-d--rb'>
  This div is display value is set to: <em>ruby</em>.
</div>

u-d--rbb (ruby-base)

A util to modify an element's display property value to ruby-base.

Include with:

@include jigsass-util(u-d, $modifier: ruby-base[, $from, $until, $misc]);

Example

<div class='fpo u-d--rbb'>
  This div is display value is set to: <em>ruby-base</em>.
</div>

u-d--rbbg (ruby-base-group)

A util to modify an element's display property value to ruby-base-group.

Include with:

@include jigsass-util(u-d, $modifier: ruby-base-group[, $from, $until, $misc]);

Example

<div class='fpo u-d--rbbg'>
  This div is display value is set to: <em>ruby-base-group</em>.
</div>

u-d--rbt (ruby-text)

A util to modify an element's display property value to ruby-text.

Include with:

@include jigsass-util(u-d, $modifier: ruby-text[, $from, $until, $misc]);

Example

<div class='fpo u-d--rbt'>
  This div is display value is set to: <em>ruby-text</em>.
</div>

u-d--rbtg (ruby-text-group)

A util to modify an element's display property value to ruby-text-group.

Include with:

@include jigsass-util(u-d, $modifier: ruby-text-group[, $from, $until, $misc]);

Example

<div class='fpo u-d--rbtg'>
  This div is display value is set to: <em>ruby-text-group</em>.
</div>

u-d--ri (run-in)

A util to modify an element's display property value to run-in.

Include with:

@include jigsass-util(u-d, $modifier: run-in[, $from, $until, $misc]);

Example

<div class='fpo u-d--ri'>
  This div is display value is set to: <em>run-in</em>.
</div>

u-d--tb (table)

A util to modify an element's display property value to table.

Include with:

@include jigsass-util(u-d, $modifier: table[, $from, $until, $misc]);

Example

<div class='fpo u-d--tb'>
  This div is display value is set to: <em>table</em>.
</div>

u-d--iteb (inline-table)

A util to modify an element's display property value to inline-table.

Include with:

@include jigsass-util(u-d, $modifier: inline-table[, $from, $until, $misc]);

Example

<div class='fpo u-d--iteb'>
  This div is display value is set to: <em>inline-table</em>.
</div>

u-d--tbcp (table-caption)

A util to modify an element's display property value to table-caption.

Include with:

@include jigsass-util(u-d, $modifier: table-caption[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbcp'>
  This div is display value is set to: <em>table-caption</em>.
</div>

u-d--tbcl (table-column)

A util to modify an element's display property value to table-column.

Include with:

@include jigsass-util(u-d, $modifier: table-column[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbcl'>
  This div is display value is set to: <em>table-column</em>.
</div>

u-d--tbclg (table-column-group)

A util to modify an element's display property value to table-column-group.

Include with:

@include jigsass-util(u-d, $modifier: table-column-group[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbclg'>
  This div is display value is set to: <em>table-column-group</em>.
</div>

u-d--tbhg (table-header-group)

A util to modify an element's display property value to table-header-group.

Include with:

@include jigsass-util(u-d, $modifier: table-header-group[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbhg'>
  This div is display value is set to: <em>table-header-group</em>.
</div>

u-d--tbr (table-row)

A util to modify an element's display property value to table-row.

Include with:

@include jigsass-util(u-d, $modifier: table-row[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbr'>
  This div is display value is set to: <em>table-row</em>.
</div>

u-d--tbrg (table-row-group)

A util to modify an element's display property value to table-row-group.

Include with:

@include jigsass-util(u-d, $modifier: table-row-group[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbrg'>
  This div is display value is set to: <em>table-row-group</em>.
</div>

u-d--tbc (table-cell)

A util to modify an element's display property value to table-cell.

Include with:

@include jigsass-util(u-d, $modifier: table-cell[, $from, $until, $misc]);

Example

<div class='fpo u-d--tbc'>
  This div is display value is set to: <em>table-cell</em>.
</div>