r-scale spacing
Utilities for spacing and sizing elements with the theme's responsive r1–r15 scale, plus the hit-area utilities for enlarging tap targets.
Utilities for spacing and sizing elements with the theme's responsive r1–r15 scale.
gap-r{1–15} / gap-x-r{n} / gap-y-r{n}
gap: var(--r{n}) on a flex or grid container
p-r{n}, px-, py-, pt-, pb-, pl-, pr-, ps-, pe-
Padding on the scale
m-r{n} and the same side variants
Margin on the scale
w-r{n} / h-r{n} / size-r{n}
Width, height, or both
min-w-r{n} / min-h-r{n}
Minimum width or height
top-r{n} / bottom-r{n} / left-r{n} / right-r{n} / start-r{n} / end-r{n} / inset-r{n}
Position offsets
space-x-r{n}, scroll-p-r{n}, translate-x-r{n}, basis-r{n}, …
The steps are registered on Tailwind's spacing scale, so core spacing utilities accept them
hit-area-r{n}
Grows the element's click target by the step on all sides, with a ::before pseudo-element
hit-area-{x|y|t|b|l|r|s|e}-r{n}
Grows one axis or side. s and e follow the text direction
hit-area…-before / hit-area…-after
Picks which pseudo-element carries the hit area (default ::before)
hit-area (no step)
Adds the pseudo-element with no growth. Growth comes from --hit-area-{top,right,bottom,left} variables set elsewhere
Each step reads a --r{n} variable from :root. At 768px it changes to the tablet value. At 1024px it changes to the desktop value. Keep the same class at every breakpoint. See Scaling.
Values
This table maps spacing steps to pixels. Text uses the same step numbers with a different set of values. See Type utilities.
r1
2px
2px
2px
r2
4px
4px
4px
r3
6px
6px
6px
r4
8px
8px
8px
r5
10px
12px
12px
r6
12px
15px
16px
r7
14px
18px
20px
r8
16px
22px
24px
r9
20px
27px
32px
r10
24px
35px
38px
r11
32px
45px
50px
r12
42px
56px
68px
r13
60px
75px
96px
r14
80px
105px
128px
r15
120px
150px
192px
Examples
A basic gap
Use gap-r{n} to space the items of a flex or grid container:
The gap tightens to 10px on mobile and opens to 12px on desktop without a breakpoint prefix.
Padding and margin
Use the padding and margin utilities with an r step, including the logical side variants ps- and pe-:
Sizing an element
Use w-r{n}, h-r{n}, and size-r{n} to size boxes on the same scale, so decoration grows with the spacing around it:
Enlarging a tap target
Use hit-area-r{n} on a relative element to grow its click target without moving the layout:
The transparent pseudo-element increases the hit area without changing layout. Use an axis variant for a control in a dense row. The header toolbar uses hit-area-y-r5 to reach the 44px minimum without widening its buttons. Use an -after variant when ::before is already used for decoration.
Customizing
Step values are compiled from constants.yml and aren't merchant settings. Merchants control gutters, section spacing, and page margins separately. See Scaling.
Last updated
Was this helpful?

