Appearance
Size Tokens β
Border Width
Figma's box model has borders sitting inside the padding region; in HTML the borders sit between the padding region and margin region. We shall use the HTML box model here.
Inline Size β
Inline size is a complicated value to describe. It may be externally fixed, with content overflow behaviour defined as needed (ellipsis or wrapping), or it may be that the content is let to grow as desired.
Either way, the inline padding defines the minimum gap between the edges and content:
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
With the gap separating content areas:
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
Plus the border width:
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
Block Size β
The overall block size of a rectangle comes from its content (based on the line height).
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
Plus any block padding:
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
Plus the border width:
Border widthββ
βBlock paddingβ
βInline paddingβ
Leading
βGapβ
Central
βGapβ
Trailing
β₯Line height
Border radiusβΆ
The border-width is usually a fixed value that does not need to respond to any external changesβattempting a non-integer border width is likely to result in different appearances between different browsers and platforms.
Variables β
With this established, we may consider a set of t-shirt sized containers:
Container Sizes
Name
Value
Sizing
Medium
Block Padding
12px Inline Padding
12px Gap
4pxSizing
Large
Block Padding
16px Inline Padding
24px Gap
8pxAs usual, we can use modes to ensure grouped usage of values (so that Sizing.Medium.Block Padding isn't accidentally used with Sizing.Large.Inline Padding):
Container Sizes
Name
Medium
Large
Sizing
Block Padding
12px16px Inline Padding
12px24px Gap
4px6pxUnits β
As with typography, we should consider whether we want padding in our UI to follow the browser root font size, which can be achieved by switching to rem units:
Container Sizes
Name
Medium
Large
Sizing
Block Padding
0.75rem1rem Inline Padding
0.75rem1.5rem Gap
0.25rem0.375remA further optional extension is to switch to using the lh unit:
Container Sizes
Name
Medium
Large
Sizing
Block Padding
0.75lh1lh Inline Padding
0.75lh1.5lh Gap
0.25lh0.375lhThis now means that our containers will respond in size with changes to both the root font size, and the line height applied to the container.
This is delightfully simple to do in CSS, and near impossible in design tooling.