[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationSpacer

Spacer

A flexible gap that pushes its neighbors apart in a stack, or holds an empty cell in a grid row.

Spacer takes the free space between its neighbors. In an HStack it grows sideways, and in a VStack it grows downward. Put one between the title and the actions of a toolbar, and the title stays left while the actions move to the right edge.

Horizontal stack HStack
Connecting to the DMS preview…
Connecting DMS 0.25.8

Usage

src/pages/installations.ts ts
import { HStack, Spacer } from "@antelopejs/interface-dms/base/stack";
import { LiveToggle } from "@antelopejs/interface-dms/base/live-toggle";
import { PeriodSelector } from "@antelopejs/interface-dms/base/period-selector";

static toolbar = HStack({ alignment: "center" })
  .child("live", LiveToggle())
  .child("spacer", Spacer())
  .child("period", PeriodSelector({ id: "production" }));

Options

Options of the Spacer block
OptionTypeDefaultDescription
minSize Layoutstring–Smallest size the spacer shrinks to.
maxSize Layoutstring–Largest size the spacer grows to.
grow Layoutnumber1Share of the leftover space the spacer takes.

Behavior

  • grow is the spacer's share of the free space, 1 by default. Two spacers at grow: 1 and grow: 2 take one third and two thirds of it.
  • minSize and maxSize bound the spacer in both directions. They set its minimum and maximum width and height.
  • A spacer adds no gap of its own. The stack's spacing applies once between the spacer's neighbors, so they sit spacing apart when there is no free space to fill.
  • In a GridRow, a spacer holds an empty cell, so the next cells line up with the grid's columns. When the grid has fewer columns than its widest row, as on a phone, the spacer hides.

Pitfalls

  • A maxSize smaller than the free space leaves the rest of it to the stack's distribution.
  • Inside an HStack that holds a spacer, sibling stacks keep their content width so the spacer can push them aside. Without a spacer, they share the row by their grow.

Next steps

Stacks

Rows and columns of blocks.

Grid

Responsive rows and columns.