Spacer
Empty layout element that injects a fixed gap on a single axis. Used inside flex/grid containers where adding a token-sized gap as a sibling reads cleaner than the gap utility.
Status: beta. Group: structure. Markdown version: /design-system/components/spacer.md
When to use
Spacer inserts a fixed, aria-hidden gap where you cannot control the parent's layout; between blocks you don't own, or in markup that isn't a Stack. It is the escape hatch, not the default: prefer gap on Stack/FlexBox/Grid first. axis="horizontal" makes it a width in inline rows.
When not to use
- Do not stack two Spacers; collapse them into the larger size.
- Do not use as a 'push' element to right-align content; use flex
margin-inline-start: autoinstead. - Do not use Spacer for page-band rhythm; Section's spacing prop owns that.
Look-alikes
- Divider: Do not use dividers as spacing; if you only need distance, use gap or Spacer.
Props
| Prop | Type | Default | Description | Required |
|---|---|---|---|---|
size | "sm" | "md" | "lg" | "xl" | "xs" | "2xl" | md | Tokenized gap size. | No |
axis | "horizontal" | "vertical" | vertical | Block (vertical) or inline (horizontal) axis. | No |
className | string | none | Additional CSS class names. | No |
Variants
- Available sizes:
sm,md,lg,xl,xs,2xl(defaultsm). - Allowed
axisvalues:horizontal,vertical(defaultvertical).
Invalid combinations
The contract records no invalid combinations.
Keyboard
The contract records no keyboard interaction.
Rules
Every item under When not to use is a MUST NOT. MUST and SHOULD follow RFC 2119.
| Level | Rule | How it is checked |
|---|---|---|
| MUST | ARIA: Renders as a non-interactive <div>; assistive tech ignores it. | Not yet verified: no evidence record. WCAG 4.1.2. |
| MUST | Required stories produce no axe violations at the configured severity. | Automated by npm run test:stories:matrix:ci. WCAG 2.5.8. |
| MUST | The accessibility tree (role, name, state) matches the committed snapshot for every required story. | Automated by npm run test:stories:matrix:ci. WCAG 1.3.1, 4.1.2. |
| MUST | The component remains legible and operable under a real browser forced-colors: active pass. | Automated by npm run test:stories:hc. |
| MUST | A human completed an end-to-end accessibility review of this component. | Manual review, last on 2026-05-28. |
| SHOULD | Reach for parent gap first (Stack/FlexBox/Grid); use Spacer only where you cannot own the parent. | Not stated in the contract. |
| SHOULD | Use axis="horizontal" inside flex rows; the default vertical axis is for block flow. | Not stated in the contract. |
| SHOULD | Pick the one size that matches the rhythm step you need; sizes map to the space scale. | Not stated in the contract. |
| SHOULD | Keep it aria-hidden (built in); it must never carry content or semantics. | Not stated in the contract. |
| SHOULD NOT | Do not stack multiple Spacers to add up space; use the next size. | Not stated in the contract. |
Install and import
- Install:
npm install @digitaltableteur/react(version 0.9.1, restricted access on npm). - Import:
import { Spacer } from "@digitaltableteur/react"; - Entry point:
@digitaltableteur/react/layoutexports it too. - Styles: import
@digitaltableteur/react/style.cssonce at the app boundary. - Also available as the custom element
<dt-spacer>; see the custom elements manifest.
Links
- Machine-readable contract (Design System Contract 1.0)
- Markdown version of this page
- Component index as JSON
- All components
- Source: The implementation lives in a private repository. This page, its Markdown twin and the contract are generated from it at build time and are the public source of truth.