Size #
Size tokens define the width and height of components, ensuring consistent proportions across the system.
They provide predictable sizing steps that help maintain alignment and balance in layouts.
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-size-scale) * <rem-value>).
| Custom Property | Value | Preview |
|---|---|---|
--afp-size-3xs |
0.5rem (8 px) |
|
--afp-size-2xs |
0.625rem (10 px) |
|
--afp-size-xs |
1rem (16 px) |
|
--afp-size-s |
1.875rem (30 px) |
|
--afp-size-m |
2.5rem (40 px) |
|
--afp-size-l |
3.125rem (50 px) |
|
--afp-size-xl |
3.75rem (60 px) |
|
--afp-size-2xl |
4.375rem (70 px) |
|
--afp-size-3xl |
5rem (80 px) |
|
--afp-size-25 |
25% |
|
--afp-size-50 |
50% |
|
--afp-size-75 |
75% |
|
--afp-size-100 |
100% |
Scale #
--afp-size-scale
The global size multiplier --afp-size-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 #
Sizes can also be applied using utility-style CSS classes. These classes map directly to the underlying size tokens and are generated at build time.
The syntax follows a simple pattern: afp-{context}:{size}
Example #
<div
class="
afp-background:surface-elevated
afp-width:size-3xl
afp-height:size-3xl
"
>
</div>
<div
class="
afp-background:surface-elevated
afp-width:size-3xl
afp-height:size-3xl
"
>
</div>
<div
class="
afp-background:surface-elevated
afp-width:size-3xl
afp-height:size-3xl
"
>
</div>
<div
class="
afp-background:surface-elevated
afp-width:size-3xl
afp-height:size-3xl
"
>
</div>
In this example:
- The
afp-width:size-3xlclass sets the element's width to--afp-size-3xl. - The
afp-height:size-3xlclass sets the element's height to--afp-size-3xl.
Contexts #
| Context | Applies to |
|---|---|
width |
width property |
height |
height property |
wh |
width and height |