Spacer
Adds space between elements, horizontally or vertically. Takes a responsive value per breakpoint.
Health
Source
Design
Storybook
Playground
No Example
Accessibility
compliant
Platform
Universal
- Overview
- Props
- Figma
Usage
Hello
World
Responsive values
It's possible to have a responsive value, based on breakpoints:
<Spacer size={{ $xs: "$px4", $md: "$px8" }} />
Migrations
Replacing unit with size
We used to have a unit prop, which was a number of units (which would result in 4 * units pixels). This has been replaced with size, which is an object of responsive values, accepting design tokens
Most usages have been replaced, but if you see a unit prop, you can replace it with size. The main different is to remember to multiply the unit by 4 to get the right size token:
- <Spacer units={2} />
+ <Spacer size="$px8" />
- <Spacer units={{ xs: 4, md: 6 }} />
+ <Spacer size={{ $xs: "$px16", $md: "$px24" }} />
tip
This component is universal, its usage is the same in
murray and murray/mobile.Spacer props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| horizontal | booleanundefined | false | ||
| size | 77 possibilitiesundefined"unset""$0""$1""$2""$4""$6""$8""$10""$12""$14""$16""$20""$24""$28""$32""$36""$40""$44""$48""$56""$64""$80""$96""$112""$128""$144""$160""$176""$192""$px0""$px1""$px2""$px4""$px6""$px8""$px10""$px12""$px14""$px16""$px20""$px24""$px28""$px32""$px36""$px40""$px44""$px48""$px56""$px64""$px80""$px96""$px112""$px128""$px144""$px160""$px176""$px192"UnionableNumber"inherit"`var(${string})`"auto"PercentString`${number}vw``${number}dvw``${number}lvw``${number}svw``${number}vh``${number}dvh``${number}lvh``${number}svh``calc(${string})``min(${string})``max(${string})`"max-content""min-content"MediaProps<SizeTokens> | $px8 | Size of the spacer, using design tokens (also accept values in pixels as a fallback) |
Deprecated props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| units | undefinednumberResponsive<number> | use `size` instead @see [Migration Guide](https://murray.alan.com/docs/components/layout/Spacer#migrations) |