Place a set of elements one next to the other.

Use these in contexts where you want to place similar elements in a tidy fashion, with precise control over the alignment and spacing of elements, such as toolbars or button groups.

The alternative, GsCols, can be used instead when you need to fit the whole container with the elements. This is not how the stack works and therefore you shouldn’t use this component when you need full width.

Usage

Group the elements to stack in a container with the GsStack class.

<div class="GsStack">
  <div>Node</div>
  <div>Node</div>
  <div>Node</div>
  <div>Node</div>
</div>

The stack will wrap nicely if the screen isn’t large enough for the items. If you can’t accept flowing the elements when the viewport is too small to fit them all, switch to GsCols, which doesn’t have this behaviour.

Change the size of the window to test the behaviour in the following example:

Stack alignment

You can position the stack elements with one of the following modifiers:

  • GsStack--start: puts them at the start of the container.
  • GsStack--end: puts them at the end of the container.
  • GsStack--center: puts them centered in the container.
  • GsStack--fill: fill the whole container, with space in between.

Stack direction

By default, the stack is horizontal: items are placed horizontally and in the order they are input. You can change this with the additional modifiers:

  • GsStack--h: horizontal mode.
  • GsStack--hr: horizontal mode, reversed.
  • GsStack--v: vertical mode.
  • GsStack--vr: vertical mode, reversed.

Stack baseline

Use the baseline modifiers to align items across the stack direction.

  • GsStack--top aligns items to the start of the cross axis.
  • GsStack--middle centers items on the cross axis.
  • GsStack--bottom aligns items to the end of the cross axis.
  • GsStack--hexpand stretches items along the cross axis.

Gap size

Use the standard gap modifier to configure the size of the gap.