Skip to content

Spacings

The spacing system uses a two-layer approach: a numeric primitive scale (spacing.0spacing.96) and a set of semantic aliases (4xs4xl) that map to the primitives. Components and layouts should always reference the semantic aliases — they give consistent rhythm and can be adjusted per breakpoint without touching component code.

Semantic Scale

Each alias resolves to a CSS custom property --cn-spacing-{name} and a Tailwind utility class. Use gap-cn-*, p-cn-*, m-cn-*, and space-y-cn-* in your markup.

Token

Value

Preview

CSS VariableTailwind Class
00px—cn-spacing-0gap-0
px1px
—cn-spacing-pxgap-px
4xs2px
—cn-layout-4xsgap-cn-4xs
3xs4px
—cn-layout-3xsgap-cn-3xs
2xs6px
—cn-layout-2xsgap-cn-2xs
xs8px
—cn-layout-xsgap-cn-xs
sm12px
—cn-layout-smgap-cn-sm
md16px
—cn-layout-mdgap-cn-md
lg20px
—cn-layout-lggap-cn-lg
xl24px
—cn-layout-xlgap-cn-xl
2xl32px
—cn-layout-2xlgap-cn-2xl
3xl40px
—cn-layout-3xlgap-cn-3xl
4xl80px
—cn-layout-4xlgap-cn-4xl
autoautom-auto
full100%w-full

Tailwind Classes

All semantic tokens are available as Tailwind utilities with the cn- prefix:

PropertyPatternExample
Gapgap-cn-{size}gap-cn-sm
Paddingp-cn-{size}

p-cn-md, px-cn-lg, pt-cn-xs

Marginm-cn-{size}

m-cn-md, mx-cn-xl, mb-cn-sm

Space betweenspace-y-cn-{size}space-y-cn-md

When to Use What

  • 4xs–3xs — Micro gaps: icon-to-label, inline badge padding, compact chip internals
  • 2xs–xs — Tight component internals: button padding, input padding, dense list items
  • sm–md — Standard component spacing: card padding, form field gaps, list item spacing
  • lg–xl — Section-level separation: content block gaps, modal padding, sidebar sections
  • 2xl–4xl — Page-level divisions: hero sections, major feature areas, page margins

Primitive Scale

The full numeric scale (spacing.0spacing.96) follows a 4px base grid. Semantic aliases reference these primitives. For most use cases, stick with the semantic tokens above — the primitives are available for edge cases where an exact pixel value is needed.

Token

Value

Token

Value

Token

Value

00px936px1872px
px1px1040px2080px
half2px1144px2496px
14px1248px32128px
28px1352px40160px
312px1456px48192px
416px1560px56224px
520px1664px64256px
624px1768px96384px
728px
832px

Half-step tokens (1-half through 12-half) are also available for fine-grained adjustments: spacing.1-half = 6px, spacing.2-half = 10px, etc.