網站導覽

v2.1.0
應用程式區塊

空狀態區塊

檢視畫面還沒有內容時該顯示什麼,以及如何引導使用者開始。

檢視畫面還沒有內容可顯示時,就會呈現空狀態。這是最小的區塊,在空狀態元件內放入合適的文字即可。重點在文案,要說清楚這裡會放什麼、為什麼目前是空的,以及下一步可以做什麼。

空狀態

<section class="sheet container-inline" aria-labelledby="es-title">  <div class="empty">    <div class="icon-frame empty-media" aria-hidden="true">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M2.5 15.25L2.5 5.25A1.25 1.25 0 0 1 3.75 4L7.9822 4A1.25 1.25 0 0 1 8.8661 4.3661L10.1339 5.6339A1.25 1.25 0 0 0 11.0178 6L16.25 6A1.25 1.25 0 0 1 17.5 7.25L17.5 15.25A1.25 1.25 0 0 1 16.25 16.5L3.75 16.5A1.25 1.25 0 0 1 2.5 15.25Z" />      </svg>    </div>    <h2 class="empty-title" id="es-title">No projects yet</h2>    <p class="empty-description">      A project connects a repository to an address. Create one, and every push becomes a deployment.    </p>    <div class="empty-actions">      <a class="btn btn-sm" href="#">Read the guide</a>      <button type="button" class="btn btn-sm btn-primary">        <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>New project      </button>    </div>  </div></section>
import FolderIcon from '@master/icons-react/native/20/soft/folder'import PlusIcon from '@master/icons-react/native/16/soft/plus'<section className="sheet container-inline" aria-labelledby="es-title">  <div className="empty">    <div className="icon-frame empty-media" aria-hidden="true"><FolderIcon className="icon" /></div>    <h2 className="empty-title" id="es-title">No projects yet</h2>    <p className="empty-description">      A project connects a repository to an address. Create one, and every push becomes a deployment.    </p>    <div className="empty-actions">      <a className="btn btn-sm" href="#">Read the guide</a>      <button type="button" className="btn btn-sm btn-primary">        <PlusIcon className="icon" />New project      </button>    </div>  </div></section>
<script>  import FolderIcon from '@master/icons-svelte/native/20/soft/folder'  import PlusIcon from '@master/icons-svelte/native/16/soft/plus'</script><section class="sheet container-inline" aria-labelledby="es-title">  <div class="empty">    <div class="icon-frame empty-media" aria-hidden="true"><FolderIcon class="icon" /></div>    <h2 class="empty-title" id="es-title">No projects yet</h2>    <p class="empty-description">      A project connects a repository to an address. Create one, and every push becomes a deployment.    </p>    <div class="empty-actions">      <a class="btn btn-sm" href="#">Read the guide</a>      <button type="button" class="btn btn-sm btn-primary">        <PlusIcon class="icon" />New project      </button>    </div>  </div></section>
<script setup>import FolderIcon from '@master/icons-vue/native/20/soft/folder'import PlusIcon from '@master/icons-vue/native/16/soft/plus'</script><template>  <section class="sheet container-inline" aria-labelledby="es-title">    <div class="empty">      <div class="icon-frame empty-media" aria-hidden="true"><FolderIcon class="icon" /></div>      <h2 class="empty-title" id="es-title">No projects yet</h2>      <p class="empty-description">        A project connects a repository to an address. Create one, and every push becomes a deployment.      </p>      <div class="empty-actions">        <a class="btn btn-sm" href="#">Read the guide</a>        <button type="button" class="btn btn-sm btn-primary">          <PlusIcon class="icon" />New project        </button>      </div>    </div>  </section></template>

區塊提供可直接複製的標記,沿用頁面的文字顏色和大小。預覽在 body 上設定 fg-text-body text-sm。每個區塊都是尺寸查詢容器,因此無論放在寬版頁面、側邊欄或對話框,都會依自身寬度調整版面配置。

#四種情況

檢視畫面可能因四種原因而沒有內容,每種情況都需要不同的文案。

類型說明什麼提供什麼
尚無內容這裡會放什麼,以及用途為何建立第一筆內容的操作
首次使用取得第一個成果所需的幾個步驟下一步操作
沒有結果搜尋了什麼,以及哪些篩選條件仍在套用放寬搜尋條件的方法
發生錯誤用白話說明發生什麼事,以及問題出在哪一方在提示訊息中提供重試方式

上方展示第一種情況,下方依序展示其餘三種。

#首次使用

使用者初次開啟產品時,用入門引導取代空白畫面。將步驟垂直排列,每個步驟用一句話說明,並用主要按鈕引導使用者前往下一步。已完成的步驟顯示為完成,目前所在的步驟則以 aria-current="step" 標記。

首次使用

<section class="sheet container-inline flex flex-col gap-lg p-xl max-w(560) mx-auto" aria-labelledby="es-steps-title">  <header class="flex flex-col gap-xs">    <h2 class="heading heading-lg" id="es-steps-title">Deploy your first project</h2>    <p class="m(0) leading-md">Three steps, about two minutes. You can stop after any of them.</p>  </header>  <ol class="steps steps-vertical">    <li class="steps-item">      <div class="steps-body">        <span class="steps-title">Connect a repository</span>        <span class="steps-description">Signed in with GitHub as yiching.</span>      </div>    </li>    <li class="steps-item" aria-current="step">      <div class="steps-body">        <span class="steps-title">Choose what to build</span>        <span class="steps-description">          Pick a repository and a branch. We detect the framework.        </span>      </div>    </li>    <li class="steps-item">      <div class="steps-body">        <span class="steps-title">Go live</span>        <span class="steps-description">Your site gets an address in under a minute.</span>      </div>    </li>  </ol>  <div class="flex flex-wrap gap-xs">    <button type="button" class="btn btn-primary">Choose a repository</button>    <button type="button" class="btn btn-quiet">Deploy an example instead</button>  </div></section>
<section className="sheet container-inline flex flex-col gap-lg p-xl max-w(560) mx-auto" aria-labelledby="es-steps-title">  <header className="flex flex-col gap-xs">    <h2 className="heading heading-lg" id="es-steps-title">Deploy your first project</h2>    <p className="m(0) leading-md">      Three steps, about two minutes. You can stop after any of them.    </p>  </header>  <ol className="steps steps-vertical">    <li className="steps-item">      <div className="steps-body">        <span className="steps-title">Connect a repository</span>        <span className="steps-description">Signed in with GitHub as yiching.</span>      </div>    </li>    <li className="steps-item" aria-current="step">      <div className="steps-body">        <span className="steps-title">Choose what to build</span>        <span className="steps-description">          Pick a repository and a branch. We detect the framework.        </span>      </div>    </li>    <li className="steps-item">      <div className="steps-body">        <span className="steps-title">Go live</span>        <span className="steps-description">Your site gets an address in under a minute.</span>      </div>    </li>  </ol>  <div className="flex flex-wrap gap-xs">    <button type="button" className="btn btn-primary">Choose a repository</button>    <button type="button" className="btn btn-quiet">Deploy an example instead</button>  </div></section>
<section class="sheet container-inline flex flex-col gap-lg p-xl max-w(560) mx-auto" aria-labelledby="es-steps-title">  <header class="flex flex-col gap-xs">    <h2 class="heading heading-lg" id="es-steps-title">Deploy your first project</h2>    <p class="m(0) leading-md">Three steps, about two minutes. You can stop after any of them.</p>  </header>  <ol class="steps steps-vertical">    <li class="steps-item">      <div class="steps-body">        <span class="steps-title">Connect a repository</span>        <span class="steps-description">Signed in with GitHub as yiching.</span>      </div>    </li>    <li class="steps-item" aria-current="step">      <div class="steps-body">        <span class="steps-title">Choose what to build</span>        <span class="steps-description">          Pick a repository and a branch. We detect the framework.        </span>      </div>    </li>    <li class="steps-item">      <div class="steps-body">        <span class="steps-title">Go live</span>        <span class="steps-description">Your site gets an address in under a minute.</span>      </div>    </li>  </ol>  <div class="flex flex-wrap gap-xs">    <button type="button" class="btn btn-primary">Choose a repository</button>    <button type="button" class="btn btn-quiet">Deploy an example instead</button>  </div></section>
<template>  <section class="sheet container-inline flex flex-col gap-lg p-xl max-w(560) mx-auto" aria-labelledby="es-steps-title">    <header class="flex flex-col gap-xs">      <h2 class="heading heading-lg" id="es-steps-title">Deploy your first project</h2>      <p class="m(0) leading-md">Three steps, about two minutes. You can stop after any of them.</p>    </header>    <ol class="steps steps-vertical">      <li class="steps-item">        <div class="steps-body">          <span class="steps-title">Connect a repository</span>          <span class="steps-description">Signed in with GitHub as yiching.</span>        </div>      </li>      <li class="steps-item" aria-current="step">        <div class="steps-body">          <span class="steps-title">Choose what to build</span>          <span class="steps-description">            Pick a repository and a branch. We detect the framework.          </span>        </div>      </li>      <li class="steps-item">        <div class="steps-body">          <span class="steps-title">Go live</span>          <span class="steps-description">Your site gets an address in under a minute.</span>        </div>      </li>    </ol>    <div class="flex flex-wrap gap-xs">      <button type="button" class="btn btn-primary">Choose a repository</button>      <button type="button" class="btn btn-quiet">Deploy an example instead</button>    </div>  </section></template>

#沒有結果

搜尋或篩選後若沒有任何結果,請原樣顯示搜尋字詞,即使有錯字也要保留,並指出哪些篩選條件仍在套用。使用者如果看不出清單為什麼是空的,可能會以為資料不見了。

沒有結果

<section class="sheet container-inline" aria-live="polite" aria-labelledby="es-none-title">  <div class="empty">    <div class="icon-frame empty-media" aria-hidden="true">      <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <circle cx="8.75" cy="8.75" r="5.75" /><path d="M12.8159 12.8159L17.5 17.5" />      </svg>    </div>    <h2 class="empty-title" id="es-none-title">No projects match “drfit”</h2>    <p class="empty-description">      Check the spelling, or search all workspaces. Filters are still applied: Ready, Tokyo.    </p>    <div class="empty-actions">      <button type="button" class="btn btn-sm">Clear filters</button>      <button type="button" class="btn btn-sm">Search all workspaces</button>    </div>  </div></section>
import SearchIcon from '@master/icons-react/native/20/soft/search'<section className="sheet container-inline" aria-live="polite" aria-labelledby="es-none-title">  <div className="empty">    <div className="icon-frame empty-media" aria-hidden="true"><SearchIcon className="icon" /></div>    <h2 className="empty-title" id="es-none-title">No projects match “drfit”</h2>    <p className="empty-description">      Check the spelling, or search all workspaces. Filters are still applied: Ready, Tokyo.    </p>    <div className="empty-actions">      <button type="button" className="btn btn-sm">Clear filters</button>      <button type="button" className="btn btn-sm">Search all workspaces</button>    </div>  </div></section>
<script>  import SearchIcon from '@master/icons-svelte/native/20/soft/search'</script><section class="sheet container-inline" aria-live="polite" aria-labelledby="es-none-title">  <div class="empty">    <div class="icon-frame empty-media" aria-hidden="true"><SearchIcon class="icon" /></div>    <h2 class="empty-title" id="es-none-title">No projects match “drfit”</h2>    <p class="empty-description">      Check the spelling, or search all workspaces. Filters are still applied: Ready, Tokyo.    </p>    <div class="empty-actions">      <button type="button" class="btn btn-sm">Clear filters</button>      <button type="button" class="btn btn-sm">Search all workspaces</button>    </div>  </div></section>
<script setup>import SearchIcon from '@master/icons-vue/native/20/soft/search'</script><template>  <section class="sheet container-inline" aria-live="polite" aria-labelledby="es-none-title">    <div class="empty">      <div class="icon-frame empty-media" aria-hidden="true"><SearchIcon class="icon" /></div>      <h2 class="empty-title" id="es-none-title">No projects match “drfit”</h2>      <p class="empty-description">        Check the spelling, or search all workspaces. Filters are still applied: Ready, Tokyo.      </p>      <div class="empty-actions">        <button type="button" class="btn btn-sm">Clear filters</button>        <button type="button" class="btn btn-sm">Search all workspaces</button>      </div>    </div>  </section></template>

這個區域設有 aria-live="polite",因此從有結果變成沒有結果時,輔助技術會等使用者停止輸入後再播報。

#發生錯誤

失敗時顯示提示訊息,位置與空狀態相同,但用途不同。用狀態色和圖示提示有異常,用文字說明發生了什麼,再提供一個按鈕讓使用者繼續。若使用者的工作成果確實有保留,就明確告知。這個區段沿用發生錯誤的檢視畫面名稱,讓使用者仍能透過地標找到它。

發生錯誤

<section class="container-inline" aria-label="Projects">  <div class="alert alert-danger" role="alert">    <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">      <circle cx="8" cy="8" r="6" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" /><path d="M8 8L8 11" />    </svg>    <div class="alert-body">      <p class="alert-title">We could not load your projects</p>      <p class="alert-description">        The request timed out. Your projects are safe; this is on our side. <a class="link" href="#">Check the status page</a>.      </p>    </div>    <button type="button" class="btn btn-sm">Try again</button>  </div></section>
import InfoCircleIcon from '@master/icons-react/native/16/soft/info-circle'<section className="container-inline" aria-label="Projects">  <div className="alert alert-danger" role="alert">    <InfoCircleIcon className="icon alert-icon" />    <div className="alert-body">      <p className="alert-title">We could not load your projects</p>      <p className="alert-description">        The request timed out. Your projects are safe; this is on our side. <a className="link" href="#">Check the status page</a>.      </p>    </div>    <button type="button" className="btn btn-sm">Try again</button>  </div></section>
<script>  import InfoCircleIcon from '@master/icons-svelte/native/16/soft/info-circle'</script><section class="container-inline" aria-label="Projects">  <div class="alert alert-danger" role="alert">    <InfoCircleIcon class="icon alert-icon" />    <div class="alert-body">      <p class="alert-title">We could not load your projects</p>      <p class="alert-description">        The request timed out. Your projects are safe; this is on our side. <a class="link" href="#">Check the status page</a>.      </p>    </div>    <button type="button" class="btn btn-sm">Try again</button>  </div></section>
<script setup>import InfoCircleIcon from '@master/icons-vue/native/16/soft/info-circle'</script><template>  <section class="container-inline" aria-label="Projects">    <div class="alert alert-danger" role="alert">      <InfoCircleIcon class="icon alert-icon" />      <div class="alert-body">        <p class="alert-title">We could not load your projects</p>        <p class="alert-description">          The request timed out. Your projects are safe; this is on our side. <a class="link" href="#">Check the status page</a>.        </p>      </div>      <button type="button" class="btn btn-sm">Try again</button>    </div>  </section></template>

#無障礙

  • 空狀態的標題應與被取代的檢視畫面標題同級。
  • 因操作而出現的空狀態需要讓輔助技術播報。沒有結果時使用 aria-live="polite",發生錯誤時使用 role="alert"。
  • 圖示僅供裝飾。請用文字說明是哪種情況,不可依賴圖示或顏色來區分。
  • 「閱讀指南」會前往另一處,使用呈現為按鈕的連結。「新增專案」會執行操作,使用按鈕。
  • 沿用完整檢視畫面中的主要操作,讓使用者只需要學一次。