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 is deprecated. Please use Rivet 2 instead.
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.5.0

Width

Use Rivet's width utilities to constrain the width of interface elements, particularly form fields.

Migrating to Rivet 2

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

New in Rivet 1.5.0

The width utilities were introduced in Rivet 1.5.0. If you need help updating to 1.5.0, see our instructions for updating Rivet.

Width utility CSS classes

You can constrain the width of a block-level element by applying one of the classes listed below.

Rivet width units
CSS class rem px
.rvt-width-xxs 4rem 64px
.rvt-width-xs 8rem 128px
.rvt-width-sm 12rem 192px
.rvt-width-md 16rem 256px
.rvt-width-lg 20rem 320px
.rvt-width-xl 24rem 384px
.rvt-width-xxl 32rem 512px
Not intended for layout

The width utility classes are intended for use when fine-tuning the appearance of individual elements on a page and should not be used for high-level page layout. To lay out pages, use the Rivet grid instead.

Width utility examples

Width utility classes are especially useful for form inputs, which should have their widths constrained to match the expected length of the information you’re asking someone to give you.

For example, a form field asking someone for their ZIP code should be much smaller than one asking for their street address.

<div class="rvt-width-xxs">
  <label for="input-1">xxs</label>
  <input type="text" id="input-1">
</div>

<div class="rvt-width-xs rvt-m-top-lg">
  <label for="input-2">xs</label>
  <input type="text" id="input-2">
</div>

<div class="rvt-width-sm rvt-m-top-lg">
  <label for="input-3">sm</label>
  <input type="text" id="input-3">
</div>

<div class="rvt-width-md rvt-m-top-lg">
  <label for="input-4">md</label>
  <input type="text" id="input-4">
</div>

<div class="rvt-width-lg rvt-m-top-lg">
  <label for="input-5">lg</label>
  <input type="text" id="input-5">
</div>

<div class="rvt-width-xl rvt-m-top-lg">
  <label for="input-6">xl</label>
  <input type="text" id="input-6">
</div>

<div class="rvt-width-xxl rvt-m-top-lg">
  <label for="input-7">xxl</label>
  <input type="text" id="input-7">
</div>

Responsive widths

Each width utility class comes with a set of modifiers that allow you to specify the screen size at which the constrained width should take effect.

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

With these spacing classes applied, the div would have a width of 192px/12rem only on large screens (1080px wide) and up.

All width utility classes 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.

Combining width and flex utilities

The width utility classes can be combined with Rivet’s flex utilities to position elements next to one another horizontally.

<div class="rvt-display-flex">
  <div class="rvt-width-xl rvt-m-right-md">
    <label for="input-8">Flex inputs</label>
    <input type="text" id="input-8">
  </div>
  
  <div class="rvt-width-sm">
    <label for="input-9">Flex inputs</label>
    <input type="text" id="input-9">
  </div>
</div>

Width Sass variables

If you are using Rivet’s Sass files, you can directly access any width unit by its variable name.

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

Rivet width Sass variables
Variable rem px
$width-xxs 4rem 64px
$width-xs 8rem 128px
$width-sm 12rem 192px
$width-md 16rem 256px
$width-lg 20rem 320px
$width-xl 24rem 384px
$width-xxl 32rem 512px

On this page

    • Width utility CSS classes
    • Width utility examples
      • Responsive widths
    • Combining width and flex utilities
    • Width Sass variables
  • Accessibility
  • Privacy Notice
  • Copyright © The Trustees of Indiana University