Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Spacing

    Padding, margin, and the space between children, on the spacing scale.

    A bare number is a step on the spacing scale (--p: 4 is 4 × --spacing). The named --space-* tokens map to 1, 2, 4, 6, 11, 24, and 40; use the number in style. Any length works too. Sides are t, r, b, l and set logical properties, so l is the right side in a right-to-left document. Margins also take auto.

    --space-x and --space-y go on a container and put a margin after each direct child but the last: on the inline end for x, the block end for y. They take states and breakpoints on the container and need a base (--space-y: 2; --space-y--md: 4). A child's own margin utility wins. A nested container on the same axis still gets its parent's margin; its own value spaces its children. Dialogs and popovers keep their own margins. A hidden last child still counts as the last, so the visible one before it keeps its margin, and flex-direction: row-reverse puts the margins on the wrong side. In flex and grid, use --gap; it wraps cleanly and leaves the children's margins alone.

    Reference

    Spacing utilities
    UtilityWritesValueTiersNotes
    --ppaddingscale number or lengthbreakpointsworks tier-only; --before-p / --after-p
    --pxpadding-inlinescale number or lengthbreakpointsworks tier-only; --before-px / --after-px
    --pypadding-blockscale number or lengthbreakpointsworks tier-only; --before-py / --after-py
    --ptpadding-block-startscale number or lengthbreakpointsworks tier-only; --before-pt / --after-pt
    --prpadding-inline-endscale number or lengthbreakpointsworks tier-only; --before-pr / --after-pr
    --pbpadding-block-endscale number or lengthbreakpointsworks tier-only; --before-pb / --after-pb
    --plpadding-inline-startscale number or lengthbreakpointsworks tier-only; --before-pl / --after-pl
    --mmarginscale number or lengthbreakpointsKeywords: auto
    --mxmargin-inlinescale number or lengthbreakpointsKeywords: auto
    --mymargin-blockscale number or lengthbreakpointsKeywords: auto
    --mtmargin-block-startscale number or lengthbreakpointsKeywords: auto
    --mrmargin-inline-endscale number or lengthbreakpointsKeywords: auto
    --mbmargin-block-endscale number or lengthbreakpointsKeywords: auto
    --mlmargin-inline-startscale number or lengthbreakpointsKeywords: auto
    --space-xmargin-inline-end on each direct child but the lastscale number or lengthbreakpoints, states
    --space-ymargin-block-end on each direct child but the lastscale number or lengthbreakpoints, states

    Examples

    --p: 2
    --p: 4
    --p: 6
    --p: 11
    <div
      style="
        --display: flex;
        --flex-wrap: wrap;
        --items: start;
        --gap: 6;
      "
    >
      <div
        style="
          --p: 2;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 2
        </div>
      </div>
      <div
        style="
          --p: 4;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 4
        </div>
      </div>
      <div
        style="
          --p: 6;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 6
        </div>
      </div>
      <div
        style="
          --p: 11;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 11
        </div>
      </div>
    </div>
    --p: 6
    --p: 6; --pl: 0
    --p: 6; --py: 2
    <div
      style="
        --display: flex;
        --flex-wrap: wrap;
        --items: start;
        --gap: 6;
      "
    >
      <div
        style="
          --p: 6;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 6
        </div>
      </div>
      <div
        style="
          --p: 6;
          --pl: 0;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 6; --pl: 0
        </div>
      </div>
      <div
        style="
          --p: 6;
          --py: 2;
          --bg: var(--color-muted);
          --radius: 2.5;
        "
      >
        <div
          data-ui="text-xs"
          style="
            --display: grid;
            --place-items: center;
            --p: 4;
            --aspect: 1;
            --font-weight: strong;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 1.5;
          "
        >
          --p: 6; --py: 2
        </div>
      </div>
    </div>
    --mx: auto
    start --ml: auto
    <div
      style="
        --display: flex-col;
        --gap: 6;
        --w: 100%;
        --max-w: 96;
      "
    >
      <div
        style="
          --p: 4;
          --bg: var(--color-muted);
          --radius: 4.5;
        "
      >
        <div
          data-ui="text-sm"
          style="
            --p: 4;
            --mx: auto;
            --w: fit-content;
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-primary-foreground);
            --bg: var(--color-primary);
            --radius: 2.5;
          "
        >
          --mx: auto
        </div>
      </div>
      <div
        style="
          --display: flex;
          --p: 4;
          --gap: 4;
          --bg: var(--color-muted);
          --radius: 4.5;
        "
      >
        <span data-ui="badge" data-badge-variant="muted">start</span>
        <span data-ui="badge" data-badge-variant="primary" style="--ml: auto">--ml: auto</span>
      </div>
    </div>

    --space-y: 2 puts a margin after each paragraph.

    The last one gets none.

    A child's own margin utility wins.

    <div style="--space-y: 6">
      <div style="--space-y: 2">
        <p>--space-y: 2 puts a margin after each paragraph.</p>
        <p>The last one gets none.</p>
        <p>A child's own margin utility wins.</p>
      </div>
      <div
        style="
          --display: flex;
          --space-x: 2;
          --space-x--md: 4;
        "
      >
        <button type="button" data-ui="button">Save</button>
        <button type="button" data-ui="button" data-button-variant="outline">Cancel</button>
        <button type="button" data-ui="button" data-button-variant="ghost">Help</button>
      </div>
    </div>

    API