Utility API

Syntax

SCSS:

$utilities: (
  // Name for utility
  "[string]": (
    // CSS property (required)
    property: [variable],
    // CSS values (required)
    values: [space-separated list or map (if class names and values should be different],
    // Class name prefix to use instead of property name
    class: [variable],
    // Generate variants for different states
    state: [space-separated list],
    // Generate responsive classes
    responsive: [boolean (false)],
    // Enable fluid rescaling
    rfs: [boolean (false)],
    // Generate print classes,
    print: [boolean (false)],
    // Keep utility in RTL,
    rtl: [boolean (true)]
  )
);

Modify

Modify sizing utility for width

SCSS:

$utilities: (
  "width": (
    property: width,
    class: w,
    values: (
      10: 10%,
      20: 20%,
      30: 30%,
      40: 40%,
      50: 50%,
      60: 60%,
      70: 70%,
      80: 80%,
      90: 90%,
      100: 100%,
      auto: auto
    )
  ),
);
Width 10%
Width 20%
Width 30%
Width 40%
Width 50%
Width 60%
Width 70%
Width 80%
Width 90%
Width 100%

Add: simple

Generate cursor utilities

SCSS:

$utilities: map-merge(
  $utilities,
  (
    "cursor": (
      property: cursor,
      values: auto context-menu copy grab help pointer wait,
    )
  )
);
Cursor auto
Cursor context-menu
Cursor copy
Cursor grab
Cursor help
Cursor pointer
Cursor wait

Add: complex

Generate opacity utilities

SCSS:

$utilities: map-merge(
  $utilities,
  (
    "opacity": (
      property: opacity,
      class: o,
      responsive: true,
      print: true,
      state: hover,
      values: (
        0: 0,
        25: .25,
        50: .5,
        75: .75,
        100: 1,
      )
    )
  )
);

All breakpoints

Opacity 0 for
Opacity 0.25 for
Opacity 0.5 for
Opacity 0.75 for
Opacity 1 for

Breakpoint sm and up

Opacity 0 for sm
Opacity 0.25 for sm
Opacity 0.5 for sm
Opacity 0.75 for sm
Opacity 1 for sm

Breakpoint md and up

Opacity 0 for md
Opacity 0.25 for md
Opacity 0.5 for md
Opacity 0.75 for md
Opacity 1 for md

Breakpoint lg and up

Opacity 0 for lg
Opacity 0.25 for lg
Opacity 0.5 for lg
Opacity 0.75 for lg
Opacity 1 for lg

Breakpoint xl and up

Opacity 0 for xl
Opacity 0.25 for xl
Opacity 0.5 for xl
Opacity 0.75 for xl
Opacity 1 for xl

Breakpoint xxl and up

Opacity 0 for xxl
Opacity 0.25 for xxl
Opacity 0.5 for xxl
Opacity 0.75 for xxl
Opacity 1 for xxl

For print only

Opacity 0 for print
Opacity 0.25 for print
Opacity 0.5 for print
Opacity 0.75 for print
Opacity 1 for print

On hover

Opacity 0 on hover
Opacity 0.25 on hover
Opacity 0.5 on hover
Opacity 0.75 on hover
Opacity 1 on hover

Rename

Rename class prefix for "margin start" from .ms-* to .ml-*.

SCSS:

$utilities: map-merge(
  $utilities, (
    "margin-start": map-merge(
      map-get($utilities, "margin-start"),
      ( class: ml ),
    ),
  )
);
Margin left 0
Margin left 1
Margin left 2
Margin left 3
Margin left 4
Margin left 5

Remove

Remove interaction utilities

SCSS:

$utilities: map-merge(
  $utilities,
  (
    "user-select": null,
    "pointer-events": null
  )
);

Pointer events none

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In laoreet pellentesque lorem sed elementum. Suspendisse maximus convallis ex. Etiam eleifend velit leo.

User select all

Lorem ipsum dolor sit amet, consectetur adipiscing elit. In laoreet pellentesque lorem sed elementum. Suspendisse maximus convallis ex. Etiam eleifend velit leo.