Skip to content

Spacing

Viljami Salminen edited this page Sep 28, 2018 · 12 revisions

Vue Design System uses the following framework and Sass Mixins for creating a predictable and harmonious spacing.

  • Inset spacing: For all user interface containers.
  • Inset squish spacing: Same as previous, but a squished inset reduces space top and bottom, for example by 50%. Used for buttons, inputs, data table cells, list items, etc.
  • Stack spacing: For all stacked content. So for example panels, form fields and anything else that is stacked vertically.
  • Inline spacing: For pills, tags, breadcrumbs, side-by-side form fields etc. Things that are displayed inline.

You simply use these via Sass Mixins, like so:

// Stack space
.heading {
  @include stack-space($space-l);
}
// Inset space
.container {
  @include inset-space($space-xl);
}
// Inline space
.pill {
  @include inline-space($space-s);
}
// You can also combine inset/inset-squish and inline/stack space
.button {
  @include inset-squish-space($space-l);
  @include inline-space($space-s);
}

These Sass helpers are located in src/styles/_spacing.scss if you want to further tweak them.

Advantages:

  • Most components come with spacing included using the above mixins.
  • A developer is able to just lay out components and they will take care of the spacing automatically as well as they can.
  • Collisions with component level spacing and inset spacing are solved systematically using advanced CSS selectors inside space mixins.

Resources:

Most of these ideas are from the following articles: