导航

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>
将握把拖到另一列:一条线标出卡片的落点,指针靠近看板任一端时看板会滚动。使用键盘时,聚焦握把后按空格键,用方向键选择位置,再按一次空格键。握把旁边的按钮无需拖动即可移动卡片。

可排序列表为一个列表排序。如果项目还会换到另一个列表,而且它所在的列表本身就说明了它的某种情况,例如所处阶段、负责人或状态,就使用看板。

#样式表绘制的内容

  • 看板是一个横向滚动的行。为它设置高度后,各列的高度就以此为限,例如上例中的 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 时,会拿起项目;鼠标、触控笔和触摸都一样,而且只有开始拖动的那个指针能移动它。指针下方的列(或横向上最近的列)就是它将落入的列,落点位于中点在指针下方的第一个项目之前。指针靠近看板的两端时,看板会横向滚动;靠近该列列表的两端时,列表会纵向滚动。松开即提交。在拿起项目的位置松开不会有任何变化;在看板之外松开、按 Esc、指针被取消或指针捕获被夺走,都会让项目留在原处。
  • 整个项目(鼠标)。 使用鼠标时,按住项目上链接、按钮或字段以外的任何位置也能拿起项目,指针在这些位置显示为手形。手指只能通过手柄拿起项目:在项目其他位置按下是滚动列表的方式。在项目上按下但没有移动,仍然只是对该处内容的一次点击。
  • 键盘。 在手柄上按 Enter 或 空格键 会拿起项目,效果与按下但不移动相同。随后用方向键选择位置,落点线会标出它;拿起项目之前,方向键不起作用,因此屏幕阅读器自身的方向键操作仍然可用。按 Enter 或 空格键 提交,按 Esc 取消,焦点离开手柄也会提交。
  • 移动面板。 项目中的按钮,只要其 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 的 select 和一个名为 position 的 select,由行为脚本填充。项目中 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;  }}