Space
Space applies consistent spacing between neighboring elements.
@duskmoon-dev/components/space Usage
When to use
- Use it to build predictable page, toolbar, panel, or grid structure.
- Keep layout primitives responsible for geometry and let child components own behavior.
Implementation notes
Features
Documents spacing, responsive behavior, and nested regions used to build larger screens.
Examples keep predictable dimensions so the surrounding UI does not jump while content changes.
Space is most often configured through `size`, `direction`, `align`, `split`.
Renders children with spacing wrappers
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and Space from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function Example() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Renders children with spacing wrappers
test-backedSpace scenario from the component test coverage: renders children with spacing wrappers.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function SpaceRendersChildrenWithSpacingDemo() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Supports size and vertical direction
test-backedSpace scenario from the component test coverage: supports size and vertical direction.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function SpaceSupportsSizeAndVerticalDemo() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Supports split and wrap
test-backedSpace scenario from the component test coverage: supports split and wrap.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function SpaceSupportsSplitAndWrapDemo() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Exposes Compact component
test-backedSpace scenario from the component test coverage: exposes compact component.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function SpaceExposesCompactComponentDemo() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Forwards root ref
test-backedSpace scenario from the component test coverage: forwards root ref.
import "@duskmoon-dev/components/styles.css";
import { Space } from "@duskmoon-dev/components/space";
export function SpaceForwardsRootRefDemo() {
return (<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>
</div>
<div data-theme="moonlight">
<Space size="middle" wrap split="|">
<span>Design</span>
<span>Build</span>
<span>Ship</span>
</Space>
</div> API
The API reference below lists every parsed exported type or interface for Space. Start with `size`, `direction`, `align`, `split` for common usage.
packages/components/src/components/space/Space.types.ts
Scenarios: packages/components/src/components/space/Space.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
size | SpaceSize | [SpaceSize, SpaceSize] | No | size configures Space. |
direction | SpaceDirection | No | direction configures Space. |
align | SpaceAlign | No | align configures Space. |
split | ReactNode | No | split configures Space. |
wrap | boolean | No | wrap configures Space. |
| Prop | Type | Required | Description |
|---|---|---|---|
block | boolean | No | block configures Space. |
direction | SpaceDirection | No | direction configures Space. |
size | SpaceSize | No | size configures Space. |
| Prop | Type | Required | Description |
|---|---|---|---|
Compact | React.ForwardRefExoticComponent< | Yes | Compact configures Space. |
"small" | "middle" | "large" | number "horizontal" | "vertical" "start" | "end" | "center" | "baseline"