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.
HStack Connecting to the DMS preview…
Usage
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
| Option | Type | Default | Description |
|---|---|---|---|
minSize Layout | string | – | Smallest size the spacer shrinks to. |
maxSize Layout | string | – | Largest size the spacer grows to. |
grow Layout | number | 1 | Share of the leftover space the spacer takes. |
Behavior
growis the spacer's share of the free space, 1 by default. Two spacers atgrow: 1andgrow: 2take one third and two thirds of it.minSizeandmaxSizebound 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
spacingapplies once between the spacer's neighbors, so they sitspacingapart 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
maxSizesmaller than the free space leaves the rest of it to the stack'sdistribution. - Inside an
HStackthat holds a spacer, sibling stacks keep their content width so the spacer can push them aside. Without a spacer, they share the row by theirgrow.
