Skip to content

Type to search the docs, API, and blog.

↑↓ navigate↵ openesc close
  • Zazz 0.14 alpha

    API

    Layout

    Position, overflow, containers, and stacking.

    Where an element sits and how it clips. --display has a page of its own: display covers the flex directions, grid-pile, grid-gallery, and the subgrids, with an example of each. --isolation takes isolate or auto and is set once, at the base.

    --container-type: inline-size makes an element a query container, so the breakpoint tiers inside it follow its width. --container-name names it, and --container is the CSS name / type shorthand, or none. --container-type and --container take breakpoints; the name is set once, at the base. Watch the shorthand: --container: inline-size sets a name, not a type. On a sticky element use --container-type with --container-name, because the shorthand drops the scroll-state type; the audit warns about it.

    --anchor-name and --position-anchor take states and breakpoints, so the anchor can move with interaction: put --anchor-name--hover: --block on every block of an editor, and a toolbar with --position: absolute; --position-anchor: --block follows the hovered one. --position-area places it: --position-area: block-start span-inline-end puts the toolbar above the block, aligned to its start. For finer placement write anchor() in plain CSS. The inset utilities take numbers, lengths, and (on the four sides) auto, nothing else, so --top: anchor(bottom) computes to 0.

    --top, --right, --bottom, and --left take auto at any breakpoint, which lets a side you set at one width go back to auto at another. A bar that sticks to the bottom of a phone screen and to the top of a desktop one is --position: sticky; --bottom: 0; --bottom--lg: auto; --top: auto; --top--lg: 0. --inset, --inset-x, and --inset-y take lengths only.

    Reference

    Layout utilities
    UtilityWritesValueTiersNotes
    --aspectaspect-ratioany CSS valuebreakpointsworks tier-only; --before-aspect / --after-aspect
    --displaydisplaykeyword, plus flex shorthands that set the direction (flex-row, flex-row-reverse, flex-col, flex-col-reverse, inline-flex-row, inline-flex-row-reverse, inline-flex-col, inline-flex-col-reverse), grid-pile, which stacks the children in one cell, grid-gallery, which picks its column count from its child count, and subgrid, subgrid-col, subgrid-row, which take the parent grid's tracksbreakpoints--before-display / --after-display
    --object-fitobject-fitkeyword—
    --object-positionobject-positionany CSS value—
    --overflowoverflowkeyword—
    --overflow-xoverflow-xkeyword—
    --overflow-yoverflow-ykeyword—
    --positionpositionkeywordbreakpointsworks tier-only; --before-position / --after-position
    --anchor-nameanchor-namedashed ident (--toolbar), a list of them, or nonebreakpoints, statesworks tier-only
    --position-anchorposition-anchordashed ident naming an anchor, auto, none, or normalbreakpoints, statesworks tier-only
    --position-areaposition-areaone or two area keywords (block-start span-inline-end), or nonebreakpoints, statesworks tier-only
    --insetinsetscale number or lengthbreakpoints--before-inset / --after-inset
    --inset-xinset-inlinescale number or lengthbreakpoints--before-inset-x / --after-inset-x
    --inset-yinset-blockscale number or lengthbreakpoints--before-inset-y / --after-inset-y
    --topinset-block-startscale number or lengthbreakpointsKeywords: auto; --before-top / --after-top
    --rightinset-inline-endscale number or lengthbreakpointsKeywords: auto; --before-right / --after-right
    --bottominset-block-endscale number or lengthbreakpointsKeywords: auto; --before-bottom / --after-bottom
    --leftinset-inline-startscale number or lengthbreakpointsKeywords: auto; --before-left / --after-left
    --visibilityvisibilitykeyword—--before-visibility / --after-visibility
    --zz-indexany CSS valuestatesworks tier-only; --before-z / --after-z
    --isolationisolationkeyword—
    --containercontainerany CSS valuebreakpoints
    --container-namecontainer-nameany CSS value—
    --container-typecontainer-typeany CSS valuebreakpoints

    Examples

    --top: 4; --left: 4 --top: 4; --right: 4 --bottom: 4; --left: 4 --bottom: 4; --right: 4
    --position: absolute; --inset: 6
    <div
      style="
        --position: relative;
        --p: 6;
        --w: 100%;
        --h: 40;
        --max-w: 96;
        --bg: var(--color-muted);
        --radius: 4.5;
      "
    >
      <span
        data-ui="badge"
        data-badge-variant="primary"
        style="
          --position: absolute;
          --top: 4;
          --left: 4;
        "
        >--top: 4; --left: 4</span
      >
      <span
        data-ui="badge"
        data-badge-variant="muted"
        style="
          --position: absolute;
          --top: 4;
          --right: 4;
        "
        >--top: 4; --right: 4</span
      >
      <span
        data-ui="badge"
        data-badge-variant="muted"
        style="
          --position: absolute;
          --bottom: 4;
          --left: 4;
        "
        >--bottom: 4; --left: 4</span
      >
      <span
        data-ui="badge"
        data-badge-variant="primary"
        style="
          --position: absolute;
          --bottom: 4;
          --right: 4;
        "
        >--bottom: 4; --right: 4</span
      >
      <div
        data-ui="text-xs"
        style="
          --display: flex;
          --position: absolute;
          --items: center;
          --justify: center;
          --inset: 6;
          --font-weight: strong;
          --text: var(--color-muted-foreground);
          --border-color: var(--color-border);
          --border-width: 1px;
          --border-style: dashed;
          --radius: 2.5;
        "
      >
        --position: absolute; --inset: 6
      </div>
    </div>

    Scrollable region one

    Scrollable region two

    Scrollable region three

    Scrollable region four

    Scrollable region five

    Scrollable region six

    --overflow-y: auto

    Scrollable region one

    Scrollable region two

    Scrollable region three

    Scrollable region four

    Scrollable region five

    Scrollable region six

    --overflow: hidden
    <div
      style="
        --display: grid;
        --grid-cols: 2;
        --gap: 6;
        --w: 100%;
        --max-w: 96;
      "
    >
      <div
        style="
          --display: flex-col;
          --gap: 2;
        "
      >
        <div
          style="
            --display: flex-col;
            --p: 4;
            --gap: 2;
            --h: 24;
            --bg: var(--color-muted);
            --radius: 2.5;
            --overflow-x: clip;
            --overflow-y: auto;
          "
        >
          <p data-ui="text-sm">Scrollable region one</p>
          <p data-ui="text-sm">Scrollable region two</p>
          <p data-ui="text-sm">Scrollable region three</p>
          <p data-ui="text-sm">Scrollable region four</p>
          <p data-ui="text-sm">Scrollable region five</p>
          <p data-ui="text-sm">Scrollable region six</p>
        </div>
        <span
          data-ui="text-xs"
          style="
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-muted-foreground);
          "
          >--overflow-y: auto</span
        >
      </div>
      <div
        style="
          --display: flex-col;
          --gap: 2;
        "
      >
        <div
          style="
            --display: flex-col;
            --p: 4;
            --gap: 2;
            --h: 24;
            --bg: var(--color-muted);
            --radius: 2.5;
            --overflow: hidden;
          "
        >
          <p data-ui="text-sm">Scrollable region one</p>
          <p data-ui="text-sm">Scrollable region two</p>
          <p data-ui="text-sm">Scrollable region three</p>
          <p data-ui="text-sm">Scrollable region four</p>
          <p data-ui="text-sm">Scrollable region five</p>
          <p data-ui="text-sm">Scrollable region six</p>
        </div>
        <span
          data-ui="text-xs"
          style="
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-muted-foreground);
          "
          >--overflow: hidden</span
        >
      </div>
    </div>
    --aspect: 1 · 1:1
    --aspect: 16 / 9 · 16:9
    --aspect: 2 / 3 · 2:3
    <div
      style="
        --display: grid;
        --items: start;
        --grid-cols: 3;
        --gap: 6;
        --w: 100%;
        --max-w: 96;
      "
    >
      <div
        data-ui="text-xs"
        style="
          --display: flex;
          --items: center;
          --justify: center;
          --p: 2;
          --aspect: 1;
          --font-weight: strong;
          --text-align: center;
          --text: var(--color-primary-foreground);
          --bg: var(--color-primary);
          --radius: 2.5;
        "
      >
        --aspect: 1 · 1:1
      </div>
      <div
        data-ui="text-xs"
        style="
          --display: flex;
          --items: center;
          --justify: center;
          --p: 2;
          --aspect: 16 / 9;
          --font-weight: strong;
          --text-align: center;
          --text: var(--color-secondary-foreground);
          --bg: var(--color-secondary);
          --radius: 2.5;
        "
      >
        --aspect: 16 / 9 · 16:9
      </div>
      <div
        data-ui="text-xs"
        style="
          --display: flex;
          --items: center;
          --justify: center;
          --p: 2;
          --aspect: 2 / 3;
          --font-weight: strong;
          --text-align: center;
          --text: var(--color-tertiary-foreground);
          --bg: var(--color-tertiary);
          --radius: 2.5;
        "
      >
        --aspect: 2 / 3 · 2:3
      </div>
    </div>
    Savanna grass at dawn
    --object-fit: cover
    Savanna grass at dawn
    --object-fit: contain
    Savanna grass at dawn
    --object-fit: fill
    <div
      style="
        --display: grid;
        --grid-cols: 3;
        --gap: 6;
        --w: 100%;
        --max-w: 96;
      "
    >
      <figure
        style="
          --display: flex-col;
          --gap: 2;
        "
      >
        <img
          src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
          width="320"
          height="200"
          loading="lazy"
          alt="Savanna grass at dawn"
          style="
            --w: 100%;
            --aspect: 1;
            --bg: var(--color-muted);
            --radius: 2.5;
            --object-fit: cover;
          "
        />
        <figcaption
          data-ui="text-xs"
          style="
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-muted-foreground);
          "
        >
          --object-fit: cover
        </figcaption>
      </figure>
      <figure
        style="
          --display: flex-col;
          --gap: 2;
        "
      >
        <img
          src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
          width="320"
          height="200"
          loading="lazy"
          alt="Savanna grass at dawn"
          style="
            --w: 100%;
            --aspect: 1;
            --bg: var(--color-muted);
            --radius: 2.5;
            --object-fit: contain;
          "
        />
        <figcaption
          data-ui="text-xs"
          style="
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-muted-foreground);
          "
        >
          --object-fit: contain
        </figcaption>
      </figure>
      <figure
        style="
          --display: flex-col;
          --gap: 2;
        "
      >
        <img
          src="https://images.unsplash.com/photo-1500382017468-9049fed747ef?auto=format&fit=crop&w=320&h=200&q=60"
          width="320"
          height="200"
          loading="lazy"
          alt="Savanna grass at dawn"
          style="
            --w: 100%;
            --aspect: 1;
            --bg: var(--color-muted);
            --radius: 2.5;
            --object-fit: fill;
          "
        />
        <figcaption
          data-ui="text-xs"
          style="
            --font-weight: strong;
            --text-align: center;
            --text: var(--color-muted-foreground);
          "
        >
          --object-fit: fill
        </figcaption>
      </figure>
    </div>

    API