Spacing
Spacing utilities control margin, padding, and gap using a mathematical scale. All spacing derives from two custom properties in config.css: --size-base (32px) and --size-scale (2). Each step multiplies or divides by the scale factor, creating a predictable, harmonious progression.
The Size Scale
Six sizes from extra-small to double-extra-large. Each calculated from the base:
Change --size-base or --size-scale in config.css and the entire spacing system recalculates automatically.
Padding
Apply padding to all sides, specific sides, or axes. Visual examples show padding as the colored area inside each box:
Classes: .p-xs, .p-sm, .p-md, .p-lg, .p-xl, .p-2xl
Classes: .px-{size} for all six sizes
Classes: .py-{size} for all six sizes
Classes: .pt-{size}, .pr-{size}, .pb-{size}, .pl-{size}
Margin
Apply margin to all sides, specific sides, or axes. Margins create space outside elements:
Classes: .m-xs, .m-sm, .m-md, .m-lg, .m-xl, .m-2xl
Classes: .mx-{size}, .my-{size}
Classes: .mt-{size}, .mr-{size}, .mb-{size}, .ml-{size}
Gap
Control spacing between flex and grid children. Gap applies between items, not around them. Works with both flexbox and grid layouts:
Classes: .gap-xs through .gap-2xl
Classes: .gap-x-{size} for column spacing
Classes: .gap-y-{size} for row spacing
Container-Responsive Spacing
Spacing utilities include container query variants that respond to the width of the parent container, not the viewport. The md: prefix applies when the container is 900px or narrower. The sm: prefix applies when the container is 600px or narrower.
Container queries let components adapt based on available space, not screen size. A sidebar component uses the same spacing rules whether it appears on mobile or in a desktop sidebar.
.p-xl .md:p-lg .sm:p-md
Resize the browser to see padding adapt at container breakpoints
All margin, padding, and gap utilities include md: and sm: variants. Examples: .md:p-sm, .sm:mx-xs, .md:gap-lg
Fluid Spacing
Fluid spacing is a different approach to responsive spacing. Instead of stepping between fixed values at breakpoints, spacing scales continuously with the container width using clamp() and cqi units. The stepped approach gives you precise control at each breakpoint; the fluid approach gives you smooth scaling with a single class.
The naming inserts fluid into the standard pattern: .p-fluid-xl, .px-fluid-md, .gap-fluid-lg. The size label indicates the maximum -- spacing compresses proportionally as the container shrinks.
Fluid spacing requires an ancestor with container-type: inline-size (the .container class). The cqi unit resolves to 1% of the nearest container's width.
Drag the bottom-right corner to resize.
Fluid and fixed spacing compose naturally. Use fluid where you want scaling, fixed where you want stability:
Fluid gap works the same way inside grid and flex layouts:
Available for padding (.p-fluid-*, .px-fluid-*, .py-fluid-*), margin (.m-fluid-*, .mx-fluid-*, .my-fluid-*), and gap (.gap-fluid-*, .gap-x-fluid-*, .gap-y-fluid-*). Sizes run from xs to 2xl.