/// Layout
Spacer
A presentational spacer — a fixed token-scale gap, or a flexible fill that pushes siblings apart.
import { Spacer } from "@protocore/pds";Fixed size
With a size, Spacer inserts a fixed gap on the --pds-space-* scale — a one-off nudge between two elements without touching their margins.
Deploy summary
3 services updated, 0 failed.
rolled out in 4.2s
Flexible push
Omit size and the Spacer grows (flex: 1) to fill available space, pushing the elements on either side apart — the classic "brand on the left, actions on the right" bar.
When to use it
A flexible Spacer is the idiomatic way to push siblings to opposite ends of a flex row — reach for it before justify-content when only one gap needs to grow. A fixed Spacer handles a single exceptional gap that breaks from the surrounding rhythm. When *every* child needs the same gap, don't sprinkle Spacers between them — use a Stack (or Grid) gap, which is cleaner and keeps the rhythm in one place. Spacer is purely presentational and aria-hidden; when the separation should be *seen*, use a Divider instead.
Usage
Do
- Use a flexible Spacer to push a brand and actions to opposite ends of a row.
- Use a fixed Spacer for a single gap that intentionally breaks the rhythm.
- Prefer a Stack/Grid gap when the same spacing repeats between many children.
Don't
- Insert a Spacer between every list item — that is what a gap is for.
- Use a Spacer where a visible rule is wanted; that is a Divider.
- Pass a raw pixel value — size is a step on the token scale.
Accessibility
- Spacer renders an `aria-hidden` `<span>` and is absent from the accessibility tree.
- It carries no content, so it never affects reading or focus order.
Mobile (React Native)
Preview. @protocore/pds-mobile ships the React Native sibling of Spacer. It mirrors the web API where React Native allows; the package is a preview with no device-level QA yet, so pin it and expect small changes.
Import it from the mobile package (not @protocore/pds), inside a <PdsProvider> — there is no stylesheet, so style (a ViewStyle) replaces className and every value comes from the theme:
import { Spacer } from "@protocore/pds-mobile";Parity with web. A layout gap — a fixed token size, or grows to fill (flex: 1) when size is omitted.
- Purely presentational and hidden from the a11y tree.
<HStack>
<Text>Left</Text>
<Spacer />
<Text>Right</Text>
</HStack>Spacer props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | — | |
size | enum | — | Fixed size on the `--pds-space-*` scale. Omit to grow and fill (flex: 1). |
style | CSSProperties | — |