Anchored Auto Layout
npm

Hover or focus a box to measure it. Click its tag, or press ] and [, to pin one. Esc unpins.

    Legend
    • Anchor: a box with data-⚓️-name
    • Placed by anchors: out of flow
    • Gap from the anchor's edge, in px
    • Edges of the box you're inspecting

    Every tag, line and number here is itself placed by data-⚓️-* attributes. JS only measures.

    Coach-mark tour that walks around each target

    A product tour whose one coach mark hops between targets and sides (below, after, above, before) with data-⚓️-to + data-⚓️-side + data-⚓️-tween, and a data-⚓️-fill spotlight that follows along.

    Full page
    <header class="intro">
      <h1>Coach-mark tour</h1>
      <p>
        One card walks around the app, hopping between targets <em>and</em> sides. Each step only sets
        <code>data-⚓️-to</code>, <code>data-⚓️-side</code> and a cross-axis <code>data-⚓️-align-*</code>;
        <code>data-⚓️-tween</code> + <code>data-⚓️-transition="morph"</code> make every hop swing
        instead of snap. The spotlight is <code>data-⚓️-fill</code> on the same target. No position maths in JS.
      </p>
      <label class="xray-toggle"><input type="checkbox" id="xray"> X-ray</label>
    </header>
    
    <div class="app" data-⚓️-root>
      <header class="bar">
        <span class="logo" aria-hidden="true">◐</span>
        <span class="brand">Orbit</span>
        <label class="search" data-⚓️-name="--search"
          data-tour-title="Search everything" data-tour-body="Projects, people and files. Press / from anywhere."
          data-tour-side="below" data-tour-align="leading">
          <span aria-hidden="true">⌕</span>
          <input type="search" placeholder="Search…" aria-label="Search">
        </label>
        <button class="avatar" data-⚓️-name="--avatar" aria-label="Account"
          data-tour-title="Your account" data-tour-body="Theme, shortcuts and billing live up here."
          data-tour-side="below" data-tour-align="trailing">AA</button>
      </header>
    
      <nav class="nav" data-⚓️-name="--nav" aria-label="Sections"
        data-tour-title="Jump between spaces" data-tour-body="Your pinned spaces live here. Drag to reorder them."
        data-tour-side="after" data-tour-align="top"
        data-tour-side-sm="below" data-tour-align-sm="leading">
        <a href="#" aria-current="page"><span aria-hidden="true">▦</span> Overview</a>
        <a href="#"><span aria-hidden="true">◎</span> Goals</a>
        <a href="#"><span aria-hidden="true">✦</span> Launches</a>
        <a href="#"><span aria-hidden="true">☰</span> Notes</a>
      </nav>
    
      <main class="main">
        <div class="hello">
          <h2>Morning, Adam</h2>
          <p>Here's how the week is shaping up.</p>
          <div class="stats"><span><b>12</b> open goals</span><span><b>3</b> launches</span><span><b>98%</b> on track</span></div>
        </div>
        <section class="card chart" data-⚓️-name="--chart"
          data-tour-title="Weekly pulse" data-tour-body="Hover a bar for the day's numbers. It updates live."
          data-tour-side="above" data-tour-align="leading">
          <h2>Weekly pulse</h2>
          <div class="bars" aria-hidden="true">
            <i style="--h:40%"></i><i style="--h:65%"></i><i style="--h:52%"></i><i style="--h:80%"></i><i style="--h:72%"></i><i style="--h:35%"></i><i style="--h:58%"></i>
          </div>
        </section>
        <section class="card foot">
          <p>3 teammates viewed this today.</p>
          <button class="share" data-⚓️-name="--share"
            data-tour-title="Share it" data-tour-body="Invite anyone by link, no account needed."
            data-tour-side="before" data-tour-align="bottom"
            data-tour-side-sm="above" data-tour-align-sm="trailing">Share</button>
        </section>
      </main>
    
      <!-- The spotlight: fills whatever the tour points at -->
      <div class="spot" data-⚓️-to="--search" data-⚓️-fill data-⚓️-transition="morph" aria-hidden="true"></div>
    
      <!-- The coach mark: one element, every step is attribute changes -->
      <div class="coach" id="coach" role="dialog" aria-labelledby="coach-title" aria-describedby="coach-body"
        data-⚓️-to="--search" data-⚓️-side="below" data-⚓️-align-leading
        data-⚓️-tween data-⚓️-transition="morph">
        <div class="panel">
          <p class="count"><span id="coach-step">1</span> / <span id="coach-total">5</span></p>
          <h3 id="coach-title">Search everything</h3>
          <p id="coach-body">Projects, people and files.</p>
          <div class="actions">
            <button class="ghost" id="skip">Skip</button>
            <button class="ghost" id="back">Back</button>
            <button class="primary" id="next">Next</button>
          </div>
        </div>
      </div>
    </div>
    
    <button class="replay" id="replay" hidden>Replay tour</button>

    data-⚓️-align-leadingdata-⚓️-filldata-⚓️-namedata-⚓️-rootdata-⚓️-sidedata-⚓️-todata-⚓️-transitiondata-⚓️-tween

    Copied