Documentation Index
Fetch the complete documentation index at: https://mintlify.com/danielitoCode/compose_svelted/llms.txt
Use this file to discover all available pages before exploring further.
Spacer is an empty div whose size is controlled entirely by a modifier. It has no visual appearance of its own — its sole purpose is to occupy space inside a Column or Row in a way that is explicit, readable, and intention-revealing.
In a flex container, a Spacer with Modifier.weight(1) expands to fill all remaining space on the main axis, pushing siblings apart just like Spacer(modifier = Modifier.weight(1f)) does in Jetpack Compose. A Spacer with a fixed Modifier.height(n) or Modifier.width(n) inserts a precise gap, which is useful when Arrangement.spacedBy() would apply the same gap everywhere but you need a one-off larger gap between two specific items.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
modifier | Modifier | Modifier.empty() | Determines the size and display behaviour of the spacer. |
div:
Fixed-size spacer
UseModifier.height(n) inside a Column or Modifier.width(n) inside a Row to add a precise, non-flexible gap between two specific children.
Flexible spacer with Modifier.weight()
When you apply Modifier.weight(1) to a Spacer it participates in flex growth, expanding to consume all leftover space on the main axis. This pushes surrounding siblings to opposite ends of the container — a pattern that appears constantly in toolbars, list rows, and navigation bars.
Push a label and an action to opposite ends of a Row:
Spacer vs Arrangement.spacedBy()
Both tools add space between children, but they serve different roles:
Spacer | Arrangement.spacedBy(n) | |
|---|---|---|
| Applies to | A single gap between two specific siblings | Every gap between all siblings uniformly |
| Flexible (grows) | ✅ Yes, with Modifier.weight(1) | ❌ No — always a fixed pixel value |
| Readable intent | Explicit — you see the Spacer in the tree | Implicit — set once on the container |
| Best for | Pushing items apart, one-off large gaps, footer anchoring | Uniform card lists, form fields, icon rows |
A
Spacer without any modifier renders as a zero-size element and has no visual effect. Always pair it with at least one sizing modifier — height, width, or weight.