網站導覽

v2.1.0
應用程式區塊

表格檢視

具備搜尋、篩選、選取與分頁功能的表格。

表格檢視把表格和操作所需的功能放在一起,包括標題、主要操作、篩選、排序、選取、各列操作與分頁。這些各有對應的元件,區塊則示範如何把它們排在同一個面板上。

表格檢視

<section class="sheet container-inline flex flex-col overflow-hidden" data-example="table-view" aria-labelledby="tv-title">  <header class="flex flex-wrap items-center justify-between gap-sm p-md">    <div class="flex flex-col gap-3xs">      <h2 class="heading heading-sm" id="tv-title">Atlas Labs</h2>      <p class="m(0) fg-text-muted" id="tv-summary">24 projects</p>    </div>    <div class="flex flex-wrap items-center gap-xs">      <div class="segmented segmented-sm" role="radiogroup" aria-label="Show">        <label class="segmented-item">          <input type="radio" class="segmented-input" name="tv-set" value="projects" checked>Projects</label>        <label class="segmented-item">          <input type="radio" class="segmented-input" name="tv-set" value="people">People</label>        <label class="segmented-item">          <input type="radio" class="segmented-input" name="tv-set" value="files">Files</label>      </div>      <button type="button" class="btn btn-primary btn-sm" id="tv-action">        <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="M3 8L13 8" />          <path d="M8 3L8 13" />        </svg>        <span>New project</span>      </button>    </div>  </header>  <div class="flex flex-wrap items-center gap-xs px-md pb-md">    <label class="input-group input-group-sm grow(1) basis(200) max-w(320)">      <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="7" cy="7" r="4.5" />        <path d="M10.182 10.182L14 14" />      </svg>      <input class="input-group-field" type="search" id="tv-search" placeholder="Search projects" aria-label="Search projects" autocomplete="off">    </label>    <button type="button" class="btn btn-sm" popovertarget="tv-filters" data-filter="open">      <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.5365 3L11.4635 3A1 1 0 0 1 12.2548 4.6114L9.4587 8.2299A1 1 0 0 0 9.25 8.8413L9.25 11.323A1 1 0 0 1 8.6214 12.2514L7.875 12.55A0.8203 0.8203 0 0 1 6.75 11.7883L6.75 8.8413A1 1 0 0 0 6.5413 8.2299L3.7452 4.6114A1 1 0 0 1 4.5365 3Z" />      </svg>Filters      <span data-filter="count" aria-hidden="true" hidden>        <span class="badge badge-sm badge-ink badge-pill">0</span>      </span>    </button>    <select class="select select-raised select-sm ml-auto" id="tv-sort" aria-label="Sort by"></select>    <div class="w-full" data-filter="applied" hidden>      <div class="flex flex-wrap items-center gap-xs">        <ul class="flex flex-wrap gap-xs m(0) p(0)" aria-label="Applied filters" data-filter="chips"></ul>        <button type="button" class="btn btn-quiet btn-sm" data-filter="clear-all">Clear all</button>      </div>    </div>  </div>  <div class="popover p(0) w(560)" id="tv-filters" popover role="dialog" aria-labelledby="tv-filters-title" style="--popover-max-width: min(36rem, calc(100vw - 2rem))" data-filter="panel">    <form class="flex flex-col" data-filter="form" novalidate>      <header class="flex flex-col gap-3xs px-md pt-md pb-sm">        <h3 class="heading heading-xs" id="tv-filters-title">Filter projects</h3>        <p class="m(0) fg-text-muted" id="tv-filters-hint">A project shows when it meets every condition.</p>      </header>      <ul class="flex flex-col gap-xs m(0) px-md py-xs" data-filter="conditions"></ul>      <p class="m(0) px-md py-xs fg-text-muted" data-filter="empty">No conditions yet: every row shows.</p>      <p class="m(0) px-md py-xs fg-danger" id="tv-filters-error" role="alert" data-filter="error" hidden></p>      <div class="px-md pb-md">        <button type="button" class="btn btn-quiet btn-sm" data-filter="add">          <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="M3 8L13 8" />            <path d="M8 3L8 13" />          </svg>Add condition</button>      </div>      <footer class="flex flex-wrap items-center justify-between gap-xs p-md bt(1) bt-solid b-line-hair">        <button type="button" class="btn btn-quiet btn-sm" data-filter="clear">Clear</button>        <div class="flex gap-xs">          <button type="button" class="btn btn-sm" data-filter="cancel">Cancel</button>          <button type="submit" class="btn btn-primary btn-sm">Apply</button>        </div>      </footer>    </form>  </div>  <div class="scroll-area scroll-area-inline bt(1) bt-solid b-line-hair">    <table class="table table-interactive" id="tv-table" aria-labelledby="tv-title">      <thead id="tv-head"></thead>      <tbody id="tv-body"></tbody>    </table>  </div>  <footer class="flex flex-wrap items-center justify-between gap-sm p-md bt(1) bt-solid b-line-hair">    <div class="flex flex-wrap items-center gap-xs min-h(32)">      <p class="m(0) fg-text-muted" id="tv-count">No projects selected</p>      <div id="tv-selected" hidden>        <div class="flex items-center gap-3xs">          <button type="button" class="btn btn-quiet btn-sm btn-danger" id="tv-delete">Delete</button>          <button type="button" class="btn btn-quiet btn-sm" id="tv-deselect">Clear selection</button>        </div>      </div>    </div>    <div class="flex flex-wrap items-center gap-sm">      <p class="m(0) fg-text-muted whitespace-nowrap" id="tv-range">1–8 of 24</p>      <nav aria-label="Pagination">        <ol class="pagination" id="tv-pages"></ol>      </nav>    </div>  </footer>  <p class="sr-only" role="status" id="tv-status"></p>  <template data-filter="row">    <li class="flex flex-wrap items-center gap-xs">      <span class="w(44) shrink(0) fg-text-muted text-end" data-part="joiner">Where</span>      <select class="select select-sm" aria-label="Field" data-part="field"></select>      <select class="select select-sm" aria-label="Comparison" data-part="operator"></select>      <input class="input input-sm grow(1) basis(128) min-w(0)" aria-label="Value" data-part="value" required>      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove condition" data-part="remove">        <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 4L12 12" />          <path d="M4 12L12 4" />        </svg>      </button>    </li>  </template>  <template data-filter="choice">    <select class="select select-sm grow(1) basis(128)" aria-label="Value" data-part="value"></select>  </template>  <template data-filter="chip">    <li>      <span class="chip">        <span class="chip-label"></span>        <button type="button" class="chip-remove" aria-label="Remove the filter">          <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 4L12 12" />            <path d="M4 12L12 4" />          </svg>        </button>      </span>    </li>  </template>  <template id="tv-head-projects">    <table class="table">      <thead>        <tr class="table-row">          <th class="table-heading" scope="col">            <input type="checkbox" class="checkbox" data-part="all" aria-label="Select all projects">          </th>          <th class="table-heading" scope="col" data-sort="name">Project</th>          <th class="table-heading" scope="col">Status</th>          <th class="table-heading" scope="col">Region</th>          <th class="table-heading table-numeric" scope="col" data-sort="deployments">Deployments</th>          <th class="table-heading" scope="col" data-sort="deployed">Last deployed</th>          <th class="table-heading" scope="col">            <span class="sr-only">Actions</span>          </th>        </tr>      </thead>    </table>  </template>  <template id="tv-row-projects">    <table class="table">      <tbody>        <tr class="table-row">          <td class="table-cell">            <input type="checkbox" class="checkbox" data-part="select" aria-label="Select">          </td>          <th class="table-cell table-primary" scope="row">            <span data-part="name"></span>            <span class="block fg-text-muted font-regular" data-part="domain"></span>          </th>          <td class="table-cell">            <span class="badge badge-dot" data-part="status"></span>          </td>          <td class="table-cell" data-part="region"></td>          <td class="table-cell table-numeric" data-part="deployments"></td>          <td class="table-cell whitespace-nowrap" data-part="deployed"></td>          <td class="table-cell text-end" data-part="actions"></td>        </tr>      </tbody>    </table>  </template>  <template id="tv-head-people">    <table class="table">      <thead>        <tr class="table-row">          <th class="table-heading" scope="col">            <input type="checkbox" class="checkbox" data-part="all" aria-label="Select all people">          </th>          <th class="table-heading" scope="col" data-sort="name">Person</th>          <th class="table-heading" scope="col">Role</th>          <th class="table-heading" scope="col">Status</th>          <th class="table-heading table-numeric" scope="col" data-sort="projects">Projects</th>          <th class="table-heading" scope="col" data-sort="active">Last active</th>          <th class="table-heading" scope="col">            <span class="sr-only">Actions</span>          </th>        </tr>      </thead>    </table>  </template>  <template id="tv-row-people">    <table class="table">      <tbody>        <tr class="table-row">          <td class="table-cell">            <input type="checkbox" class="checkbox" data-part="select" aria-label="Select">          </td>          <th class="table-cell table-primary" scope="row">            <span class="flex items-center gap-sm">              <span class="avatar avatar-sm" aria-hidden="true" data-part="initials"></span>              <span class="min-w(0)">                <span class="block" data-part="name"></span>                <span class="block fg-text-muted font-regular" data-part="email"></span>              </span>            </span>          </th>          <td class="table-cell" data-part="role"></td>          <td class="table-cell">            <span class="badge badge-dot" data-part="status"></span>          </td>          <td class="table-cell table-numeric" data-part="projects"></td>          <td class="table-cell whitespace-nowrap" data-part="active"></td>          <td class="table-cell text-end" data-part="actions"></td>        </tr>      </tbody>    </table>  </template>  <template id="tv-head-files">    <table class="table">      <thead>        <tr class="table-row">          <th class="table-heading" scope="col">            <input type="checkbox" class="checkbox" data-part="all" aria-label="Select all files">          </th>          <th class="table-heading" scope="col" data-sort="name">File</th>          <th class="table-heading" scope="col">Type</th>          <th class="table-heading table-numeric" scope="col" data-sort="size">Size</th>          <th class="table-heading" scope="col" data-sort="modified">Modified</th>          <th class="table-heading" scope="col">Owner</th>          <th class="table-heading" scope="col">            <span class="sr-only">Actions</span>          </th>        </tr>      </thead>    </table>  </template>  <template id="tv-row-files">    <table class="table">      <tbody>        <tr class="table-row">          <td class="table-cell">            <input type="checkbox" class="checkbox" data-part="select" aria-label="Select">          </td>          <th class="table-cell table-primary" scope="row">            <span class="flex items-center gap-sm">              <span class="icon-frame icon-frame-xs" aria-hidden="true">                <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round">                  <path d="M4.5 2L9.0858 2A1 1 0 0 1 9.7929 2.2929L12.2071 4.7071A1 1 0 0 1 12.5 5.4142L12.5 13A1 1 0 0 1 11.5 14L4.5 14A1 1 0 0 1 3.5 13L3.5 3A1 1 0 0 1 4.5 2Z" />                  <path d="M10 2.5V4.4A0.1 0.1 0 0 0 10.1 4.5H12L12.2409 4.7427A0.9993 0.9993 0 0 1 12.5 5.4142V5.5H10.1Q9.6444 5.5 9.3222 5.1778Q9 4.8556 9 4.4V2A1.1002 1.1002 0 0 1 9.3761 2.0431A1.0001 1.0001 0 0 1 9.7929 2.2929L10 2.5Z" fill="currentColor" stroke="none" fill-rule="evenodd" />                </svg>              </span>              <span class="min-w(0) truncate" data-part="name"></span>            </span>          </th>          <td class="table-cell" data-part="type"></td>          <td class="table-cell table-numeric" data-part="size"></td>          <td class="table-cell whitespace-nowrap" data-part="modified"></td>          <td class="table-cell whitespace-nowrap" data-part="owner"></td>          <td class="table-cell text-end" data-part="actions"></td>        </tr>      </tbody>    </table>  </template>  <template id="tv-actions">    <div>      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Actions">        <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="3.5" cy="8" r="1.05" fill="currentColor" stroke="none" />          <circle cx="8" cy="8" r="1.05" fill="currentColor" stroke="none" />          <circle cx="12.5" cy="8" r="1.05" fill="currentColor" stroke="none" />        </svg>      </button>      <div class="menu menu-end" popover>        <a class="menu-item" href="#" data-part="open">Open</a>        <hr class="menu-separator">        <button type="button" class="menu-item menu-item-danger" data-part="delete">Delete</button>      </div>    </div>  </template>  <template id="tv-empty">    <table class="table">      <tbody>        <tr class="table-row">          <td class="table-cell" colspan="7">            <div class="empty">              <p class="empty-title" data-part="title">No projects match</p>              <p class="empty-description">Try another search, or remove a filter.</p>              <div class="empty-actions">                <button type="button" class="btn btn-sm" data-part="reset">Clear the search and the filters</button>              </div>            </div>          </td>        </tr>      </tbody>    </table>  </template>  <template id="tv-page">    <ol class="pagination">      <li>        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Page"></button>      </li>    </ol>  </template>  <template id="tv-gap">    <ol class="pagination">      <li class="pagination-gap" aria-hidden="true">…</li>    </ol>  </template>  <template id="tv-previous">    <ol class="pagination">      <li>        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Previous 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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" transform="rotate(180 8 8)" />          </svg>        </button>      </li>    </ol>  </template>  <template id="tv-next">    <ol class="pagination">      <li>        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Next 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="M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5" />          </svg>        </button>      </li>    </ol>  </template></section>
搜尋、篩選、排序專案並翻頁瀏覽,或切換到成員與檔案。選取資料列即可刪除。

區塊提供可直接複製的標記,沿用頁面的文字顏色和字級。預覽在 body 上設定 fg-text-body text-sm。每個區塊都是尺寸容器,無論放在寬大的頁面、側邊欄大小的空間,還是對話框裡,都會依自身寬度重新排列。

#組成

  • 一個面板。 各區段以 bt(1) bt-solid b-line-hair 畫出的細線分隔,避免卡片層層相套。
  • 標題區分列兩端。 一側是工作區和說明符合筆數的計數,另一側是在專案、成員與檔案之間切換的分段控制項,以及主要操作。套用 flex flex-wrap items-center justify-between,面板較窄時,切換器和主要操作就會換到標題下方。
  • 搜尋、篩選與排序是一列可換行的控制項。 這一列包含寬度從 200px 延展到 320px 的搜尋輸入群組、篩選列的按鈕,以及用來選擇排序方式的凸起下拉選單,後者以 ml-auto 推到列尾。已套用的篩選條件會在下方另起一行,以膠囊標籤呈現,每個都可移除一項條件。
  • 排序方式顯示在讀者閱讀的地方。 已排序欄位的標題帶有 aria-sort,表格會以較深的文字色和 V 形箭頭標示;下拉選單則是變更排序的地方。
  • 表格在自己的區段內捲動。 將表格放在套用 scroll-area-inline 的捲動區域中。面板較窄時,水平捲動會留在表格內,還有欄位延伸的邊緣則會淡出。
  • 每組資料都有自己的第一個儲存格。 專案名稱在上,網域在下,成員是頭像旁的姓名和電子郵件,檔案則是圖示框旁的檔名。它們都使用 <th scope="row">,讓輔助技術讀取儲存格時一併讀出所屬的列。
  • 選取的是符合條件的資料。 在 table-row 上設定 aria-selected="true" 會套用選取色調,列內的核取方塊也會勾選。表頭的核取方塊會選取所有符合搜尋和篩選條件的資料列(包含所有頁面),只選取部分時則為 indeterminate。不再符合條件的資料列會離開選取範圍,因此「已選取 3 個,共 15 個」從不計入看不到的資料列。
  • 頁尾分列兩端。 一側是選取狀態,有選取項目時會附上「刪除」和「清除選取」;另一側是目前範圍和以按鈕組成的分頁導覽。到達兩端時會停用「上一頁」或「下一頁」;頁數很多時,會保留第一頁、最後一頁和目前頁面的相鄰頁,中間以省略符號隔開。
  • 各列操作收在選單裡,透過列尾低調的按鈕開啟。按鈕名稱要指出它所屬的列,例如「Atlas 的操作」。
  • 沒有符合的資料時會明確說明。 空狀態會填滿表格區域,並提供返回的方式:清除搜尋與篩選條件。

#哪些功能需要腳本

資料列是資料,因此由範例的 main.js 從 data.js 讀取資料,寫進標記中為每組資料準備的範本:樣式表和 utility 來自標記,文字則來自資料。它與篩選列共用兩個模組:query.js 對一般的資料列進行搜尋、篩選、排序和分頁,filters.js 則負責運作篩選列。在實際產品中,這些查詢應交給你的資料來源處理;區塊示範的是如何呈現每個查詢結果。若沒有腳本,可用 <form method="get"> 包住各區段:搜尋欄位、下拉選單和核取方塊會變成伺服器能處理的查詢字串,分頁導覽則改為連結。

#對選取項目執行操作

範例只有一個針對選取項目的操作,放在頁尾的計數旁邊。若有多個操作,請用浮動工具列顯示選取筆數、可執行的操作,以及清除選取的方式。使用 sticky bottom(16) 將工具列貼在面板底部,或將它固定在檢視區底部。只要還有選取項目,就顯示工具列。

對選取項目執行操作

<div class="toolbar toolbar-floating flex-wrap justify-center" role="toolbar" aria-label="2 projects selected">  <span class="px-xs fg-text-strong">2 selected</span>  <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-sm">    <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="M8 1.3333C4 4.6667 3.6667 8.6667 5.6667 12.3333H10.3333C12.3333 8.6667 12 4.6667 8 1.3333Z" /><circle cx="8" cy="6.6667" r="0.85" fill="currentColor" stroke="none" /><path d="M10.016 12.3333Q10.1079 12.4463 10.2446 12.5147L12.5342 13.6594A0.6999 0.6999 0 0 0 13.5377 13.1484L14.1443 9.5091Q14.1989 9.1824 13.9807 8.9328L11.9808 6.6473A0.7011 0.7011 0 0 0 11.3582 6.4146C11.5022 7.0678 11.5536 7.7269 11.5195 8.3865L11.635 7.7707L13.1346 9.4845L12.6181 12.5833L10.8942 11.7215L11.1203 10.5157C10.924 11.1275 10.6597 11.7349 10.3333 12.3333H10.016ZM4.6418 6.4146A0.6958 0.6958 0 0 0 4.0192 6.6473L2.0193 8.9328Q1.8012 9.1824 1.8557 9.5091L2.4623 13.1484A0.6999 0.6999 0 0 0 3.4658 13.6594L5.7554 12.5147Q5.8921 12.4463 5.984 12.3333H5.6667C5.3403 11.7349 5.076 11.1275 4.8797 10.5157L5.1058 11.7215L3.3819 12.5833L2.8654 9.4845L4.365 7.7707L4.4805 8.3865C4.4464 7.7269 4.4978 7.0678 4.6418 6.4146Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M6.6667 15L9.3333 15" />    </svg>Redeploy  </button>  <button type="button" class="btn btn-quiet btn-sm">    <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="M8.5 9L8.4994 1.9755A0.5 0.5 0 0 0 7.5054 1.9266L7.5 2L7.5014 9.0379A0.5007 0.5007 0 0 0 7.5892 9.285A0.7044 0.7044 0 0 0 8.4108 9.285A0.4996 0.4996 0 0 0 8.5 9Z" fill="currentColor" stroke="none" fill-rule="evenodd" /><path d="M5 6L7.8586 8.8586A0.2 0.2 0 0 0 8.1414 8.8586L11 6" /><path d="M2.5 10.5L2.5 12.5A1 1 0 0 0 3.5 13.5L12.5 13.5A1 1 0 0 0 13.5 12.5L13.5 10.5" />    </svg>Export  </button>  <button type="button" class="btn btn-quiet btn-sm btn-danger">    <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="M2.5 4.5L13.5 4.5" /><path d="M4 4.5L4.4501 13.0526A1 1 0 0 0 5.4488 14L10.5512 14A1 1 0 0 0 11.5499 13.0526L12 4.5" /><path d="M6 4.5L6 3A1 1 0 0 1 7 2L9 2A1 1 0 0 1 10 3L10 4.5" /><path d="M8 7.5L8 11" />    </svg>Delete  </button>  <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Clear the selection">    <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 4L12 12" /><path d="M4 12L12 4" />    </svg>  </button></div>
import RocketIcon from '@master/icons-react/native/16/soft/rocket'import DownloadIcon from '@master/icons-react/native/16/soft/download'import TrashIcon from '@master/icons-react/native/16/soft/trash'import XIcon from '@master/icons-react/native/16/soft/x'<div className="toolbar toolbar-floating flex-wrap justify-center" role="toolbar" aria-label="2 projects selected">  <span className="px-xs fg-text-strong">2 selected</span>  <span className="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" className="btn btn-quiet btn-sm">    <RocketIcon className="icon" />Redeploy  </button>  <button type="button" className="btn btn-quiet btn-sm">    <DownloadIcon className="icon" />Export  </button>  <button type="button" className="btn btn-quiet btn-sm btn-danger">    <TrashIcon className="icon" />Delete  </button>  <span className="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Clear the selection">    <XIcon className="icon" />  </button></div>
<script>  import RocketIcon from '@master/icons-svelte/native/16/soft/rocket'  import DownloadIcon from '@master/icons-svelte/native/16/soft/download'  import TrashIcon from '@master/icons-svelte/native/16/soft/trash'  import XIcon from '@master/icons-svelte/native/16/soft/x'</script><div class="toolbar toolbar-floating flex-wrap justify-center" role="toolbar" aria-label="2 projects selected">  <span class="px-xs fg-text-strong">2 selected</span>  <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-sm"><RocketIcon class="icon" />Redeploy</button>  <button type="button" class="btn btn-quiet btn-sm"><DownloadIcon class="icon" />Export</button>  <button type="button" class="btn btn-quiet btn-sm btn-danger">    <TrashIcon class="icon" />Delete  </button>  <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>  <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Clear the selection">    <XIcon class="icon" />  </button></div>
<script setup>import RocketIcon from '@master/icons-vue/native/16/soft/rocket'import DownloadIcon from '@master/icons-vue/native/16/soft/download'import TrashIcon from '@master/icons-vue/native/16/soft/trash'import XIcon from '@master/icons-vue/native/16/soft/x'</script><template>  <div class="toolbar toolbar-floating flex-wrap justify-center" role="toolbar" aria-label="2 projects selected">    <span class="px-xs fg-text-strong">2 selected</span>    <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>    <button type="button" class="btn btn-quiet btn-sm"><RocketIcon class="icon" />Redeploy</button>    <button type="button" class="btn btn-quiet btn-sm"><DownloadIcon class="icon" />Export</button>    <button type="button" class="btn btn-quiet btn-sm btn-danger">      <TrashIcon class="icon" />Delete    </button>    <span class="toolbar-separator" role="separator" aria-orientation="vertical"></span>    <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Clear the selection">      <XIcon class="icon" />    </button>  </div></template>

#無障礙

  • 面板使用 <section>,並以其標題作為名稱,表格也以同一個標題命名。
  • 每個核取方塊的名稱都要包含所屬的列,例如「選取 Atlas」。表頭核取方塊的名稱要說明它選取的範圍,例如「選取全部 15 個專案」。
  • 標題下方的計數是一般文字;另有一個以 sr-only 隱藏的狀態區域,說明操作的結果,例如「第 2 頁,共 3 頁」或「已刪除 3 個專案」。焦點會留在剛按下的元素上;若它所在的資料列已不存在,焦點會移到表頭的核取方塊。
  • 操作欄有一個供輔助技術讀取的標題,在畫面上隱藏。
  • 分頁導覽使用帶有標籤的 <nav>;由於各頁會就地切換檢視內容,頁碼使用按鈕,目前頁面帶有 aria-current="page"。
  • 每列的第一個儲存格使用 <th scope="row">,讓輔助技術讀取儲存格時一併讀出所屬的專案、成員或檔案。
  • 篩選條件在名為「篩選專案」的彈出面板中開啟;篩選列說明了其中各列與訊息的朗讀方式。
  • 表格可在捲動區域內水平捲動。鍵盤使用者可以透過其中的核取方塊和按鈕進入捲動區域。如果表格內沒有可取得焦點的元素,請在捲動區域上設定 tabindex="0",並提供角色與名稱。