Space #
Spacing tokens provide a consistent rhythm and visual structure across the design system.
They are defined in rem units so that all values scale proportionally with the root font size.
Custom Properties #
These properties use rem units in order to scale proportionately with the root font size.
All values are multiplied internally by calc(var(--afp-space-scale) * <rem-value>).
| Custom Property | Default | Preview |
|---|---|---|
--afp-space-3xs |
0.125rem (2px) |
|
--afp-space-2xs |
0.25rem (4px) |
|
--afp-space-xs |
0.5rem (8px) |
|
--afp-space-s |
0.75rem (12px) |
|
--afp-space-m |
1rem (16px) |
|
--afp-space-l |
1.5rem (24px) |
|
--afp-space-xl |
2rem (32px) |
|
--afp-space-2xl |
2.5rem (40px) |
|
--afp-space-3xl |
3rem (48px) |
|
--afp-space-4xl |
4rem (64px) |
Scale #
--afp-space-scale
The global spacing multiplier --afp-space-scale lets you adjust all spacing values at once.
By default, this value is set to 1.
Each spacing step is calculated from this multiplier, with the resulting pixel values (based on a 16px root size) shown in the table below.
CSS Classes #
Space tokens can be applied using utility-style CSS classes to control spacing such as padding and margin.
These classes are generated at build time and map directly to the space tokens defined above.
The syntax follows the pattern used across the design system: afp-{context}:space-{space}
Example #
<div class="afp-padding:space-m afp-background:surface-elevated">
<div class="afp-margin-bottom:space-s">
Example
</div>
</div>
<div class="afp-padding:space-m afp-background:surface-elevated">
<div class="afp-margin-bottom:space-s">
Example
</div>
</div>
<div class="afp-padding:space-m afp-background:surface-elevated">
<div class="afp-margin-bottom:space-s">
Example
</div>
</div>
<div class="afp-padding:space-m afp-background:surface-elevated">
<div class="afp-margin-bottom:space-s">
Example
</div>
</div>
This applies:
padding: var(--afp-space-m)margin-bottom: var(--afp-space-s)
Contexts #
Padding #
| Context | Applies to |
|---|---|
afp-padding |
padding |
afp-padding-x |
padding-left, padding-right |
afp-padding-y |
padding-top, padding-bottom |
afp-padding-top |
padding-top |
afp-padding-right |
padding-right |
afp-padding-bottom |
padding-bottom |
afp-padding-left |
padding-left |
Margin #
| Context | Applies to |
|---|---|
afp-margin |
margin |
afp-margin-x |
margin-left, margin-right |
afp-margin-y |
margin-top, margin-bottom |
afp-margin-top |
margin-top |
afp-margin-right |
margin-right |
afp-margin-bottom |
margin-bottom |
afp-margin-left |
margin-left |