網站導覽

v2.1.0
結構

看板

由多個欄組成的看板,可透過拖曳、按鍵或選擇位置,在欄內或跨欄移動項目。

本頁內容

看板由多個欄組成,每一欄都是一個具名的區段,內含一份清單;項目可以移到同一欄的其他位置,也可以移到另一欄。每個項目有兩個小型控制項:一個是把手,用指標或按鍵搬移項目;另一個是按鈕,用來開啟移動表單,不必拖曳就能選擇欄和位置。項目要顯示什麼由頁面決定:這裡是一張帶有徽章和頭像的卡片。kanban 行為負責移動;在確認移動之前,任何東西都不會移動。

看板

<div class="kanban h(376)" role="group" aria-label="Launch plan">  <section class="kanban-column" data-value="backlog" aria-labelledby="launch-backlog">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-backlog">Backlog</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="emails">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Audit the onboarding emails</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Audit the onboarding emails">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Audit the onboarding emails">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Lifecycle</span>            <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="pricing">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Price the annual plan</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Price the annual plan">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Price the annual plan">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Pricing</span>            <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="tour">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Record the product tour</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Record the product tour">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Record the product tour">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Video</span>            <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="translate">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Translate the pricing page</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Translate the pricing page">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Translate the pricing page">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Localization</span>            <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing waiting</p>  </section>  <section class="kanban-column" data-value="progress" aria-labelledby="launch-progress">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-progress">In progress</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="post">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Draft the launch post</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Draft the launch post">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Draft the launch post">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Writing</span>            <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="table">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Design the comparison table</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Design the comparison table">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Design the comparison table">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Design</span>            <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing in progress</p>  </section>  <section class="kanban-column" data-value="review" aria-labelledby="launch-review">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-review">In review</h3>    </header>    <ol class="kanban-items"></ol>    <p class="kanban-empty">Nothing in review</p>  </section>  <section class="kanban-column" data-value="done" aria-labelledby="launch-done">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-done">Done</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="name">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Name the release</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Name the release">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Name the release">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Brand</span>            <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="date">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Book the launch date</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Book the launch date">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />                </svg>              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Book the launch date">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                  <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />                </svg>              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Planning</span>            <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing done yet</p>  </section>  <div class="popover popover-end" popover id="launch-mover">    <form class="kanban-mover">      <label class="field">Column<select class="select" name="column"></select></label>      <label class="field">Position<select class="select" name="position"></select></label>      <div class="kanban-mover-actions">        <button type="button" class="btn btn-sm" popovertarget="launch-mover" popovertargetaction="hide">          Cancel        </button>        <button type="submit" class="btn btn-sm btn-primary">Move</button>      </div>    </form>  </div>  <div class="kanban-preview" popover="manual" aria-hidden="true"></div>  <p class="kanban-status" role="status"></p></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import ArrowLeftRightIcon from '@master/icons-react/native/16/soft/arrow-left-right'import GripVerticalIcon from '@master/icons-react/native/16/soft/grip-vertical'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="kanban h(376)" role="group" aria-label="Launch plan">      <section className="kanban-column" data-value="backlog" aria-labelledby="launch-backlog">        <header className="kanban-header">          <h3 className="kanban-title" id="launch-backlog">Backlog</h3>        </header>        <ol className="kanban-items">          <li className="kanban-item" data-value="emails">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Audit the onboarding emails</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Audit the onboarding emails">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Audit the onboarding emails">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Lifecycle</span>                <span className="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>              </div>            </article>          </li>          <li className="kanban-item" data-value="pricing">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Price the annual plan</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Price the annual plan">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Price the annual plan">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Pricing</span>                <span className="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>              </div>            </article>          </li>          <li className="kanban-item" data-value="tour">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Record the product tour</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Record the product tour">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Record the product tour">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Video</span>                <span className="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>              </div>            </article>          </li>          <li className="kanban-item" data-value="translate">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Translate the pricing page</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Translate the pricing page">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Translate the pricing page">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Localization</span>                <span className="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>              </div>            </article>          </li>        </ol>        <p className="kanban-empty">Nothing waiting</p>      </section>      <section className="kanban-column" data-value="progress" aria-labelledby="launch-progress">        <header className="kanban-header">          <h3 className="kanban-title" id="launch-progress">In progress</h3>        </header>        <ol className="kanban-items">          <li className="kanban-item" data-value="post">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Draft the launch post</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Draft the launch post">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Draft the launch post">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Writing</span>                <span className="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>              </div>            </article>          </li>          <li className="kanban-item" data-value="table">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Design the comparison table</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Design the comparison table">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Design the comparison table">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Design</span>                <span className="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>              </div>            </article>          </li>        </ol>        <p className="kanban-empty">Nothing in progress</p>      </section>      <section className="kanban-column" data-value="review" aria-labelledby="launch-review">        <header className="kanban-header">          <h3 className="kanban-title" id="launch-review">In review</h3>        </header>        <ol className="kanban-items"></ol>        <p className="kanban-empty">Nothing in review</p>      </section>      <section className="kanban-column" data-value="done" aria-labelledby="launch-done">        <header className="kanban-header">          <h3 className="kanban-title" id="launch-done">Done</h3>        </header>        <ol className="kanban-items">          <li className="kanban-item" data-value="name">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Name the release</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Name the release">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Name the release">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Brand</span>                <span className="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>              </div>            </article>          </li>          <li className="kanban-item" data-value="date">            <article className="card gap-xs">              <div className="card-header">                <p className="card-title">Book the launch date</p>                <span className="card-action kanban-controls">                  <button type="button" className="kanban-move" popoverTarget="launch-mover" aria-label="Move Book the launch date">                    <ArrowLeftRightIcon className="icon" />                  </button>                  <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Book the launch date">                    <GripVerticalIcon className="icon" />                  </button>                </span>              </div>              <div className="flex items-center justify-between gap-xs">                <span className="badge badge-sm">Planning</span>                <span className="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>              </div>            </article>          </li>        </ol>        <p className="kanban-empty">Nothing done yet</p>      </section>      <div className="popover popover-end" popover="" id="launch-mover">        <form className="kanban-mover">          <label className="field">Column<select className="select" name="column"></select></label>          <label className="field">Position<select className="select" name="position"></select></label>          <div className="kanban-mover-actions">            <button type="button" className="btn btn-sm" popoverTarget="launch-mover" popoverTargetAction="hide">              Cancel            </button>            <button type="submit" className="btn btn-sm btn-primary">Move</button>          </div>        </form>      </div>      <div className="kanban-preview" popover="manual" aria-hidden="true"></div>      <p className="kanban-status" role="status"></p>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import ArrowLeftRightIcon from '@master/icons-svelte/native/16/soft/arrow-left-right'  import GripVerticalIcon from '@master/icons-svelte/native/16/soft/grip-vertical'</script><div class="kanban h(376)" role="group" aria-label="Launch plan" {@attach attach}>  <section class="kanban-column" data-value="backlog" aria-labelledby="launch-backlog">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-backlog">Backlog</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="emails">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Audit the onboarding emails</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Audit the onboarding emails">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Audit the onboarding emails">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Lifecycle</span>            <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="pricing">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Price the annual plan</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Price the annual plan">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Price the annual plan">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Pricing</span>            <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="tour">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Record the product tour</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Record the product tour">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Record the product tour">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Video</span>            <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="translate">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Translate the pricing page</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Translate the pricing page">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Translate the pricing page">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Localization</span>            <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing waiting</p>  </section>  <section class="kanban-column" data-value="progress" aria-labelledby="launch-progress">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-progress">In progress</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="post">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Draft the launch post</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Draft the launch post">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Draft the launch post">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Writing</span>            <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="table">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Design the comparison table</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Design the comparison table">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Design the comparison table">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Design</span>            <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing in progress</p>  </section>  <section class="kanban-column" data-value="review" aria-labelledby="launch-review">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-review">In review</h3>    </header>    <ol class="kanban-items"></ol>    <p class="kanban-empty">Nothing in review</p>  </section>  <section class="kanban-column" data-value="done" aria-labelledby="launch-done">    <header class="kanban-header">      <h3 class="kanban-title" id="launch-done">Done</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="name">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Name the release</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Name the release">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Name the release">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Brand</span>            <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>          </div>        </article>      </li>      <li class="kanban-item" data-value="date">        <article class="card gap-xs">          <div class="card-header">            <p class="card-title">Book the launch date</p>            <span class="card-action kanban-controls">              <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Book the launch date">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Book the launch date">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>          <div class="flex items-center justify-between gap-xs">            <span class="badge badge-sm">Planning</span>            <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>          </div>        </article>      </li>    </ol>    <p class="kanban-empty">Nothing done yet</p>  </section>  <div class="popover popover-end" popover id="launch-mover">    <form class="kanban-mover">      <label class="field">Column<select class="select" name="column"></select></label>      <label class="field">Position<select class="select" name="position"></select></label>      <div class="kanban-mover-actions">        <button type="button" class="btn btn-sm" popovertarget="launch-mover" popovertargetaction="hide">          Cancel        </button>        <button type="submit" class="btn btn-sm btn-primary">Move</button>      </div>    </form>  </div>  <div class="kanban-preview" popover="manual" aria-hidden="true"></div>  <p class="kanban-status" role="status"></p></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import ArrowLeftRightIcon from '@master/icons-vue/native/16/soft/arrow-left-right'import GripVerticalIcon from '@master/icons-vue/native/16/soft/grip-vertical'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="kanban h(376)" role="group" aria-label="Launch plan">    <section class="kanban-column" data-value="backlog" aria-labelledby="launch-backlog">      <header class="kanban-header">        <h3 class="kanban-title" id="launch-backlog">Backlog</h3>      </header>      <ol class="kanban-items">        <li class="kanban-item" data-value="emails">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Audit the onboarding emails</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Audit the onboarding emails">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Audit the onboarding emails">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Lifecycle</span>              <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>            </div>          </article>        </li>        <li class="kanban-item" data-value="pricing">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Price the annual plan</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Price the annual plan">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Price the annual plan">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Pricing</span>              <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>            </div>          </article>        </li>        <li class="kanban-item" data-value="tour">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Record the product tour</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Record the product tour">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Record the product tour">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Video</span>              <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>            </div>          </article>        </li>        <li class="kanban-item" data-value="translate">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Translate the pricing page</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Translate the pricing page">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Translate the pricing page">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Localization</span>              <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>            </div>          </article>        </li>      </ol>      <p class="kanban-empty">Nothing waiting</p>    </section>    <section class="kanban-column" data-value="progress" aria-labelledby="launch-progress">      <header class="kanban-header">        <h3 class="kanban-title" id="launch-progress">In progress</h3>      </header>      <ol class="kanban-items">        <li class="kanban-item" data-value="post">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Draft the launch post</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Draft the launch post">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Draft the launch post">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Writing</span>              <span class="avatar avatar-xs" role="img" aria-label="Mei Kato">MK</span>            </div>          </article>        </li>        <li class="kanban-item" data-value="table">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Design the comparison table</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Design the comparison table">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Design the comparison table">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Design</span>              <span class="avatar avatar-xs" role="img" aria-label="Yi-ching Lin">YL</span>            </div>          </article>        </li>      </ol>      <p class="kanban-empty">Nothing in progress</p>    </section>    <section class="kanban-column" data-value="review" aria-labelledby="launch-review">      <header class="kanban-header">        <h3 class="kanban-title" id="launch-review">In review</h3>      </header>      <ol class="kanban-items"></ol>      <p class="kanban-empty">Nothing in review</p>    </section>    <section class="kanban-column" data-value="done" aria-labelledby="launch-done">      <header class="kanban-header">        <h3 class="kanban-title" id="launch-done">Done</h3>      </header>      <ol class="kanban-items">        <li class="kanban-item" data-value="name">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Name the release</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Name the release">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Name the release">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Brand</span>              <span class="avatar avatar-xs" role="img" aria-label="Po-han Chen">PC</span>            </div>          </article>        </li>        <li class="kanban-item" data-value="date">          <article class="card gap-xs">            <div class="card-header">              <p class="card-title">Book the launch date</p>              <span class="card-action kanban-controls">                <button type="button" class="kanban-move" popovertarget="launch-mover" aria-label="Move Book the launch date">                  <ArrowLeftRightIcon class="icon" />                </button>                <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Book the launch date">                  <GripVerticalIcon class="icon" />                </button>              </span>            </div>            <div class="flex items-center justify-between gap-xs">              <span class="badge badge-sm">Planning</span>              <span class="avatar avatar-xs" role="img" aria-label="Ana Souza">AS</span>            </div>          </article>        </li>      </ol>      <p class="kanban-empty">Nothing done yet</p>    </section>    <div class="popover popover-end" popover id="launch-mover">      <form class="kanban-mover">        <label class="field">Column<select class="select" name="column"></select></label>        <label class="field">Position<select class="select" name="position"></select></label>        <div class="kanban-mover-actions">          <button type="button" class="btn btn-sm" popovertarget="launch-mover" popovertargetaction="hide">            Cancel          </button>          <button type="submit" class="btn btn-sm btn-primary">Move</button>        </div>      </form>    </div>    <div class="kanban-preview" popover="manual" aria-hidden="true"></div>    <p class="kanban-status" role="status"></p>  </div></template>
將握把拖曳到另一欄:會有一條線標示卡片的落點,指標靠近看板任一端時,看板會自動捲動。使用按鍵時,讓握把取得焦點後按 Space,用方向鍵選擇位置,再按一次 Space。握把旁的按鈕不必拖曳就能移動卡片。

可排序清單負責排列單一清單的順序。如果項目還會換到另一份清單,而且所在的清單本身就說明了項目的某件事,例如階段、負責人或狀態,請使用看板。

#樣式表繪製的內容

  • 看板是一列可橫向捲動的欄。為它設定高度(如上方的 h(376),或像看板頁面的主區域那樣),各欄就會止於這個高度。
  • 欄是一個托盤:以色調和細線呈現凹陷,寬度為 --kanban-column-width,且不會超過看板寬度減去 2rem,因此在手機上,下一欄會從邊緣露出。欄的高度隨內容而定。欄內的清單 kanban-items 是唯一會捲動的部分,上方的標頭則留在原位。
  • 同一個圓角,同一條線。 看板中的卡片採用 --kanban-radius 和 --kanban-padding。欄的圓角是這個圓角半徑加上 --kanban-inset,也就是項目周圍的空間;欄的標題則與卡片的文字從同一條線開始。
  • 兩個控制項成對出現,各為 24px,以手指觸控時目標高 44px,且各自只延伸到兩者中間,不會替對方回應:把手內放握把圖示,kanban-move 內放兩個交錯箭頭的圖示,兩者都是寫在標記裡的 Master Icons 圖稿。在指標或按鍵移到它們之前,兩者都只顯示圖示。只有把手設有 touch-action: none,因此從卡片其他位置開始的滑動仍會捲動。kanban-controls 把這對控制項放在項目第一行的結尾:它會伸入卡片的內距,距離為 .5rem,也就是握把的點在其方框內的內縮量,讓握把貼齊下方頭像結束的邊緣,並對齊標題第一行的中線。
  • 移動按鈕會等待。 在指標可以懸停的裝置上,kanban-move 要等指標或按鍵到達所屬項目才會繪製,因此看板上每張卡片只顯示一個握把;在觸控螢幕上它一律顯示。
  • 搬移中的項目會留在原位並淡化,讓讀者看得出它從哪裡來,它的握把則落在凹槽中。
  • 落點是間距正中央的一條線,繪製在標有 kanban-item-target 的項目之前,或標有 kanban-items-target 的清單最後一個項目之後。沒有項目會讓出空間:看板在指標下方保持不動,落點才不會自己追著自己跑。
  • 空的欄會顯示 kanban-empty 取代清單,也就是淺凹槽中的幾個字。當它成為項目的落點時,凹槽會以標記的顏色繪製一圈外環。
  • 搬移面板 kanban-preview 是一張略為凸起的小面板,寬度與項目相同,上面寫著項目的名稱。它是手動彈出面板,因此位於頂層,不會被任何一欄的捲動範圍裁切;它也不含卡片的複本,所以不會出現第二個 id、欄位或圖片。放開時,它會滑到項目的新位置,然後消失。

啟用減少動態效果時,搬移面板不會滑動,項目也不會淡入。在強制色彩模式下,欄、凹槽和搬移面板都會加上外框,落點線則以系統的醒目提示色繪製。

#行為

kanban 接收根元素,也就是帶有 kanban 類別的元素,並傳回用來解除行為的函式。

app.js
import { kanban } from '@master/ui/behaviors/kanban.js'const board = kanban(document.querySelector('.kanban'))board.value// [{ value: 'backlog', items: ['emails', 'pricing', 'tour', 'translate'] }, { value: 'progress', items: ['post', 'table'] }, …]board.move('pricing', 'review', 0)// The board dispatches input, then change, once for each move that changed it.document.querySelector('.kanban').addEventListener('change', (event) => {  if (event.target === event.currentTarget) save(board.value)})
  • 指標。 在把手上按下並移動超過 4px 時,就會拿起項目;滑鼠、觸控筆和觸控都一樣,而且只有開始拖曳的那個指標能移動項目。指標下方的欄(或橫向最接近的欄)就是項目會落入的欄,落點在中點低於指標的第一個項目之前。指標靠近邊緣時,看板會橫向捲動,該欄的清單則會縱向捲動。放開指標即確認移動。在拿起項目的位置放開不會有任何變更;在看板外放開、按 Escape、指標被取消,以及指標擷取被取走,都會讓項目留在原位。
  • 整個項目(滑鼠)。 使用滑鼠時,按住項目上連結、按鈕或欄位以外的任何位置也能拿起項目,游標在這些位置會顯示為手形。手指只能從把手搬移:在項目其他位置按下是捲動清單的方式。在項目上按下但沒有移動,仍然只是對該處內容的一次點按。
  • 按鍵。 在把手上按 Enter 或 Space 會拿起項目,在把手上按下而不移動也有相同的效果。接著用方向鍵選擇位置,並由落點線標示;在拿起項目之前,方向鍵不會有任何作用,因此螢幕閱讀器自己的方向鍵操作仍可正常使用。按 Enter 或 Space 會確認移動,按 Escape 會取消,焦點離開把手時也會確認。
  • 移動表單。 項目中的按鈕,只要 popovertarget 指向內含 kanban-mover 表單的彈出面板,就會為該項目開啟移動表單。彈出面板由瀏覽器開啟和關閉;行為會把各欄寫入名為 column 的下拉選單,把所選欄中的各個位置寫入名為 position 的下拉選單,提交表單即確認移動。無法拖曳又沒有鍵盤的讀者,以及在觸控螢幕上使用螢幕閱讀器的讀者,都靠這個方式移動項目。
  • 單一路徑。 指標、按鍵和移動表單都透過 move(item, column, index) 確認移動,你也可以直接呼叫它。index 是項目在該欄其他項目之間的位置:0 是第一個,超出結尾的數字則代表結尾。若確認的移動改變了看板,行為會移動項目節點本身(瀏覽器支援時使用 moveBefore(),因此欄位中的文字和焦點會保留下來),將項目捲入可見範圍,讓它的把手取得焦點,並派送事件。若確認的位置就是項目目前所在的位置,則不會派送任何事件。
  • 移動過程會繪製出來。 瀏覽器支援以元素為範圍的 view transition 時,確認移動會在看板上啟動一次:每個項目都滑到它的新位置,並由所屬清單裁切;確認會晚一個影格完成,因此 move 這時回傳 promise。其他瀏覽器以及啟用減少動態效果時,項目會直接就位。滑動歷時 160ms,期間看板不接受按壓。
  • 頁面自行移動時。 由頁面呼叫的 move 不會把項目捲入可見範圍,也不會移動焦點;它不會把項目移入隱藏的欄,而且在前一次移動尚未繪製完成時會被拒絕。把手為 disabled 的項目不論用哪種方式都留在原位,移動表單也不例外。
  • 值就是排列方式:每一欄一個 { value, items },依欄的順序排列。它代表已確認的結果,絕不是正在選擇的位置。設定它即可排列看板,且不會派送任何事件。如果值指名了看板沒有的欄或項目,或同一個欄或項目出現兩次,就會遭到拒絕,看板維持原狀,因此卡片絕不會在途中遺失。值未列出的項目會留在原本的欄,排在值所列的項目之後。
  • 移動進行中。 在搬移項目期間設定值、呼叫 move,或以其他方式重新排列看板,都會先取消那次移動。
  • 朗讀內容。 每次拿起、選擇位置、放下和取消,都會在 kanban-status 區域中說出項目名稱、欄和位置,例如「Price the annual plan: In review, position 1 of 1.」傳入 messages 即可改用頁面的語言。項目以其 aria-label 稱呼,沒有時則用它所含的前幾個字;欄則以其標題稱呼。

欄的順序就是標記中的順序。帶有 hidden 的欄不接受任何項目,按鍵操作也會略過它。

卡片內的欄位和移動表單自己的下拉選單,也會讓 input 和 change 經過看板,就像經過表單一樣。屬於移動的事件,是 target 為看板的那些。

#這個行為測量的內容

行為只變更屬性,幾何則交給樣式表。但在可捲動的欄之間拖曳,無法用這種方式判斷位置,因此唯獨這個行為會進行測量,測量的範圍則明訂在它的契約中:它讀取指標在各欄與各項目之間的位置,在指標靠近邊緣時捲動看板和清單,並在搬移面板上寫入三個自訂屬性:--kanban-x、--kanban-y 和 --kanban-width。它不設定顏色、陰影或其他樣式,落點的標記則是由樣式表繪製的類別。

#鍵盤操作

按鍵動作
Enter, Space在把手上時,拿起項目;再按一次則將項目放到所選的位置
ArrowUp, ArrowDown在項目會落入的欄中,選擇前一個或後一個位置
ArrowLeft, ArrowRight依畫面上所見選擇相鄰的欄,由右至左排列時方向相反。位置維持不變;該欄的位置較少時,則為最後一個位置
Home, End選擇該欄的第一個或最後一個位置
Escape讓項目留在原位,焦點留在它的把手上;拖曳期間則結束拖曳
Tab將項目放到所選的位置,再依 Tab 的一般行為離開把手

#較小的看板

欄和卡片會依看板的自訂屬性調整。這裡用 --kanban-column-width 縮窄各欄,每個項目都是只有一行的扁平卡片,最後一欄則是空的。

較小的看板

<div class="kanban" role="group" aria-label="Candidates" style="--kanban-column-width: 13rem">  <section class="kanban-column" data-value="applied" aria-labelledby="hiring-applied">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-applied">Applied</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="rivera">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Dana Rivera</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Dana Rivera">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />              </svg>            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Dana Rivera">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />              </svg>            </button>          </span>        </div>      </li>      <li class="kanban-item" data-value="okafor">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Chidi Okafor</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Chidi Okafor">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />              </svg>            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Chidi Okafor">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />              </svg>            </button>          </span>        </div>      </li>      <li class="kanban-item" data-value="sato">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Hana Sato</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Hana Sato">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />              </svg>            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Hana Sato">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />              </svg>            </button>          </span>        </div>      </li>    </ol>    <p class="kanban-empty">No applicants</p>  </section>  <section class="kanban-column" data-value="interview" aria-labelledby="hiring-interview">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-interview">Interview</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="meyer">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Lena Meyer</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Lena Meyer">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <path d="M4.2559 2.3817A0.4996 0.4996 0 0 0 4.1667 2.6667L4.1673 13.3578A0.5 0.5 0 0 0 5.1613 13.4067L5.1667 13.3333L5.1653 2.6288A0.5007 0.5007 0 0 0 5.0775 2.3817A0.7044 0.7044 0 0 0 4.2559 2.3817Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M2.3333 5L4.5253 2.8081A0.2 0.2 0 0 1 4.8081 2.8081L7 5" transform="rotate(90 8 8)" /><path d="M11.8333 13.3333L11.8327 2.6422A0.5 0.5 0 0 0 10.8387 2.5933L10.8333 2.6667L10.8347 13.3712A0.5007 0.5007 0 0 0 10.9225 13.6183A0.7044 0.7044 0 0 0 11.7441 13.6183A0.4996 0.4996 0 0 0 11.8333 13.3333Z" fill="currentColor" stroke="none" fill-rule="evenodd" transform="rotate(90 8 8)" /><path d="M9 11L11.1919 13.1919A0.2 0.2 0 0 0 11.4747 13.1919L13.6667 11" transform="rotate(90 8 8)" />              </svg>            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Lena Meyer">              <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">                <circle cx="6" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="4" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="8" r="1" fill="currentColor" stroke="none" /><circle cx="6" cy="12" r="1" fill="currentColor" stroke="none" /><circle cx="10" cy="12" r="1" fill="currentColor" stroke="none" />              </svg>            </button>          </span>        </div>      </li>    </ol>    <p class="kanban-empty">No interviews</p>  </section>  <section class="kanban-column" data-value="offer" aria-labelledby="hiring-offer">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-offer">Offer</h3>    </header>    <ol class="kanban-items"></ol>    <p class="kanban-empty">No offers yet</p>  </section>  <div class="popover popover-end" popover id="hiring-mover">    <form class="kanban-mover">      <label class="field">Column<select class="select" name="column"></select></label>      <label class="field">Position<select class="select" name="position"></select></label>      <div class="kanban-mover-actions">        <button type="button" class="btn btn-sm" popovertarget="hiring-mover" popovertargetaction="hide">          Cancel        </button>        <button type="submit" class="btn btn-sm btn-primary">Move</button>      </div>    </form>  </div>  <div class="kanban-preview" popover="manual" aria-hidden="true"></div>  <p class="kanban-status" role="status"></p></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import ArrowLeftRightIcon from '@master/icons-react/native/16/soft/arrow-left-right'import GripVerticalIcon from '@master/icons-react/native/16/soft/grip-vertical'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="kanban" role="group" aria-label="Candidates" style={{ '--kanban-column-width': '13rem' } as React.CSSProperties}>      <section className="kanban-column" data-value="applied" aria-labelledby="hiring-applied">        <header className="kanban-header">          <h3 className="kanban-title" id="hiring-applied">Applied</h3>        </header>        <ol className="kanban-items">          <li className="kanban-item" data-value="rivera">            <div className="card card-flat flex-row items-center gap-2xs">              <span className="grow(1) min-w(0) fg-text-strong">Dana Rivera</span>              <span className="kanban-controls">                <button type="button" className="kanban-move" popoverTarget="hiring-mover" aria-label="Move Dana Rivera">                  <ArrowLeftRightIcon className="icon" />                </button>                <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Dana Rivera">                  <GripVerticalIcon className="icon" />                </button>              </span>            </div>          </li>          <li className="kanban-item" data-value="okafor">            <div className="card card-flat flex-row items-center gap-2xs">              <span className="grow(1) min-w(0) fg-text-strong">Chidi Okafor</span>              <span className="kanban-controls">                <button type="button" className="kanban-move" popoverTarget="hiring-mover" aria-label="Move Chidi Okafor">                  <ArrowLeftRightIcon className="icon" />                </button>                <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Chidi Okafor">                  <GripVerticalIcon className="icon" />                </button>              </span>            </div>          </li>          <li className="kanban-item" data-value="sato">            <div className="card card-flat flex-row items-center gap-2xs">              <span className="grow(1) min-w(0) fg-text-strong">Hana Sato</span>              <span className="kanban-controls">                <button type="button" className="kanban-move" popoverTarget="hiring-mover" aria-label="Move Hana Sato">                  <ArrowLeftRightIcon className="icon" />                </button>                <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Hana Sato">                  <GripVerticalIcon className="icon" />                </button>              </span>            </div>          </li>        </ol>        <p className="kanban-empty">No applicants</p>      </section>      <section className="kanban-column" data-value="interview" aria-labelledby="hiring-interview">        <header className="kanban-header">          <h3 className="kanban-title" id="hiring-interview">Interview</h3>        </header>        <ol className="kanban-items">          <li className="kanban-item" data-value="meyer">            <div className="card card-flat flex-row items-center gap-2xs">              <span className="grow(1) min-w(0) fg-text-strong">Lena Meyer</span>              <span className="kanban-controls">                <button type="button" className="kanban-move" popoverTarget="hiring-mover" aria-label="Move Lena Meyer">                  <ArrowLeftRightIcon className="icon" />                </button>                <button type="button" className="kanban-handle" aria-pressed="false" aria-label="Drag Lena Meyer">                  <GripVerticalIcon className="icon" />                </button>              </span>            </div>          </li>        </ol>        <p className="kanban-empty">No interviews</p>      </section>      <section className="kanban-column" data-value="offer" aria-labelledby="hiring-offer">        <header className="kanban-header">          <h3 className="kanban-title" id="hiring-offer">Offer</h3>        </header>        <ol className="kanban-items"></ol>        <p className="kanban-empty">No offers yet</p>      </section>      <div className="popover popover-end" popover="" id="hiring-mover">        <form className="kanban-mover">          <label className="field">Column<select className="select" name="column"></select></label>          <label className="field">Position<select className="select" name="position"></select></label>          <div className="kanban-mover-actions">            <button type="button" className="btn btn-sm" popoverTarget="hiring-mover" popoverTargetAction="hide">              Cancel            </button>            <button type="submit" className="btn btn-sm btn-primary">Move</button>          </div>        </form>      </div>      <div className="kanban-preview" popover="manual" aria-hidden="true"></div>      <p className="kanban-status" role="status"></p>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import ArrowLeftRightIcon from '@master/icons-svelte/native/16/soft/arrow-left-right'  import GripVerticalIcon from '@master/icons-svelte/native/16/soft/grip-vertical'</script><div class="kanban" role="group" aria-label="Candidates" style="--kanban-column-width: 13rem" {@attach attach}>  <section class="kanban-column" data-value="applied" aria-labelledby="hiring-applied">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-applied">Applied</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="rivera">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Dana Rivera</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Dana Rivera">              <ArrowLeftRightIcon class="icon" />            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Dana Rivera">              <GripVerticalIcon class="icon" />            </button>          </span>        </div>      </li>      <li class="kanban-item" data-value="okafor">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Chidi Okafor</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Chidi Okafor">              <ArrowLeftRightIcon class="icon" />            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Chidi Okafor">              <GripVerticalIcon class="icon" />            </button>          </span>        </div>      </li>      <li class="kanban-item" data-value="sato">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Hana Sato</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Hana Sato">              <ArrowLeftRightIcon class="icon" />            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Hana Sato">              <GripVerticalIcon class="icon" />            </button>          </span>        </div>      </li>    </ol>    <p class="kanban-empty">No applicants</p>  </section>  <section class="kanban-column" data-value="interview" aria-labelledby="hiring-interview">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-interview">Interview</h3>    </header>    <ol class="kanban-items">      <li class="kanban-item" data-value="meyer">        <div class="card card-flat flex-row items-center gap-2xs">          <span class="grow(1) min-w(0) fg-text-strong">Lena Meyer</span>          <span class="kanban-controls">            <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Lena Meyer">              <ArrowLeftRightIcon class="icon" />            </button>            <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Lena Meyer">              <GripVerticalIcon class="icon" />            </button>          </span>        </div>      </li>    </ol>    <p class="kanban-empty">No interviews</p>  </section>  <section class="kanban-column" data-value="offer" aria-labelledby="hiring-offer">    <header class="kanban-header">      <h3 class="kanban-title" id="hiring-offer">Offer</h3>    </header>    <ol class="kanban-items"></ol>    <p class="kanban-empty">No offers yet</p>  </section>  <div class="popover popover-end" popover id="hiring-mover">    <form class="kanban-mover">      <label class="field">Column<select class="select" name="column"></select></label>      <label class="field">Position<select class="select" name="position"></select></label>      <div class="kanban-mover-actions">        <button type="button" class="btn btn-sm" popovertarget="hiring-mover" popovertargetaction="hide">          Cancel        </button>        <button type="submit" class="btn btn-sm btn-primary">Move</button>      </div>    </form>  </div>  <div class="kanban-preview" popover="manual" aria-hidden="true"></div>  <p class="kanban-status" role="status"></p></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import ArrowLeftRightIcon from '@master/icons-vue/native/16/soft/arrow-left-right'import GripVerticalIcon from '@master/icons-vue/native/16/soft/grip-vertical'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="kanban" role="group" aria-label="Candidates" style="--kanban-column-width: 13rem">    <section class="kanban-column" data-value="applied" aria-labelledby="hiring-applied">      <header class="kanban-header">        <h3 class="kanban-title" id="hiring-applied">Applied</h3>      </header>      <ol class="kanban-items">        <li class="kanban-item" data-value="rivera">          <div class="card card-flat flex-row items-center gap-2xs">            <span class="grow(1) min-w(0) fg-text-strong">Dana Rivera</span>            <span class="kanban-controls">              <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Dana Rivera">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Dana Rivera">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>        </li>        <li class="kanban-item" data-value="okafor">          <div class="card card-flat flex-row items-center gap-2xs">            <span class="grow(1) min-w(0) fg-text-strong">Chidi Okafor</span>            <span class="kanban-controls">              <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Chidi Okafor">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Chidi Okafor">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>        </li>        <li class="kanban-item" data-value="sato">          <div class="card card-flat flex-row items-center gap-2xs">            <span class="grow(1) min-w(0) fg-text-strong">Hana Sato</span>            <span class="kanban-controls">              <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Hana Sato">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Hana Sato">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>        </li>      </ol>      <p class="kanban-empty">No applicants</p>    </section>    <section class="kanban-column" data-value="interview" aria-labelledby="hiring-interview">      <header class="kanban-header">        <h3 class="kanban-title" id="hiring-interview">Interview</h3>      </header>      <ol class="kanban-items">        <li class="kanban-item" data-value="meyer">          <div class="card card-flat flex-row items-center gap-2xs">            <span class="grow(1) min-w(0) fg-text-strong">Lena Meyer</span>            <span class="kanban-controls">              <button type="button" class="kanban-move" popovertarget="hiring-mover" aria-label="Move Lena Meyer">                <ArrowLeftRightIcon class="icon" />              </button>              <button type="button" class="kanban-handle" aria-pressed="false" aria-label="Drag Lena Meyer">                <GripVerticalIcon class="icon" />              </button>            </span>          </div>        </li>      </ol>      <p class="kanban-empty">No interviews</p>    </section>    <section class="kanban-column" data-value="offer" aria-labelledby="hiring-offer">      <header class="kanban-header">        <h3 class="kanban-title" id="hiring-offer">Offer</h3>      </header>      <ol class="kanban-items"></ol>      <p class="kanban-empty">No offers yet</p>    </section>    <div class="popover popover-end" popover id="hiring-mover">      <form class="kanban-mover">        <label class="field">Column<select class="select" name="column"></select></label>        <label class="field">Position<select class="select" name="position"></select></label>        <div class="kanban-mover-actions">          <button type="button" class="btn btn-sm" popovertarget="hiring-mover" popovertargetaction="hide">            Cancel          </button>          <button type="submit" class="btn btn-sm btn-primary">Move</button>        </div>      </form>    </div>    <div class="kanban-preview" popover="manual" aria-hidden="true"></div>    <p class="kanban-status" role="status"></p>  </div></template>

#沒有腳本時

看板由區段、標題和清單組成,因此沒有行為時,內容仍可依序逐欄閱讀,也能捲動。但無法移動任何項目:移動需要行為,或由頁面自行寫入順序。沒有作用的把手和移動按鈕比沒有更糟,因此可能在沒有腳本的情況下執行的頁面,應該等腳本就緒後再渲染它們。

瀏覽器不支援 popover API 時,拖曳期間不會有任何東西跟隨指標;淡化的項目和落點線仍會說明正在搬移什麼、會落在哪裡。

#無障礙

  • 每一欄都是以其標題命名的 <section>,因此是螢幕閱讀器可以直接跳到的區域;欄內的項目是原生清單,會說出項目的數量。看板則是帶有名稱的 role="group"。
  • 拖曳絕不是唯一的方式。指標能做到的,按鍵都能做到;移動表單則用兩個下拉選單和一個按鈕完成同樣的事,這正是 WCAG 2.5.7 的要求:只提供鍵盤替代方式,無法顧及使用觸控且無法拖曳的讀者。
  • 以所移動的內容為兩個控制項命名,例如「Drag Price the annual plan」和「Move Price the annual plan」。
  • 從一開始就在頁面中放好空白的狀態區域:在要朗讀時才加入的區域,常常不會被讀出。
  • 移動之後,焦點會落在被移動項目的把手上,項目也會在可見範圍內。用 Tab 離開把手會確認移動,且不會把焦點拉回來。
  • 以頁面儲存其他資料的方式,在 change 時儲存排列;若移動會產生讀者看不到的影響,請在看板附近說明。

#React、Svelte 和 Vue

kanban 元件會依 columns、items 和它保存的排列寫入各欄及其項目,把兩個按鈕的屬性交給項目的標記展開,並掛上行為。確認移動時,行為會把要繪製的排列交給元件,等這次渲染完成後才交還焦點並派送事件;如果擁有者不接受這個排列,看板就會維持原狀。用 npx master-ui add kanban 將元件複製到專案中。元件的建置與使用方式請參閱 React、Svelte 和 Vue。

換欄的項目會在新的清單中重新渲染,框架對任何更換父層的項目都是如此。請把卡片顯示的內容保存在你的資料中,不要放在卡片內部的狀態裡。

ui/kanban.tsx
'use client'import { useId, useLayoutEffect, useRef, useState, type ComponentProps, type ReactNode } from 'react'import { kanban, type KanbanMessages, type KanbanValue } from '@master/ui/behaviors/kanban.js'import { useBehavior } from './use-behavior'export type { KanbanValue }export interface KanbanColumn {  /** What the column stands for in the arrangement. */  value: string  /** The column's name: its title, and what the status and the mover call it. */  label: string}export interface KanbanItem {  /** What the item stands for in the arrangement. No other item has it. */  value: string  /** What the item is called: its handle and its move button are named with it. */  label: string  /** The column the item starts in, and stays in while the arrangement does not name it. The first by default. */  column?: string}export interface KanbanLabels<T extends KanbanItem> {  /** The accessible name of an item's handle. `Drag <label>` by default. */  drag?: (item: T) => string  /** The accessible name of the button that opens the mover for an item. `Move <label>` by default. */  move?: (item: T) => string  /** The mover's two fields and two buttons. */  column?: string  position?: string  confirm?: string  cancel?: string}/** What an item's own markup spreads on its two buttons. */export interface KanbanControls {  /** For the grip, an empty `<button>`: it carries the item with the pointer and the keys. */  handle: ComponentProps<'button'>  /** For the button that opens the mover, an empty `<button>`: a column and a position are chosen there. */  move: ComponentProps<'button'>}export interface KanbanProps<C extends KanbanColumn, T extends KanbanItem> extends Omit<ComponentProps<'div'>, 'children' | 'defaultValue' | 'ref'> {  /** The columns, in their order. The order is not the reader's to change. */  columns: C[]  items: T[]  /** The arrangement: each column's value and the values of its items, in order. */  value?: KanbanValue  defaultValue?: KanbanValue  onValueChange?: (value: KanbanValue) => void  /** What an item shows, with the attributes of its handle and of its move button to spread. Each button holds its icon. */  children: (item: T, controls: KanbanControls) => ReactNode  /** What stands beside a column's title, such as the number of items it holds. */  header?: (column: C, items: T[]) => ReactNode  /** What a column says while it holds no item. */  empty?: (column: C) => ReactNode  /** The names of the controls, in the page's language. */  labels?: KanbanLabels<T>  /** What the status region says, in the page's language. */  messages?: KanbanMessages}/** * A board whose items the reader moves between columns. React writes the columns and their items in the * arrangement it holds; the behavior carries an item with the pointer and the keys, and asks React to arrange * the board when one is dropped. An item that changes column is rendered again in its new list, so what it * shows comes from the data, not from state kept inside it. */export function Kanban<C extends KanbanColumn, T extends KanbanItem>({ columns, items, value, defaultValue, onValueChange, children, header, empty, labels = {}, messages, className, ...root }: KanbanProps<C, T>) {  const id = useId()  const [kept, setKept] = useState(() => value ?? defaultValue)  const shown = arranged(columns, items, value ?? kept)  // A move waits for the render that writes the item in its place, so focus finds its handle there. Every  // arrangement asked for is kept, which renders even when the owner does not take it: the wait always ends.  const waiting = useRef<(() => void)[]>([])  useLayoutEffect(() => {    waiting.current.splice(0).forEach(done => done())  })  const arrange = (next: KanbanValue) => new Promise<void>((done) => {    waiting.current.push(done)    setKept(next)    onValueChange?.(next)  })  const ref = useBehavior(kanban, { messages, arrange })  const { drag = (item: T) => `Drag ${item.label}`, move = (item: T) => `Move ${item.label}`, column: columnLabel = 'Column', position = 'Position', confirm = 'Move', cancel = 'Cancel' } = labels  return (    <div className={className ? `kanban ${className}` : 'kanban'} role="group" ref={ref} {...root}>      {columns.map((column, at) => (        <section className="kanban-column" data-value={column.value} aria-labelledby={`${id}-column-${at}`} key={column.value}>          <header className="kanban-header">            <h3 className="kanban-title" id={`${id}-column-${at}`}>{column.label}</h3>            {header?.(column, shown[at]!)}          </header>          <ol className="kanban-items">            {shown[at]!.map(item => (              <li className="kanban-item" data-value={item.value} key={item.value}>                {children(item, {                  handle: { 'type': 'button', 'className': 'kanban-handle', 'aria-pressed': 'false', 'aria-label': drag(item) },                  move: { 'type': 'button', 'className': 'kanban-move', 'popoverTarget': `${id}-mover`, 'aria-label': move(item) },                })}              </li>            ))}          </ol>          <p className="kanban-empty">{empty ? empty(column) : 'No items'}</p>        </section>      ))}      <div className="popover popover-end" popover="auto" id={`${id}-mover`}>        <form className="kanban-mover">          <label className="field">            {columnLabel}            <select className="select" name="column" />          </label>          <label className="field">            {position}            <select className="select" name="position" />          </label>          <div className="kanban-mover-actions">            <button type="button" className="btn btn-sm" popoverTarget={`${id}-mover`} popoverTargetAction="hide">{cancel}</button>            <button type="submit" className="btn btn-sm btn-primary">{confirm}</button>          </div>        </form>      </div>      <div className="kanban-preview" popover="manual" aria-hidden="true" />      <p className="kanban-status" role="status" />    </div>  )}/** * The items of each column, in the order an arrangement gives them. An item it does not name keeps the column * it names itself, or the first, after the ones it does; a value it names that no item has is passed over. */function arranged<C extends KanbanColumn, T extends KanbanItem>(columns: C[], items: T[], order: KanbanValue = []): T[][] {  const named = new Set(order.flatMap(entry => entry.items))  const own = (item: T) => columns.some(column => column.value === item.column) ? item.column : columns[0]?.value  return columns.map((column) => {    const listed = (order.find(entry => entry.value === column.value)?.items ?? []).flatMap(value => items.filter(item => item.value === value))    return [...listed, ...items.filter(item => !named.has(item.value) && own(item) === column.value)]  })}
ui/Kanban.svelte
<script lang="ts" module>  import type { Snippet } from 'svelte'  import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements'  import type { KanbanMessages, KanbanValue } from '@master/ui/behaviors/kanban.js'  export type { KanbanValue }  export interface KanbanColumn {    /** What the column stands for in the arrangement. */    value: string    /** The column's name: its title, and what the status and the mover call it. */    label: string  }  export interface KanbanItem {    /** What the item stands for in the arrangement. No other item has it. */    value: string    /** What the item is called: its handle and its move button are named with it. */    label: string    /** The column the item starts in, and stays in while the arrangement does not name it. The first by default. */    column?: string  }  export interface KanbanLabels<T extends KanbanItem> {    /** The accessible name of an item's handle. `Drag <label>` by default. */    drag?: (item: T) => string    /** The accessible name of the button that opens the mover for an item. `Move <label>` by default. */    move?: (item: T) => string    /** The mover's two fields and two buttons. */    column?: string    position?: string    confirm?: string    cancel?: string  }  /** What an item's own markup spreads on its two buttons. */  export interface KanbanControls {    /** For the grip, an empty `<button>`: it carries the item with the pointer and the keys. */    handle: HTMLButtonAttributes    /** For the button that opens the mover, an empty `<button>`: a column and a position are chosen there. */    move: HTMLButtonAttributes  }  export interface KanbanProps<C extends KanbanColumn, T extends KanbanItem> extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {    /** The columns, in their order. The order is not the reader's to change. */    columns: C[]    items: T[]    /** The arrangement: each column's value and the values of its items, in order. Bind it, or leave it out. */    value?: KanbanValue    onValueChange?: (value: KanbanValue) => void    /** What an item shows, with the attributes of its handle and of its move button to spread. Each button holds its icon. */    children: Snippet<[T, KanbanControls]>    /** What stands beside a column's title, such as the number of items it holds. */    header?: Snippet<[C, T[]]>    /** What a column says while it holds no item. */    empty?: Snippet<[C]>    /** The names of the controls, in the page's language. */    labels?: KanbanLabels<T>    /** What the status region says, in the page's language. */    messages?: KanbanMessages  }  /**   * The items of each column, in the order an arrangement gives them. An item it does not name keeps the   * column it names itself, or the first, after the ones it does; a value no item has is passed over.   */  function arranged<C extends KanbanColumn, T extends KanbanItem>(columns: C[], items: T[], order: KanbanValue = []): T[][] {    const named = new Set(order.flatMap(entry => entry.items))    const own = (item: T) => columns.some(column => column.value === item.column) ? item.column : columns[0]?.value    return columns.map((column) => {      const listed = (order.find(entry => entry.value === column.value)?.items ?? []).flatMap(value => items.filter(item => item.value === value))      return [...listed, ...items.filter(item => !named.has(item.value) && own(item) === column.value)]    })  }</script><script lang="ts" generics="C extends KanbanColumn, T extends KanbanItem">  import { tick, untrack } from 'svelte'  import { kanban } from '@master/ui/behaviors/kanban.js'  import { behavior } from './behavior.svelte.js'  const id = $props.id()  let { columns, items, value = $bindable(), onValueChange, children, header, empty, labels = {}, messages, class: className, ...root }: KanbanProps<C, T> = $props()  let kept = $state(untrack(() => value))  const shown = $derived(arranged(columns, items, value ?? kept))  const drag = $derived(labels.drag ?? ((item: T) => `Drag ${item.label}`))  const move = $derived(labels.move ?? ((item: T) => `Move ${item.label}`))  // A move waits for the render that writes the item in its place, so focus finds its handle there.  const arrange = async (next: KanbanValue) => {    kept = next    value = next    onValueChange?.(next)    await tick()  }  const attach = behavior(kanban, () => ({ messages, arrange }))</script><!--  @component  A board whose items the reader moves between columns. Svelte writes the columns and their items in the  arrangement it holds; the behavior carries an item with the pointer and the keys, and asks Svelte to arrange  the board when one is dropped. An item that changes column is rendered again in its new list, so what it  shows comes from the data, not from state kept inside it.--><div class={['kanban', className]} role="group" {@attach attach} {...root}>  {#each columns as column, at (column.value)}    <section class="kanban-column" data-value={column.value} aria-labelledby="{id}-column-{at}">      <header class="kanban-header">        <h3 class="kanban-title" id="{id}-column-{at}">{column.label}</h3>        {@render header?.(column, shown[at]!)}      </header>      <ol class="kanban-items">        {#each shown[at]! as item (item.value)}          <li class="kanban-item" data-value={item.value}>            {@render children(item, {              handle: { 'type': 'button', 'class': 'kanban-handle', 'aria-pressed': 'false', 'aria-label': drag(item) },              move: { 'type': 'button', 'class': 'kanban-move', 'popovertarget': `${id}-mover`, 'aria-label': move(item) },            })}          </li>        {/each}      </ol>      <p class="kanban-empty">{#if empty}{@render empty(column)}{:else}No items{/if}</p>    </section>  {/each}  <div class="popover popover-end" popover="auto" id="{id}-mover">    <form class="kanban-mover">      <label class="field">        {labels.column ?? 'Column'}        <select class="select" name="column"></select>      </label>      <label class="field">        {labels.position ?? 'Position'}        <select class="select" name="position"></select>      </label>      <div class="kanban-mover-actions">        <button type="button" class="btn btn-sm" popovertarget="{id}-mover" popovertargetaction="hide">{labels.cancel ?? 'Cancel'}</button>        <button type="submit" class="btn btn-sm btn-primary">{labels.confirm ?? 'Move'}</button>      </div>    </form>  </div>  <div class="kanban-preview" popover="manual" aria-hidden="true"></div>  <p class="kanban-status" role="status"></p></div>
ui/Kanban.vue
<script setup lang="ts" generic="C extends { value: string, label: string }, T extends { value: string, label: string, column?: string }">import { computed, nextTick, ref, useId, useTemplateRef } from 'vue'import { kanban, type KanbanMessages, type KanbanValue } from '@master/ui/behaviors/kanban.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { columns, items, labels = {}, messages } = defineProps<{  /** The columns, in their order, each with the value it stands for and its name. The order is not the reader's to change. */  columns: C[]  /**   * Each with the value it stands for, which no other item has, the label its controls are named with, and   * the column it starts in: the first by default.   */  items: T[]  /**   * The names of the controls, in the page's language: `drag` and `move` name an item's handle and the   * button that opens the mover, `Drag <label>` and `Move <label>` by default; the others are the mover's   * two fields and two buttons.   */  labels?: { drag?: (item: T) => string, move?: (item: T) => string, column?: string, position?: string, confirm?: string, cancel?: string }  /** What the status region says, in the page's language. */  messages?: KanbanMessages}>()/** The arrangement, each column's value and the values of its items in order: `v-model`. */const model = defineModel<KanbanValue>()defineSlots<{  /**   * What an item shows. Bind `handle` on the grip, an empty button that carries the item with the pointer and   * the keys, and `move` on another, which opens the mover.   */  default?: (props: { item: T, handle: { 'type': 'button', 'class': string, 'aria-pressed': 'false', 'aria-label': string }, move: { 'type': 'button', 'class': string, 'popovertarget': string, 'aria-label': string } }) => unknown  /** What stands beside a column's title, such as the number of items it holds. */  header?: (props: { column: C, items: T[] }) => unknown  /** What a column says while it holds no item. */  empty?: (props: { column: C }) => unknown}>()/* * A board whose items the reader moves between columns. Vue writes the columns and their items in the * arrangement it holds; the behavior carries an item with the pointer and the keys, and asks Vue to arrange * the board when one is dropped. An item that changes column is rendered again in its new list, so what it * shows comes from the data, not from state kept inside it. */const id = useId()const kept = ref<KanbanValue | undefined>(model.value)const order = computed(() => model.value ?? kept.value ?? [])/** * The items of each column, in the order the arrangement gives them. An item it does not name keeps the * column it names itself, or the first, after the ones it does; a value no item has is passed over. */const shown = computed(() => {  const named = new Set(order.value.flatMap(entry => entry.items))  const own = (item: T) => columns.some(column => column.value === item.column) ? item.column : columns[0]?.value  return columns.map((column) => {    const listed = (order.value.find(entry => entry.value === column.value)?.items ?? []).flatMap(value => items.filter(item => item.value === value))    return [...listed, ...items.filter(item => !named.has(item.value) && own(item) === column.value)]  })})const drag = (item: T) => labels.drag?.(item) ?? `Drag ${item.label}`const move = (item: T) => labels.move?.(item) ?? `Move ${item.label}`// A move waits for the render that writes the item in its place, so focus finds its handle there.const arrange = async (next: KanbanValue) => {  kept.value = next  model.value = next  await nextTick()}const root = useTemplateRef<HTMLDivElement>('root')useBehavior(root, kanban, () => ({ messages, arrange }))</script><template>  <div class="kanban" role="group" ref="root" v-bind="$attrs">    <section v-for="(column, at) in columns" :key="column.value" class="kanban-column" :data-value="column.value" :aria-labelledby="`${id}-column-${at}`">      <header class="kanban-header">        <h3 class="kanban-title" :id="`${id}-column-${at}`">{{ column.label }}</h3>        <slot name="header" :column="column" :items="shown[at]!" />      </header>      <ol class="kanban-items">        <li v-for="item in shown[at]" :key="item.value" class="kanban-item" :data-value="item.value">          <slot            :item="item"            :handle="{ 'type': 'button', 'class': 'kanban-handle', 'aria-pressed': 'false', 'aria-label': drag(item) }"            :move="{ 'type': 'button', 'class': 'kanban-move', 'popovertarget': `${id}-mover`, 'aria-label': move(item) }"          />        </li>      </ol>      <p class="kanban-empty"><slot name="empty" :column="column">No items</slot></p>    </section>    <div class="popover popover-end" popover="auto" :id="`${id}-mover`">      <form class="kanban-mover">        <label class="field">          {{ labels.column ?? 'Column' }}          <select class="select" name="column" />        </label>        <label class="field">          {{ labels.position ?? 'Position' }}          <select class="select" name="position" />        </label>        <div class="kanban-mover-actions">          <button type="button" class="btn btn-sm" :popovertarget="`${id}-mover`" popovertargetaction="hide">{{ labels.cancel ?? 'Cancel' }}</button>          <button type="submit" class="btn btn-sm btn-primary">{{ labels.confirm ?? 'Move' }}</button>        </div>      </form>    </div>    <div class="kanban-preview" popover="manual" aria-hidden="true" />    <p class="kanban-status" role="status" />  </div></template>

#類別

類別說明
kanban看板:一列可橫向捲動的欄。為它設定高度後,各欄就會止於該高度,每份清單各自捲動。搬移項目期間,游標會呈握拳手勢
kanban-column一個欄,也就是以其標題命名的托盤。它代表其 data-value。帶有 hidden 時不接受任何項目,並會被略過
kanban-header欄的標頭:欄的標題,以及放在標題旁的內容,例如計數。清單捲動時它會留在原位
kanban-title欄的名稱,與項目的文字從同一條線開始
kanban-items欄的清單,依文件中的順序排列。它是會捲動的部分
kanban-items-target由行為設定在清單上,表示搬移中項目的落點在該清單的結尾:在最後一個項目之後繪製一條線,空的欄則在凹槽周圍繪製外環搭配 kanban-items 使用
kanban-item一個項目。它代表其 data-value,看板中的其他項目不可使用相同的值。搬移時,它會留在原位並淡化。使用滑鼠時,可從連結、按鈕或欄位以外的任何部分搬移它
kanban-item-target由行為設定在項目上,表示搬移中的項目會落在它之前:在它上方的間距中繪製一條線搭配 kanban-item 使用
kanban-handle用來搬移項目的按鈕,內含握把圖示,請以所移動的內容命名。點按範圍為 24px,觸控螢幕上高 44px,並只延伸到與旁邊移動按鈕的中間
kanban-controls將項目的移動按鈕和把手成對放在第一行結尾的容器:兩者緊鄰排列,伸入項目的內距,讓握把的圖示貼齊下方文字結束的邊緣,並對齊高度為 --kanban-line 的行的中線
kanban-move為所屬項目開啟移動表單的按鈕,與握把成對,內含兩個交錯箭頭的圖示:點按範圍為 24px,觸控螢幕上高 44px,並只延伸到與握把的中間。請將 popovertarget 設為移動表單所在的彈出面板,並以所移動的內容命名。在指標可以懸停的裝置上,指標或按鍵到達所屬項目後才會繪製
kanban-empty欄內沒有項目時,取代清單顯示的幾個字,位於淺凹槽中
kanban-preview一個空元素,拖曳期間由行為顯示在頂層,帶有搬移中項目的名稱,並位於指標處
kanban-preview-landing由行為在放開後設定,此時搬移面板正滑向項目的新位置搭配 kanban-preview 使用
kanban-mover看板中彈出面板內的表單,包含名為 column 和名為 position 的下拉選單,由行為填入選項。項目中的按鈕只要 popovertarget 指向該彈出面板,無論是 kanban-move 還是頁面自己的按鈕,都會為該項目開啟它;提交表單就會移動項目。行為會把該按鈕的名稱寫成表單的 aria-label,讓表單說明要移動的是哪個項目
kanban-mover-actions移動表單的按鈕,位於表單結尾:先是關閉表單的按鈕,再是執行移動的按鈕
kanban-status說出每次拿起、選擇位置、放下和取消的區域,放在看板內或緊接在看板之後。不占用版面空間

#自訂屬性

屬性預設值說明
--kanban-column-width17.5rem欄的寬度,不會超過看板寬度減去 2rem
--kanban-gap.75rem兩欄之間的間距
--kanban-inset.375rem欄的邊緣與其項目之間的空間;欄的圓角等於項目的圓角加上這個值
--kanban-item-gap.375rem兩個項目之間的間距,落點線就畫在這裡
--kanban-padding.75rem看板中卡片的內距;欄的標題從同一條線開始
--kanban-radiusvar(--radius-control-lg)看板中卡片、空欄凹槽和搬移面板的圓角
--kanban-markervar(--color-focus)標示落點的線條和空欄外環的顏色
--kanban-linecalc(.9375rem * 1.4)這對控制項置中對齊的行高,預設為卡片標題的行高設定於 kanban-controls
--kanban-x搬移面板起始側邊緣與檢視區左側的距離,由腳本寫入設定於 kanban-preview
--kanban-y搬移面板頂端與檢視區頂端的距離,由腳本寫入設定於 kanban-preview
--kanban-width搬移面板的寬度,等於搬移中項目本身的寬度,由腳本寫入設定於 kanban-preview

#原始碼

@master/ui/components/kanban.css
/* * Kanban: a board of columns, each a named section that holds a list of items, where an item is moved to * another place in its column or into another column: by dragging its handle, with the keys, or by choosing a * column and a position in the mover. * The board is a row that scrolls across; a column is a tray as wide as --kanban-column-width, never wider than * the board less a peek of the next, and its list scrolls by itself once the column is as tall as the board. * A column's corner is the corner of what it holds plus its inset, and its title starts on the line the * items' words start on. What an item holds is the page's: a card, a badge, an avatar. * Nothing moves while an item is carried. The item stays in its place and fades, a line stands in the gap it * would land in, kanban-item-target before an item or kanban-items-target at the end of a list, and a small * sheet with the item's name follows the pointer in the top layer, clear of every column's clipping, placed * by --kanban-x and --kanban-y at the width --kanban-width. Those three are the only things the behavior * measures and writes. On the release the sheet glides into the place the item took and leaves. * Without the popover API there is no sheet: the faded item and the line still say what is carried and where. */@layer components.ui {  .kanban {    --kanban-column-width: 17.5rem;    --kanban-gap: .75rem;    --kanban-inset: .375rem;    --kanban-item-gap: .375rem;    --kanban-padding: .75rem;    --kanban-radius: var(--radius-control-lg);    --kanban-marker: var(--color-focus);    position: relative;    display: flex;    align-items: flex-start;    gap: var(--kanban-gap);    min-width: 0;    min-height: 0;    overflow-x: auto;    overscroll-behavior-x: contain;    scrollbar-width: thin;    scrollbar-color: var(--color-line-strong) transparent;    /* While an item is carried the cursor is a closed hand wherever the pointer goes, and no text is selected. */    &:has(.kanban-handle[aria-pressed="true"]) {      cursor: grabbing;      user-select: none;      -webkit-user-select: none;    }    /* A card the board holds takes the board's corner and padding, so the column's corner and title follow it. */    .card {      --card-radius: var(--kanban-radius);      --card-padding: var(--kanban-padding);    }    @media (forced-colors: active) {      scrollbar-color: auto;    }  }  /* A column: a tray that holds its header and its list, as tall as what it holds and never taller than the board. */  .kanban-column {    --surface-color: var(--color-surface-tray);    display: flex;    flex: none;    flex-direction: column;    width: min(var(--kanban-column-width), 100% - 2rem);    min-width: 0;    max-height: 100%;    border-radius: calc(var(--kanban-radius) * var(--corner-scale) + var(--kanban-inset));    corner-shape: var(--corner-shape);    background: var(--color-surface-tray);    color: var(--color-text-body);    box-shadow: inset 0 0 0 .5px var(--color-line-hair), inset 0 1px 2px -1px var(--color-shade-2);    &[hidden] {      display: none;    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }  /* The head of a column stays while its list scrolls. Its words start where the items' words start. */  .kanban-header {    display: flex;    flex: none;    align-items: center;    gap: .5rem;    min-height: 2.5rem;    padding: .375rem calc(var(--kanban-inset) + var(--kanban-padding)) .125rem;  }  .kanban-title {    flex: 1;    min-width: 0;    margin: 0;    color: var(--color-text-strong);    font-size: .8125rem;    font-weight: var(--font-weight-control);    line-height: 1.4;    overflow-wrap: break-word;  }  /* The list. It is the one part of a column that scrolls, and it keeps room for the line of a place at its ends. */  .kanban-items {    display: flex;    flex: 1 1 auto;    flex-direction: column;    gap: var(--kanban-item-gap);    min-height: 0;    margin: 0;    padding: var(--kanban-item-gap) var(--kanban-inset) var(--kanban-inset);    overflow-y: auto;    /* Its end does not move the page under it; a swipe or a wheel across still reaches the board, which scrolls that way. */    overscroll-behavior-y: contain;    list-style: none;    scrollbar-width: thin;    scrollbar-color: var(--color-line-strong) transparent;    @media (forced-colors: active) {      scrollbar-color: auto;    }  }  .kanban-item {    position: relative;    flex: none;    min-width: 0;    margin: 0;    padding: 0;    scroll-margin: var(--kanban-inset);    transition-property: opacity;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);    /* Carried: it keeps its place and fades, so the reader sees where it came from. */    &:has(.kanban-handle[aria-pressed="true"]) {      opacity: .45;    }    /* Held by the keys, its handle has focus: it fades less, so the ring around the grip stays plain. */    &:has(.kanban-handle[aria-pressed="true"]:focus) {      opacity: .7;    }    /* The place before this item: a line in the middle of the gap over it. */    &.kanban-item-target::before {      content: '';      position: absolute;      inset-inline: 0;      top: calc(var(--kanban-item-gap) / -2 - 1px);      height: 2px;      border-radius: 1px;      background: var(--kanban-marker);      pointer-events: none;    }    @media (prefers-reduced-motion: reduce) {      transition-property: none;    }    @media (forced-colors: active) {      &.kanban-item-target::before {        background: Highlight;      }    }  }  /* An empty list with no well to show keeps its room, and the line of a place is drawn across the middle of it. */  .kanban-items-target:not(:has(.kanban-item)) {    background: linear-gradient(var(--kanban-marker), var(--kanban-marker)) center / calc(100% - var(--kanban-inset) * 2) 2px no-repeat;    @media (forced-colors: active) {      background-image: linear-gradient(Highlight, Highlight);    }  }  /*   * An item is carried by any part of it with a mouse, and says so with the hand where a pointer hovers; a   * link, a button or a field in it keeps its own cursor and its own press.   */  @media (hover: hover) and (pointer: fine) {    .kanban-item:has(.kanban-handle:enabled) {      cursor: grab;    }  }  /*   * A move is drawn by the platform where it can be: the behavior starts a view transition scoped to the board,   * each item is named by its own node, and every item glides from where it stood to where it stands. A list is   * named too and holds its items' pictures, clipped as the list clips them: an item past the foot of a long   * column, or scrolled under its head, stays out of sight on the way. An item that changes column is drawn by   * the list it arrives in, so it comes in from that list's edge while the carried sheet crosses the gap. The   * names stay inside the board, so a page's own transitions take the board as one picture.   */  @supports (view-transition-scope: all) {    .kanban {      view-transition-scope: all;    }    .kanban-items {      view-transition-name: match-element;      view-transition-class: kanban-items;      view-transition-group: contain;    }    .kanban-item {      view-transition-name: match-element;      view-transition-class: kanban-item;    }    /*     * The board takes no press while the pictures glide, so the glide is quick, the board's own picture with     * it: a reader who drops one card and reaches for the next finds it answering.     */    .kanban::view-transition-group(*),    .kanban::view-transition-old(*),    .kanban::view-transition-new(*) {      animation-duration: var(--duration-quick);      animation-timing-function: var(--easing-glide);    }    .kanban::view-transition-group-children(.kanban-items) {      overflow: clip;    }  }  /*   * The place at the end of a list: a line under its last item, in the middle of the gap the item would leave   * there. It is drawn by that item, out of flow as the line over an item is, so marking a place never changes   * how far the list scrolls: a line that was an item of the list made it 2px longer and moved every item.   */  .kanban-items-target .kanban-item:nth-last-child(1 of .kanban-item)::after {    content: '';    position: absolute;    inset-inline: 0;    bottom: calc(var(--kanban-item-gap) / -2 - 1px);    height: 2px;    border-radius: 1px;    background: var(--kanban-marker);    pointer-events: none;    @media (forced-colors: active) {      background: Highlight;    }  }  /*   * What an empty column shows: a shallow well with a few words, in place of its list. A column that is the   * place an item would land in has no gap to draw a line in, so the well takes the marker's ink as a ring.   */  .kanban-empty {    display: none;    place-items: center;    min-height: 3.5rem;    margin: var(--kanban-item-gap) var(--kanban-inset) var(--kanban-inset);    padding: .5rem var(--kanban-padding);    border-radius: calc(var(--kanban-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--color-surface-inset);    color: var(--color-text-muted);    box-shadow: inset 0 0 0 .5px var(--color-line-hair);    font-size: .8125rem;    line-height: 1.4;    text-align: center;  }  .kanban-column:not(:has(.kanban-item)):has(.kanban-empty) {    .kanban-items {      display: none;    }    .kanban-empty {      display: grid;    }    &:has(.kanban-items-target) .kanban-empty {      color: var(--color-text-strong);      box-shadow: inset 0 0 0 1.5px var(--kanban-marker);      @media (forced-colors: active) {        outline: 2px solid Highlight;        outline-offset: -2px;      }    }  }  /*   * An item's two controls, a quiet pair of the same size: the handle, which carries the item, and the button   * that opens the mover. Each holds its icon, a grip and two arrows that pass, at 14px; each is 24px and shows   * only that icon until the pointer or the keys reach it, and its target is 44px tall on touch without moving it.   */  .kanban-handle,  .kanban-move {    --icon-size: .875rem;    position: relative;    display: inline-grid;    flex: none;    place-items: center;    width: 1.5rem;    height: 1.5rem;    margin: 0;    padding: 0;    border: 0;    border-radius: calc(var(--radius-chip) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: transparent;    color: var(--color-text-muted);    appearance: none;    user-select: none;    -webkit-user-select: none;    -webkit-tap-highlight-color: transparent;    transition-property: background-color, color;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);    &::after {      content: '';      position: absolute;      inset: -.25rem;      @media (pointer: coarse) {        inset: min(-.25rem, calc((100% - 2.75rem) / 2));      }    }    @media (hover: hover) {      &:hover:not(:disabled) {        background: var(--color-surface-chip);        color: var(--color-text-strong);      }    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 0;      color: var(--color-text-strong);    }    &:disabled {      color: var(--color-text-disabled);      cursor: not-allowed;    }  }  /*   * The pair at the end of an item's first line. The two stand close; the pair reaches into the item's padding   * by .5rem, as far as the grip's points stand in from its box, so the points meet the edge the words under   * them end on and only a hover chip shows past it; and it centers on a line of --kanban-line, a card title's   * by default, so it stands beside the first line and does not deepen it.   */  .kanban-controls {    --kanban-line: calc(.9375rem * 1.4);    display: inline-flex;    flex: none;    align-items: center;    gap: .125rem;    margin-block: calc((var(--kanban-line) - 1.5rem) / 2);    margin-inline-end: -.5rem;  }  /*   * The two stand .125rem apart, so on the side where they meet each target stops halfway: a target that reached   * its full depth there lay over the other button, and a press on the edge of one answered as the other.   */  .kanban-controls:has(.kanban-handle) .kanban-move::after {    inset-inline-end: -.0625rem;  }  .kanban-controls:has(.kanban-move) .kanban-handle::after {    inset-inline-start: -.0625rem;  }  @media (hover: hover) and (pointer: fine) {    .kanban-item:hover .kanban-move,    .kanban-item:focus-within .kanban-move {      opacity: 1;    }  }  .kanban-handle {    cursor: grab;    /* A drag that starts on the grip never scrolls; the rest of the item still does. */    touch-action: none;    /* Carried: the grip sits in a well, as a pressed button does. */    &[aria-pressed="true"] {      background: var(--color-surface-inset);      color: var(--color-text-strong);      box-shadow: var(--shadow-pressed);      cursor: grabbing;    }  }  .kanban-move {    cursor: pointer;    touch-action: manipulation;    /*     * Where a pointer hovers, the way to move without a drag waits out of sight until the pointer or the keys     * are on its item: a board of cards then shows one grip to a card, not a pair. A finger has no hover, so on     * a touch screen it is always drawn.     */    @media (hover: hover) and (pointer: fine) {      opacity: 0;      transition-property: background-color, color, opacity;      @media (prefers-reduced-motion: reduce) {        transition-property: background-color, color;      }    }  }  /*   * The carried item's name on a small raised sheet, in the top layer, where no column clips it. It is a manual   * popover the behavior shows; it stands at the viewport's corner and --kanban-x and --kanban-y carry it to the   * pointer, with no easing between the two. Landing, it glides to the place the item took, then leaves.   */  .kanban-preview {    display: none;    position: fixed;    inset: 0 auto auto 0;    box-sizing: border-box;    width: var(--kanban-width, 16rem);    max-width: calc(100vw - 1rem);    margin: 0;    /*     * The room under the words is a clear border, not padding: the clamp cuts at the padding's edge, and an     * engine that still paints the line after the last showed the top of it in padding there.     */    padding: .625rem var(--kanban-padding, .75rem) 0;    border: 0;    border-block-end: .625rem solid transparent;    border-radius: calc(var(--kanban-radius, var(--radius-control-lg)) * var(--corner-scale));    corner-shape: var(--corner-shape);    overflow: hidden;    @apply --surface-sheet;    color: var(--color-text-strong);    box-shadow: var(--shadow-floating);    font-size: .875rem;    font-weight: var(--font-weight-control);    line-height: 1.4;    translate: var(--kanban-x, 0px) var(--kanban-y, 0px);    pointer-events: none;    user-select: none;    -webkit-user-select: none;    will-change: translate;    @supports selector(:popover-open) {      opacity: 0;      transition-property: opacity, overlay, display;      transition-duration: var(--duration-quick);      transition-timing-function: var(--easing-glide);      transition-behavior: allow-discrete;      &:popover-open {        display: -webkit-box;        opacity: 1;        -webkit-box-orient: vertical;        -webkit-line-clamp: 2;        @starting-style {          opacity: 0;        }      }    }    &.kanban-preview-landing {      transition-property: translate, opacity, overlay, display;      transition-duration: var(--duration-base), var(--duration-quick), var(--duration-quick), var(--duration-quick);    }    @media (prefers-reduced-motion: reduce) {      &.kanban-preview-landing {        transition-property: opacity, overlay, display;      }    }    @media (forced-colors: active) {      outline: 2px solid Highlight;      outline-offset: -2px;    }  }  /* The mover: the form of a popover where a column and a position are chosen, for a hand that does not drag. */  .kanban-mover {    display: grid;    gap: .75rem;    width: 15rem;    max-width: 100%;    margin: 0;  }  /* The mover's buttons stand at its end, the one that moves last. */  .kanban-mover-actions {    display: flex;    flex-wrap: wrap;    justify-content: flex-end;    gap: .5rem;  }  /* What the status region says is for assistive technology: it takes no room. */  .kanban-status {    position: absolute;    width: 1px;    height: 1px;    margin: -1px;    padding: 0;    overflow: hidden;    clip-path: inset(50%);    white-space: nowrap;  }}