Skip to content
Indiana University Logo
Rivet Design System
  • Components Add-ons Content guide Migration guide
  • What is Rivet? Blog Changelog
  1. May 4, 2022

    Rivet 2.0.0-beta.4 release

    The fourth Rivet 2 beta release introduces design updates to several components and a new responsive table wrapper element.

  2. March 30, 2022

    Rivet 2.0.0-beta.3 release

    The third Rivet 2 beta release updates accordion, badge, and button styles.

  3. February 9, 2022

    Rivet 2.0.0-beta.2 release

    The latest Rivet 2 beta release introduces the link hub component, adds new utility classes, and refactors component JavaScript.

More posts Get updates in your inbox
Install via NPM Download CSS & JS Hosted assets
Navigation
    • Components
    • Add-ons
    • Content guide
    • What is Rivet?
    • Blog
    • Roadmap
    • Changelog
  • Use Rivet
Resources
  • User Experience Office
  • Accessibility Evaluations
  • Rivet Software Design System
  • IU Framework for WCMS
Rivet 1 has been retired and will no longer receive updates. The v1 source code has been archived here. Please migrate to Rivet 2 as soon as possible.
Version 1.8.3
  • Information
    • Changelog
    • Component status
    • Contributing
  • Getting started
    • Install with NPM
    • Rivet Sass
  • Layout
    • Box
    • Grid
    • Panels
    • Spacing
    • Typography
  • Page content
    • Badges
    • Links
    • Lists
    • Media Object
    • Step Indicator
    • Tables
    • Tabs This component requires JS
    • Timeline
  • Forms
    • Buttons
    • Segmented Buttons
    • Checkboxes
    • File input This component requires JS
    • Input group
    • Radio buttons
    • Select element
    • Text inputs
  • Navigation
    • Breadcrumb
    • Dropdown This component requires JS
    • Footer
    • Header This component requires JS
    • Menu
    • Pagination
  • Overlays & Feedback
    • Alerts This component requires JS
    • Loading indicator
    • Modals This component requires JS
  • Utilities
    • Border
    • Display
    • Flex
    • Text
    • Visibility
    • Width
    • z-index
Ready Added in 1.1.0

Spacing

A robust set of responsive spacing utilities to help fine-tune your layout.

Migrating to Rivet 2

This version of Rivet is deprecated. View the spacing utilities documentation on the Rivet 2 website.

About spacing

To maintain consistent spacing between components and to help create a sense of vertical rhythm, we have created a spacing system based on .5rem (8px) unit. Margins and padding can be applied using a set of CSS utility classes to add or remove margin and padding from any element.

Spacing examples

Rivet spacing units
CSS suffix Sass variable rem px Example
-xxs $xxs .25rem 4px

xxs

-xs $xs .5rem 8px

xs

-sm $sm 1rem 16px

sm

-md $md 1.5rem 24px

md

-lg $lg 2rem 32px

lg

-xl $xl 2.5rem 40px

xl

-xxl $xxl 4rem 64px

xxl

Spacing Sass variables

If you are using Rivet’s Sass files you can directly access any spacing unit by its variable name. The spacing unit variables follow the same naming conventions as all of Rivet’s spacing utility classes.

See the documentation on getting started with Rivet for a complete list of Rivet’s Sass variables.

// Global spacing units

$spacing-unit: .5rem;        // 8px

$xxs: $spacing-unit/2;       // 4px
$xs: $spacing-unit;          // 8px
$sm: $spacing-unit * 2;      // 16px Base
$md: $spacing-unit * 3;      // 24px
$lg: $spacing-unit * 4;      // 32px
$xl: $spacing-unit * 5;      // 40px
$xxl: $spacing-unit * 8;     // 64px

Implementation

The CSS classes for the spacing system use the following conventions:

  • rvt = namespace
  • m, p = margin, padding
  • top, right, bottom, left = the top, right, bottom, left side of the element
  • tb = Top and bottom of the element (e.g. rvt-m-tb-xl)
  • lr = Left and right of the element (e.g. rvt-p-lr-md)
  • xs = Extra Small (8px/.5rem)
  • sm = Small (16px/1rem)
  • md = Medium (24px/1.5rem)
  • lg = Large (32px/2rem)
  • xl = Extra large (40px/2.5rem)
  • xxl = Extra extra large (48px/3rem)
  • none = Remove margin/padding from any of the previous combinations

So the class .rvt-m-top-sm would add 16px/1rem of margin on all screen sizes to the top of the element it was applied to.

Responsive spacing

Each spacing utility class also comes with a set of modifiers that allow you to adjust spacing at different screen sizes. Take the following div

<div class="rvt-p-bottom-sm rvt-p-bottom-lg-lg-up">
    <!-- markup -->
</div>

With these spacing classes applied, it would have 16px/1rem of bottom padding at all screen sizes and 32px/2rem of bottom padding on large screens (1080px wide) and up.

Spacing modifiers

All spacing utilities described above have the following responsive modifiers available to them:

  • -sm-up - screens 480–740px and wider
  • -md-up - screens 740–1080px and wider
  • -lg-up - screens 1080–1260px and wider
  • -xl-up - screens 1260–1400px and wider
  • -xxl-up - screens 1400px and wider
Rivet breakpoints

See the documentation about Rivet’s global breakpoints in the grid documentation.

Responsive removal of spacing

Sometimes you may need to totally remove the margin or padding of an element at different screen sizes. The margin/padding removal utility classes use the following pattern:

.rvt-*1-none-*2-up

  • *1 = m (margin) or p (padding)
  • *2 = one of the following breakpoints sm, md, lg, xl, xxl

Responsive spacing example

This box will have xxl top margin on small screens and no margin on md screens and up.

<div class="rvt-m-top-xxl rvt-m-top-none-lg-up">
  <div class="rvt-box">
    <div class="rvt-box__body">
      <p>This box will have xxl top margin on small screens and no margin on md screens and up.</p>
    </div>
  </div>
</div>

Add spacing to all sides

Using the size conventions above you could apply the class .rvt-p-all-xl to add an Extra large amount (40px/2.5rem) to both the top and bottom of an element.

On this page

  • About spacing
    • Spacing examples
  • Spacing Sass variables
  • Implementation
    • Responsive spacing
    • Spacing modifiers
    • Add spacing to all sides
  • Accessibility
  • Privacy Notice
  • Copyright © The Trustees of Indiana University