Skip to main content

Margin Utilities

Margin utilities in NuvoUI help you control spacing outside elements. They're essential for controlling layout and spacing between components.

Configuration

The margin utilities are built on configurable variables:

Parent Selector

All margin utilities are scoped under the VAR.$parent-selector which can be configured:

Utility Class Generation

Margin utility classes are only generated if VAR.$generate-utility-classes is set to true:

Margin All Sides

Add equal margin on all sides of an element with the .m-{size} utility:

Horizontal and Vertical Margins

Control horizontal and vertical margins independently:

Individual Side Margins

Apply margin to specific sides using directional utilities:

Auto Margins

Auto margins are useful for alignment and pushing elements apart:

Margin for Space Between Elements

Create consistent spacing between a group of elements:

Visual Margin Comparison

See how different margin sizes affect your elements:

Negative Margins

Though not included in the base framework, you can create negative margins in SCSS:

Responsive Margins

Apply different margins at different breakpoints:

Common Use Cases

Cards with Consistent Spacing

Spacing Between Form Elements

Content Sections with Proper Spacing

Margin Utilities Reference Table

All Sides Margin Classes

ClassCSS PropertyDescription
.m-0margin: 0No margin
.m-1margin: 0.25remExtra small margin (4px)
.m-2margin: 0.5remSmall margin (8px)
.m-3margin: 0.75remMedium small margin (12px)
.m-4margin: 1remMedium margin (16px)
.m-5margin: 1.25remMedium large margin (20px)
.m-6margin: 1.5remLarge margin (24px)
.m-8margin: 2remExtra large margin (32px)
.m-10margin: 2.5rem2x large margin (40px)
.m-12margin: 3rem3x large margin (48px)
.m-16margin: 4rem4x large margin (64px)
.m-20margin: 5rem5x large margin (80px)
.m-24margin: 6rem6x large margin (96px)
.m-32margin: 8rem8x large margin (128px)

Horizontal and Vertical Margin Classes

ClassCSS PropertyDescription
.mx-0 to .mx-32margin-left; margin-rightHorizontal margins
.my-0 to .my-32margin-top; margin-bottomVertical margins

Individual Side Margin Classes

ClassCSS PropertyDescription
.mt-0 to .mt-32margin-topTop margin
.mr-0 to .mr-32margin-rightRight margin
.mb-0 to .mb-32margin-bottomBottom margin
.ml-0 to .ml-32margin-leftLeft margin

Auto Margin Classes

ClassCSS PropertyDescription
.mx-automargin-left: auto; margin-right: autoHorizontally center element
.ml-automargin-left: autoPush element to the right
.mr-automargin-right: autoPush element to the left

Responsive Classes

Add @{breakpoint} suffix to any margin class for responsive behavior:

  • .m-4@sm
  • .mx-auto@md
  • .mt-8@lg
  • .mb-4@xl

SCSS Mixins

NuvoUI provides a comprehensive set of margin mixins for use in your SCSS:

Margin Mixins

MixinParametersDescription
@include m($val)$val: Margin valueSets margin on all sides
@include mx($val)$val: Margin valueSets left and right margins
@include my($val)$val: Margin valueSets top and bottom margins
@include mt($val)$val: Margin valueSets top margin
@include mr($val)$val: Margin valueSets right margin
@include mb($val)$val: Margin valueSets bottom margin
@include ml($val)$val: Margin valueSets left margin
@include ml-autoNoneSets left margin to auto
@include mr-autoNoneSets right margin to auto
@include mx-autoNoneSets left and right margins to auto

Example SCSS Usage

Advanced Layout Patterns