Skip to main content
Gremorie

Spacing

A single base (4px) generates the entire spacing scale through Tailwind v4 calc().

Spacing is the rhythm of the interface. It is what says "these two elements belong together" and "this other one is part of another group" without writing a word. In UI, 70% of visual decisions are spacing decisions, and doing it well means you stop inventing values and start using a scale.

How the scale works

Gremorie inherits the Tailwind v4 strategy: a single variable (--spacing: 0.25rem, that is, 4px) generates the entire family of utilities through calc().

/* Tailwind v4 deriva tudo disso: */
.p-1 {
  padding: calc(var(--spacing) * 1);
} /* 4px */
.p-2 {
  padding: calc(var(--spacing) * 2);
} /* 8px */
.p-4 {
  padding: calc(var(--spacing) * 4);
} /* 16px */
.gap-6 {
  gap: calc(var(--spacing) * 6);
} /* 24px */
.h-32 {
  height: calc(var(--spacing) * 32);
} /* 128px */

The practical consequence: there is no list of stops like in radius or shadow. Any multiplier works - p-7, p-13, p-50. In general we stick to the increments 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64, 72, 80, 96, which cover 99% of cases.

Why 4px

The 4px base (0.25rem) is the smallest useful increment in UI:

  • A multiple of 2 and 4, so it fits common pixel densities.
  • It combines well with line-heights of 16px (default body), 20px (text-sm) and 24px (text-base).
  • Thin stops (p-0.5 = 2px) cover hairline cases (separators, borders).

If you need to rescale the whole system to be denser or more spacious, edit --spacing in a higher CSS layer and every utility cascades.

Reference scale

The table below shows a representative subset. Any integer multiplier, or fractional down to a quarter, works.

AmostraPassoClasseRemPixelsUso
0p-00rem0pxZero espaço — reset
0.5p-0.50.125rem2pxHairline — bordas, separadores ultra-finos
1p-10.25rem4pxPadding mínimo de UI compacta
1.5p-1.50.375rem6pxPill / tag interno
2p-20.5rem8pxPadding interno de inputs e botões pequenos
3p-30.75rem12pxEspaçamento entre elementos relacionados
4p-41rem16pxPadding padrão de cards e containers
5p-51.25rem20pxPadding intermediário
6p-61.5rem24pxPadding amplo de cards, gap entre seções
8p-82rem32pxEspaçamento entre blocos
10p-102.5rem40pxEspaçamento generoso
12p-123rem48pxPadding hero
16p-164rem64pxMargens de seção em landings
20p-205rem80pxEspaçamento entre seções em landings
24p-246rem96pxPadding de hero generoso
32p-328rem128pxEspaçamento dramático
48p-4812rem192pxDisplay, ilustrações ocupando largura
64p-6416rem256pxLarguras fixas grandes (sidebars, hero columns)
96p-9624rem384pxLarguras gigantes (extremo da escala)

Best practices

  • 4 and 6 are the safe defaults for internal UI padding (p-4 on cards, p-6 on larger containers).
  • 8, 12, 16 for gaps between related elements.
  • 20, 24 for gaps between content sections inside the same surface.
  • 64, 80, 96 for gaps between macro sections on landing pages.
  • Do not invent values. If you are about to write padding: 18px, ask whether p-4 (16px) or p-5 (20px) would do. Scale consistency is worth more than the exact pixel.
  • Prefer gap-* over margins when possible. Flex and grid with gap are more predictable than cascading margins.

On this page