網站導覽

v2.1.0
表單

清單方塊

供使用者選擇的清單,也是組合方塊與指令面板展開時顯示的介面。

本頁內容

清單方塊列出可供選擇的項目。它是組合方塊和指令面板展開時顯示的介面,也能獨立放在頁面上。樣式表根據 ARIA 屬性呈現各種狀態,腳本則處理按鍵操作,並更新屬性以標示目前作用中的選項與已選取的值。獨立的清單方塊由 listbox 行為控制,組合方塊和指令面板則各自由自己的輸入欄位控制清單。

清單方塊

<div class="sheet sheet-flat max-w(320) mx-auto">  <div class="listbox" role="listbox" aria-label="Framework" tabindex="0" aria-activedescendant="fw-astro">    <div class="listbox-option" role="option" id="fw-astro" aria-selected="true" aria-checked="true">      Astro    </div>    <div class="listbox-option" role="option" id="fw-next" aria-checked="false">Next.js</div>    <div class="listbox-option" role="option" id="fw-svelte" aria-checked="false">SvelteKit</div>    <div class="listbox-option" role="option" id="fw-nuxt" aria-checked="false" aria-disabled="true">      Nuxt    </div>  </div></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="sheet sheet-flat max-w(320) mx-auto">      <div className="listbox" role="listbox" aria-label="Framework" tabIndex={0} aria-activedescendant="fw-astro">        <div className="listbox-option" role="option" id="fw-astro" aria-selected="true" aria-checked="true">          Astro        </div>        <div className="listbox-option" role="option" id="fw-next" aria-checked="false">Next.js</div>        <div className="listbox-option" role="option" id="fw-svelte" aria-checked="false">          SvelteKit        </div>        <div className="listbox-option" role="option" id="fw-nuxt" aria-checked="false" aria-disabled="true">          Nuxt        </div>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="sheet sheet-flat max-w(320) mx-auto" {@attach attach}>  <div class="listbox" role="listbox" aria-label="Framework" tabindex="0" aria-activedescendant="fw-astro">    <div class="listbox-option" role="option" id="fw-astro" aria-selected="true" aria-checked="true">      Astro    </div>    <div class="listbox-option" role="option" id="fw-next" aria-checked="false">Next.js</div>    <div class="listbox-option" role="option" id="fw-svelte" aria-checked="false">SvelteKit</div>    <div class="listbox-option" role="option" id="fw-nuxt" aria-checked="false" aria-disabled="true">      Nuxt    </div>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="sheet sheet-flat max-w(320) mx-auto">    <div class="listbox" role="listbox" aria-label="Framework" tabindex="0" aria-activedescendant="fw-astro">      <div class="listbox-option" role="option" id="fw-astro" aria-selected="true" aria-checked="true">        Astro      </div>      <div class="listbox-option" role="option" id="fw-next" aria-checked="false">Next.js</div>      <div class="listbox-option" role="option" id="fw-svelte" aria-checked="false">SvelteKit</div>      <div class="listbox-option" role="option" id="fw-nuxt" aria-checked="false" aria-disabled="true">        Nuxt      </div>    </div>  </div></template>
點選選項,或將焦點移到清單,用方向鍵移動,再按 Enter 或空白鍵選取。

#兩種狀態,兩個屬性

清單方塊會區分鍵盤目前指向的選項與已選取的值。

  • 作用中使用 aria-selected="true",表示方向鍵目前移到的選項,也是按 Enter 時會選取的選項。該列會套用膠囊標籤的色調。指標移到某一列上方時,該列也會立即套用相同色調,沒有淡入效果。
  • 已選取使用 aria-checked="true",表示該值已設定,選項末端會顯示勾號。只要選項有 aria-checked,無論值為何,都會保留勾號的空間,讓標籤維持在原位。

焦點通常留在清單或文字欄位上,由 aria-activedescendant 指定作用中的選項。若選項本身取得焦點,還會顯示一道文字色的外框。

#含圖示與說明的選項

在列首的圖示上加上 icon。listbox-body 將標題放在 listbox-description 上方,listbox-end 則在列尾放置快速鍵或提示。用 listbox-group 包住一組選項及其 listbox-label,再用 listbox-separator 在群組之間加上分隔線。

含圖示與說明的選項

<div class="sheet sheet-flat max-w(360) mx-auto">  <div class="listbox" role="listbox" aria-label="Commands">    <div class="listbox-group" role="group" aria-labelledby="rich-suggestions">      <div class="listbox-label" id="rich-suggestions">Suggestions</div>      <div class="listbox-option" role="option" aria-selected="true">        <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 <span class="listbox-end"><kbd class="kbd">⌘</kbd><kbd class="kbd">N</kbd></span>      </div>      <div class="listbox-option" role="option">        <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>        <span class="listbox-body">          <span>Search deployments</span>          <span class="listbox-description">By branch, commit or author</span>        </span>      </div>    </div>    <hr class="listbox-separator">    <div class="listbox-group" role="group" aria-labelledby="rich-team">      <div class="listbox-label" id="rich-team">Team</div>      <div class="listbox-option" role="option">        <span class="avatar avatar-xs">          <img class="avatar-image" src="/demo/portrait-1.svg" alt>        </span> Ada Lovelace      </div>      <div class="listbox-option" role="option">        <span class="avatar avatar-xs">          <img class="avatar-image" src="/demo/portrait-2.svg" alt>        </span> Alan Turing      </div>    </div>  </div></div>
import PlusIcon from '@master/icons-react/native/16/soft/plus'import SearchIcon from '@master/icons-react/native/16/soft/search'<div className="sheet sheet-flat max-w(360) mx-auto">  <div className="listbox" role="listbox" aria-label="Commands">    <div className="listbox-group" role="group" aria-labelledby="rich-suggestions">      <div className="listbox-label" id="rich-suggestions">Suggestions</div>      <div className="listbox-option" role="option" aria-selected="true">        <PlusIcon className="icon" /> New project <span className="listbox-end">          <kbd className="kbd">⌘</kbd><kbd className="kbd">N</kbd>        </span>      </div>      <div className="listbox-option" role="option">        <SearchIcon className="icon" />        <span className="listbox-body">          <span>Search deployments</span>          <span className="listbox-description">By branch, commit or author</span>        </span>      </div>    </div>    <hr className="listbox-separator" />    <div className="listbox-group" role="group" aria-labelledby="rich-team">      <div className="listbox-label" id="rich-team">Team</div>      <div className="listbox-option" role="option">        <span className="avatar avatar-xs">          <img className="avatar-image" src="/demo/portrait-1.svg" alt="" />        </span> Ada Lovelace      </div>      <div className="listbox-option" role="option">        <span className="avatar avatar-xs">          <img className="avatar-image" src="/demo/portrait-2.svg" alt="" />        </span> Alan Turing      </div>    </div>  </div></div>
<script>  import PlusIcon from '@master/icons-svelte/native/16/soft/plus'  import SearchIcon from '@master/icons-svelte/native/16/soft/search'</script><div class="sheet sheet-flat max-w(360) mx-auto">  <div class="listbox" role="listbox" aria-label="Commands">    <div class="listbox-group" role="group" aria-labelledby="rich-suggestions">      <div class="listbox-label" id="rich-suggestions">Suggestions</div>      <div class="listbox-option" role="option" aria-selected="true">        <PlusIcon class="icon" /> New project <span class="listbox-end"><kbd class="kbd">⌘</kbd><kbd class="kbd">N</kbd></span>      </div>      <div class="listbox-option" role="option">        <SearchIcon class="icon" />        <span class="listbox-body">          <span>Search deployments</span>          <span class="listbox-description">By branch, commit or author</span>        </span>      </div>    </div>    <hr class="listbox-separator">    <div class="listbox-group" role="group" aria-labelledby="rich-team">      <div class="listbox-label" id="rich-team">Team</div>      <div class="listbox-option" role="option">        <span class="avatar avatar-xs">          <img class="avatar-image" src="/demo/portrait-1.svg" alt>        </span> Ada Lovelace      </div>      <div class="listbox-option" role="option">        <span class="avatar avatar-xs">          <img class="avatar-image" src="/demo/portrait-2.svg" alt>        </span> Alan Turing      </div>    </div>  </div></div>
<script setup>import PlusIcon from '@master/icons-vue/native/16/soft/plus'import SearchIcon from '@master/icons-vue/native/16/soft/search'</script><template>  <div class="sheet sheet-flat max-w(360) mx-auto">    <div class="listbox" role="listbox" aria-label="Commands">      <div class="listbox-group" role="group" aria-labelledby="rich-suggestions">        <div class="listbox-label" id="rich-suggestions">Suggestions</div>        <div class="listbox-option" role="option" aria-selected="true">          <PlusIcon class="icon" /> New project <span class="listbox-end"><kbd class="kbd">⌘</kbd><kbd class="kbd">N</kbd></span>        </div>        <div class="listbox-option" role="option">          <SearchIcon class="icon" />          <span class="listbox-body">            <span>Search deployments</span>            <span class="listbox-description">By branch, commit or author</span>          </span>        </div>      </div>      <hr class="listbox-separator">      <div class="listbox-group" role="group" aria-labelledby="rich-team">        <div class="listbox-label" id="rich-team">Team</div>        <div class="listbox-option" role="option">          <span class="avatar avatar-xs">            <img class="avatar-image" src="/demo/portrait-1.svg" alt>          </span> Ada Lovelace        </div>        <div class="listbox-option" role="option">          <span class="avatar avatar-xs">            <img class="avatar-image" src="/demo/portrait-2.svg" alt>          </span> Alan Turing        </div>      </div>    </div>  </div></template>

#搜尋結果

搜尋結果要說明它的位置和符合的內容。listbox-path 是標題下方的一行小字,每一層各用一個 listbox-crumb;listbox-excerpt 是符合搜尋的段落,最多兩行。把輸入的文字包在 mark 裡:在選項中它會採用標題的文字色和字重,所以在淡色的文字行中也找得到。

搜尋結果

<div class="sheet sheet-flat max-w(420) mx-auto">  <div class="listbox" role="listbox" aria-label="Results">    <div class="listbox-option" role="option" aria-selected="true">      <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 5.75L13.5 5.75" /><path d="M2.5 10.25L13.5 10.25" /><path d="M6.5 2.5L4.5 13.5" /><path d="M11.5 2.5L9.5 13.5" />      </svg>      <span class="listbox-body">        <span>Retune <mark class="mark">token</mark>s</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span><span class="listbox-crumb">Theming</span>        </span>        <span class="listbox-excerpt">          Override a <mark class="mark">token</mark> after the import. Every component that reads it follows.        </span>      </span>    </div>    <div class="listbox-option" role="option">      <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.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 class="listbox-body">        <span>Default theme</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>        </span>        <span class="listbox-excerpt">          Moonstone and obsidian: the default materials, <mark class="mark">token</mark> roles and implementation values in Master UI.        </span>      </span>    </div>    <div class="listbox-option" role="option">      <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.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 class="listbox-body">        <span>Customization</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>        </span>      </span>    </div>  </div></div>
import HashIcon from '@master/icons-react/native/16/soft/hash'import FileIcon from '@master/icons-react/native/16/soft/file'<div className="sheet sheet-flat max-w(420) mx-auto">  <div className="listbox" role="listbox" aria-label="Results">    <div className="listbox-option" role="option" aria-selected="true">      <HashIcon className="icon" />      <span className="listbox-body">        <span>Retune <mark className="mark">token</mark>s</span>        <span className="listbox-path">          <span className="listbox-crumb">Guide</span><span className="listbox-crumb">Customizing</span><span className="listbox-crumb">Theming</span>        </span>        <span className="listbox-excerpt">          Override a <mark className="mark">token</mark> after the import. Every component that reads it follows.        </span>      </span>    </div>    <div className="listbox-option" role="option">      <FileIcon className="icon" />      <span className="listbox-body">        <span>Default theme</span>        <span className="listbox-path">          <span className="listbox-crumb">Guide</span><span className="listbox-crumb">Customizing</span>        </span>        <span className="listbox-excerpt">          Moonstone and obsidian: the default materials, <mark className="mark">token</mark> roles and implementation values in Master UI.        </span>      </span>    </div>    <div className="listbox-option" role="option">      <FileIcon className="icon" />      <span className="listbox-body">        <span>Customization</span>        <span className="listbox-path">          <span className="listbox-crumb">Guide</span><span className="listbox-crumb">Customizing</span>        </span>      </span>    </div>  </div></div>
<script>  import HashIcon from '@master/icons-svelte/native/16/soft/hash'  import FileIcon from '@master/icons-svelte/native/16/soft/file'</script><div class="sheet sheet-flat max-w(420) mx-auto">  <div class="listbox" role="listbox" aria-label="Results">    <div class="listbox-option" role="option" aria-selected="true">      <HashIcon class="icon" />      <span class="listbox-body">        <span>Retune <mark class="mark">token</mark>s</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span><span class="listbox-crumb">Theming</span>        </span>        <span class="listbox-excerpt">          Override a <mark class="mark">token</mark> after the import. Every component that reads it follows.        </span>      </span>    </div>    <div class="listbox-option" role="option">      <FileIcon class="icon" />      <span class="listbox-body">        <span>Default theme</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>        </span>        <span class="listbox-excerpt">          Moonstone and obsidian: the default materials, <mark class="mark">token</mark> roles and implementation values in Master UI.        </span>      </span>    </div>    <div class="listbox-option" role="option">      <FileIcon class="icon" />      <span class="listbox-body">        <span>Customization</span>        <span class="listbox-path">          <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>        </span>      </span>    </div>  </div></div>
<script setup>import HashIcon from '@master/icons-vue/native/16/soft/hash'import FileIcon from '@master/icons-vue/native/16/soft/file'</script><template>  <div class="sheet sheet-flat max-w(420) mx-auto">    <div class="listbox" role="listbox" aria-label="Results">      <div class="listbox-option" role="option" aria-selected="true">        <HashIcon class="icon" />        <span class="listbox-body">          <span>Retune <mark class="mark">token</mark>s</span>          <span class="listbox-path">            <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span><span class="listbox-crumb">Theming</span>          </span>          <span class="listbox-excerpt">            Override a <mark class="mark">token</mark> after the import. Every component that reads it follows.          </span>        </span>      </div>      <div class="listbox-option" role="option">        <FileIcon class="icon" />        <span class="listbox-body">          <span>Default theme</span>          <span class="listbox-path">            <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>          </span>          <span class="listbox-excerpt">            Moonstone and obsidian: the default materials, <mark class="mark">token</mark> roles and implementation values in Master UI.          </span>        </span>      </div>      <div class="listbox-option" role="option">        <FileIcon class="icon" />        <span class="listbox-body">          <span>Customization</span>          <span class="listbox-path">            <span class="listbox-crumb">Guide</span><span class="listbox-crumb">Customizing</span>          </span>        </span>      </div>    </div>  </div></template>
  • 圖示一律對齊標題那一行,不論下方是路徑、說明或摘錄。標題搭配路徑或說明時仍是一列,所以 listbox-end 會對齊這兩行的中央;摘錄會讓文字高過一列,這時 listbox-end 也改為對齊標題。
  • 路徑的各層是文字。一個選項只有一個目標,所以它們不是麵包屑導覽的連結。
  • 只要有一個結果帶圖示,就讓每個結果都有圖示:頁面用文件圖示,頁面內的標題用井字號,即可涵蓋沒有專屬圖示的結果。

#篩選

腳本會在不符合條件的選項上設定 hidden 屬性。接著,:has() 會自動處理下列兩種情況,無須額外的腳本。

  • 所有選項都隱藏時,listbox-empty 就會顯示。只要有選項重新出現,它就會隱藏。
  • listbox-group 是包住群組標題及其選項的 role="group" 元素。當群組內的選項全數隱藏時,整個群組也會隱藏,避免只剩標題。

沒有相符的選項

<div class="sheet sheet-flat max-w(320) mx-auto">  <div class="listbox" role="listbox" aria-label="Regions">    <div class="listbox-option" role="option" hidden>Tokyo</div>    <div class="listbox-option" role="option" hidden>Frankfurt</div>    <div class="listbox-empty">No regions match "zz".</div>  </div></div>
<div className="sheet sheet-flat max-w(320) mx-auto">  <div className="listbox" role="listbox" aria-label="Regions">    <div className="listbox-option" role="option" hidden>Tokyo</div>    <div className="listbox-option" role="option" hidden>Frankfurt</div>    <div className="listbox-empty">No regions match "zz".</div>  </div></div>
<div class="sheet sheet-flat max-w(320) mx-auto">  <div class="listbox" role="listbox" aria-label="Regions">    <div class="listbox-option" role="option" hidden>Tokyo</div>    <div class="listbox-option" role="option" hidden>Frankfurt</div>    <div class="listbox-empty">No regions match "zz".</div>  </div></div>
<template>  <div class="sheet sheet-flat max-w(320) mx-auto">    <div class="listbox" role="listbox" aria-label="Regions">      <div class="listbox-option" role="option" hidden>Tokyo</div>      <div class="listbox-option" role="option" hidden>Frankfurt</div>      <div class="listbox-empty">No regions match "zz".</div>    </div>  </div></template>

#行為

listbox 控制獨立放在頁面上、由清單本身保有焦點的清單方塊,因此清單需要 tabindex="0"。它接收帶有 role="listbox" 的元素,不接受設定選項,並傳回用來解除行為的函式。

app.js
import { listbox } from '@master/ui/behaviors/listbox.js'const list = document.querySelector('.listbox')listbox(list)list.addEventListener('change', () => {  const chosen = list.querySelectorAll('[aria-checked="true"]')})
  • 作用中的選項。 按鍵或點擊會將 aria-selected="true" 移到對應的選項,更新清單上的 aria-activedescendant,再捲動清單,讓該選項進入可見範圍。焦點始終留在清單上。缺少 id 的選項會自動取得一個。清單取得焦點時,若沒有作用中的選項,已選取的選項就會成為作用中的選項。若也沒有已選取的選項,則由第一個選項成為作用中的選項。
  • 選取。 按 Enter、Space 或點擊時,該選項會設為 aria-checked="true",其餘選項則設為 false。
  • 事件。 選取結果每次變更時,清單會依序派送 input 和 change 事件。讀取帶有 aria-checked="true" 的選項即可取得選取結果。
  • 略過的選項。 隱藏的選項和帶有 aria-disabled="true" 的選項都無法成為作用中的選項,也無法選取。

在清單上設定 aria-multiselectable="true" 後,每個選項都可獨立勾選或取消勾選,其餘選項會維持原狀。按鍵也能像檔案清單一樣選取一段連續的選項:最後選取的選項是錨點,按住 Shift 再按方向鍵、Space 或點擊,就會勾選從錨點到鍵盤或指標目前指向的選項為止的所有選項,包含兩端。按 Control 或 Command 加 A 會勾選所有選項;若已全部勾選,則全部取消勾選。

多選

<div class="sheet sheet-flat max-w(320) mx-auto">  <div class="listbox" role="listbox" aria-label="Notify me about" aria-multiselectable="true" tabindex="0">    <div class="listbox-option" role="option" id="notify-deploys" aria-checked="true">      Deployments    </div>    <div class="listbox-option" role="option" id="notify-comments" aria-checked="false">      Comments    </div>    <div class="listbox-option" role="option" id="notify-billing" aria-checked="true">Billing</div>    <div class="listbox-option" role="option" id="notify-mentions" aria-checked="false">      Mentions    </div>    <div class="listbox-option" role="option" id="notify-digest" aria-checked="false" aria-disabled="true">      Weekly digest    </div>  </div></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="sheet sheet-flat max-w(320) mx-auto">      <div className="listbox" role="listbox" aria-label="Notify me about" aria-multiselectable="true" tabIndex={0}>        <div className="listbox-option" role="option" id="notify-deploys" aria-checked="true">          Deployments        </div>        <div className="listbox-option" role="option" id="notify-comments" aria-checked="false">          Comments        </div>        <div className="listbox-option" role="option" id="notify-billing" aria-checked="true">          Billing        </div>        <div className="listbox-option" role="option" id="notify-mentions" aria-checked="false">          Mentions        </div>        <div className="listbox-option" role="option" id="notify-digest" aria-checked="false" aria-disabled="true">          Weekly digest        </div>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="sheet sheet-flat max-w(320) mx-auto" {@attach attach}>  <div class="listbox" role="listbox" aria-label="Notify me about" aria-multiselectable="true" tabindex="0">    <div class="listbox-option" role="option" id="notify-deploys" aria-checked="true">      Deployments    </div>    <div class="listbox-option" role="option" id="notify-comments" aria-checked="false">      Comments    </div>    <div class="listbox-option" role="option" id="notify-billing" aria-checked="true">Billing</div>    <div class="listbox-option" role="option" id="notify-mentions" aria-checked="false">      Mentions    </div>    <div class="listbox-option" role="option" id="notify-digest" aria-checked="false" aria-disabled="true">      Weekly digest    </div>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="sheet sheet-flat max-w(320) mx-auto">    <div class="listbox" role="listbox" aria-label="Notify me about" aria-multiselectable="true" tabindex="0">      <div class="listbox-option" role="option" id="notify-deploys" aria-checked="true">        Deployments      </div>      <div class="listbox-option" role="option" id="notify-comments" aria-checked="false">        Comments      </div>      <div class="listbox-option" role="option" id="notify-billing" aria-checked="true">        Billing      </div>      <div class="listbox-option" role="option" id="notify-mentions" aria-checked="false">        Mentions      </div>      <div class="listbox-option" role="option" id="notify-digest" aria-checked="false" aria-disabled="true">        Weekly digest      </div>    </div>  </div></template>
先讓清單取得焦點,再按住 Shift 並按 ArrowDown,即可勾選一段連續的選項。

由文字欄位控制的清單方塊,會由該欄位的行為從欄位端操作。若清單是由 role="combobox" 欄位的 aria-controls 指定,listbox 會略過它。attach() 也會略過組合方塊或指令面板內的清單。沒有腳本時,清單方塊只會依照現有屬性呈現,狀態不會變更。

#浮動顯示

加上 popover 屬性後,清單方塊會成為彈出面板。面板的圓角為 12px,列的圓角為 8px。面板會貼著錨點定位,遇到檢視區邊緣時會翻轉到另一側,進出場動畫與選單相同。由文字欄位控制時,請使用 popover="manual",讓清單在輸入時保持開啟。可參考組合方塊的示範。

#清單方塊、選單或下拉選單

  • 下拉選單是從清單中選取單一值的原生控制項。選項都是純文字時,使用這個元件即可,無須腳本。
  • 選單以原生按鈕和連結提供可執行的動作。
  • 清單方塊包含可由腳本篩選、分組或載入的值或結果,適用於組合方塊、指令面板和多選介面。

#鍵盤操作

以下是焦點留在清單方塊上時,listbox 行為支援的按鍵。方向鍵移到第一個或最後一個選項時就會停下。組合方塊和指令面板則由各自的欄位依照其互動模式處理按鍵。

按鍵動作
ArrowDown, ArrowUp切換目前作用中的選項,略過停用的選項,並將新選項捲動到可見範圍內
Home, End移到第一個或最後一個選項
Enter, Space選取目前作用中的選項。若清單設有 aria-multiselectable="true",則切換該選項的勾選狀態
Shift+ArrowDown, Shift+ArrowUp在可多選的清單中,移動作用中選項,並勾選從最後選取的選項到新作用中選項之間的每個選項
Shift+Space, Shift+click在可多選的清單中,勾選從最後選取的選項到此選項之間的每個選項
Control+Shift+Home, Control+Shift+End在可多選的清單中,勾選從目前位置到第一個或最後一個選項之間的每個選項。在 Mac 上使用 Command
Control+A在可多選的清單中,勾選所有選項;若已全部勾選,則全部取消勾選。在 Mac 上使用 Command
Typing移到下一個以輸入字母開頭的選項

#無障礙

  • 為容器加上 role="listbox" 和標籤,並為每個選項加上 role="option"。listbox-group 使用 role="group",並透過 aria-labelledby 引用群組標題作為標籤。
  • 此行為會同步更新 aria-selected 和 aria-activedescendant,並捲動清單,讓作用中的選項進入可見範圍。選項設有捲動邊距,因此捲動後會與清單邊緣保留一些距離。
  • 停用的選項帶有 aria-disabled="true",鍵盤操作會略過它。

#React、Svelte 和 Vue

listbox 元件會根據資料呈現選項、掛載行為,並接收和傳出選取的值。帶有 group 的選項會寫在該群組的標題下:元件會寫出帶有 role="group" 的 listbox-group,以它的 listbox-label 作為標籤,並把同一群組的選項放在一起,群組依首次出現的順序排列。使用 npx master-ui add listbox 將元件複製到專案中。元件的實作方式與用法請見 React、Svelte 和 Vue。

ui/listbox.tsx
'use client'import { useId, useState, type ComponentProps } from 'react'import { listbox } from '@master/ui/behaviors/listbox.js'import { useBehavior } from './use-behavior'export interface ListboxOption {  /** What choosing the option gives `onValueChange`. */  value: string  label: string  description?: string  /** The caption of the group the option belongs to. Options of one group are written together, under it. */  group?: string  disabled?: boolean}export interface ListboxProps extends Omit<ComponentProps<'div'>, 'defaultValue' | 'children' | 'role' | 'ref'> {  options: ListboxOption[]  /** The value of the chosen option, null for none; a list of them when `multiple`. */  value?: string | string[] | null  defaultValue?: string | string[] | null  onValueChange?: (value: string | string[] | null) => void  /** Any number of options may be chosen. */  multiple?: boolean}/** A listbox that stands in the page. Name it with `aria-label` or `aria-labelledby`. */export function Listbox({ options, value, defaultValue, onValueChange, multiple, className, ...root }: ListboxProps) {  const id = useId()  const ref = useBehavior(listbox, undefined, { value, defaultValue, onValueChange })  const [first] = useState(() => [value ?? defaultValue ?? []].flat())  const groups = [...new Set(options.map(option => option.group))]  const row = (option: ListboxOption) => (    <div className="listbox-option" role="option" key={option.value} data-value={option.value} aria-checked={first.includes(option.value)} aria-disabled={option.disabled || undefined}>      {option.description        ? <span className="listbox-body"><span>{option.label}</span><span className="listbox-description">{option.description}</span></span>        : option.label}    </div>  )  return (    <div className={className ? `listbox ${className}` : 'listbox'} role="listbox" tabIndex={0} aria-multiselectable={multiple || undefined} ref={ref} {...root}>      {groups.map((group, index) => group === undefined        ? options.filter(option => option.group === undefined).map(row)        : (            <div className="listbox-group" role="group" aria-labelledby={`${id}group${index}`} key={group}>              <div className="listbox-label" id={`${id}group${index}`}>{group}</div>              {options.filter(option => option.group === group).map(row)}            </div>          ))}    </div>  )}
ui/Listbox.svelte
<script lang="ts" module>  import type { HTMLAttributes } from 'svelte/elements'  export interface ListboxOption {    /** What choosing the option gives `onValueChange`. */    value: string    label: string    description?: string    /** The caption of the group the option belongs to. Options of one group are written together, under it. */    group?: string    disabled?: boolean  }  export interface ListboxProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'children'> {    options: ListboxOption[]    /** The value of the chosen option, null for none; a list of them when `multiple`. Bind it, or leave it out. */    value?: string | string[] | null    onValueChange?: (value: string | string[] | null) => void    /** Any number of options may be chosen. */    multiple?: boolean  }</script><script lang="ts">  import { untrack } from 'svelte'  import { listbox } from '@master/ui/behaviors/listbox.js'  import { behavior } from './behavior.svelte.js'  let { options, value = $bindable(), onValueChange, multiple, class: className, ...root }: ListboxProps = $props()  const id = $props.id()  // The first value is drawn into the first render; after that the behavior marks what is chosen. A row written  // later, from new options, is drawn with the value as it is then, which is not read as state.  const chosen = { values: untrack(() => [value ?? []].flat()) }  const groups = $derived([...new Set(options.map(option => option.group))])  const attach = behavior(listbox, undefined, {    value: () => value,    change: (next) => { chosen.values = [next ?? []].flat(); value = next; onValueChange?.(next) },    settled: (held) => { chosen.values = [held ?? []].flat() },  })</script>{#snippet row(option: ListboxOption)}  <!-- The behavior writes `aria-selected` on the option the keys are on. -->  <!-- svelte-ignore a11y_role_has_required_aria_props -->  <div class="listbox-option" role="option" data-value={option.value} aria-checked={chosen.values.includes(option.value)} aria-disabled={option.disabled || undefined}>    {#if option.description}      <span class="listbox-body"><span>{option.label}</span><span class="listbox-description">{option.description}</span></span>    {:else}      {option.label}    {/if}  </div>{/snippet}<!--  @component  A listbox that stands in the page. Name it with `aria-label` or `aria-labelledby`.--><div class={['listbox', className]} role="listbox" tabindex={0} aria-multiselectable={multiple || undefined} {@attach attach} {...root}>  {#each groups as group, index (group)}    {#if group === undefined}      {#each options.filter(option => option.group === undefined) as option (option.value)}{@render row(option)}{/each}    {:else}      <div class="listbox-group" role="group" aria-labelledby="{id}group{index}">        <div class="listbox-label" id="{id}group{index}">{group}</div>        {#each options.filter(option => option.group === group) as option (option.value)}{@render row(option)}{/each}      </div>    {/if}  {/each}</div>
ui/Listbox.vue
<script lang="ts">export interface ListboxOption {  /** What choosing the option gives the model. */  value: string  label: string  description?: string  /** The caption of the group the option belongs to. Options of one group are written together, under it. */  group?: string  disabled?: boolean}</script><script setup lang="ts">import { computed, h, useId, useTemplateRef, type FunctionalComponent } from 'vue'import { listbox } from '@master/ui/behaviors/listbox.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { options } = defineProps<{  options: ListboxOption[]  /** Any number of options may be chosen. */  multiple?: boolean}>()/** The value of the chosen option, null for none; a list of them when `multiple`: `v-model`. */const model = defineModel<string | string[] | null>()/* A listbox that stands in the page. Name it with `aria-label` or `aria-labelledby`. */const id = useId()const first = [model.value ?? []].flat()const groups = computed(() => [...new Set(options.map(option => option.group))])const root = useTemplateRef<HTMLDivElement>('root')useBehavior(root, listbox, undefined, model)const Row: FunctionalComponent<{ option: ListboxOption }> = ({ option }) => h('div', {  'class': 'listbox-option',  'role': 'option',  'data-value': option.value,  'aria-checked': first.includes(option.value),  'aria-disabled': option.disabled || undefined,}, option.description  ? h('span', { class: 'listbox-body' }, [h('span', option.label), h('span', { class: 'listbox-description' }, option.description)])  : option.label)Row.props = ['option']</script><template>  <div class="listbox" role="listbox" tabindex="0" :aria-multiselectable="multiple || undefined" ref="root" v-bind="$attrs">    <template v-for="(group, index) in groups" :key="group ?? ''">      <template v-if="group === undefined">        <template v-for="option in options" :key="option.value"><Row v-if="option.group === undefined" :option="option" /></template>      </template>      <div v-else class="listbox-group" role="group" :aria-labelledby="`${id}-group-${index}`">        <div class="listbox-label" :id="`${id}-group-${index}`">{{ group }}</div>        <template v-for="option in options" :key="option.value"><Row v-if="option.group === group" :option="option" /></template>      </div>    </template>  </div></template>

#類別

類別說明
listbox選項清單。帶有 popover 屬性時,會顯示為彈出面板。
listbox-option以 role="option" 標記元素作為選項。選項值取自 data-value,未設定時則使用元素的文字
listbox-body選項內的標題在上,說明在下
listbox-descriptionlistbox-body 內選項標題下方的淡色說明文字。
listbox-path選項所在的位置:標題下方的一行小字,置於 listbox-body 內,每一層各用一個 listbox-crumb。它不會換行,上方的標題採用控制項的字重。
listbox-crumblistbox-path 的一層,除了第一層以外,每一層前面都有箭頭。它是文字,不是連結。
listbox-excerpt選項文字下方的段落,置於 listbox-body 內,用來顯示搜尋符合的內容,最多兩行。有了它,圖示和末端內容會對齊標題。
listbox-end選項末端的快速鍵或提示。
listbox-group一組附有標題的選項。容器元素設定 role="group",並以標題作為無障礙名稱。所有選項都隱藏時,整組也會隱藏。
listbox-label選項群組上方的低調標題。
listbox-separator群組之間的細線,延伸至清單兩側邊緣
listbox-empty沒有符合項目時顯示的訊息,會在所有選項都隱藏後出現

#自訂屬性

屬性預設值說明
--listbox-inset4px選項周圍的內距
--listbox-option-radiusvar(--radius-control-sm)列的圓角半徑。浮動清單的圓角半徑為此值加上清單內距。

#原始碼

@master/ui/components/listbox.css
/* * Listbox: a list of options to choose from, the surface a combobox and a command palette open. * The stylesheet draws every state from ARIA and leaves the behavior to the script that drives it: * aria-selected marks the active option, the one the arrow keys are on; aria-checked marks a chosen value * with a check. In the flow of the page it is a plain list; with the popover attribute it is a floating * sheet placed against its anchor, whose corner is a row's corner plus its 4px inset. * An option follows one alignment: its icon, its words and its end center on one another, which holds while the * words are a title and one line under it, a description or a path. With an excerpt, a passage of up to two * lines, the option turns to its first line: the icon and the end stand beside the title and the rest runs * under it. A match in an option is a mark, in the title's ink and weight so it is found in a muted line too. */@layer components.ui {  .listbox {    --listbox-inset: 4px;    --listbox-option-radius: var(--radius-control-sm);    min-width: 0;    margin: 0;    padding: var(--listbox-inset);    overflow-y: auto;    overscroll-behavior: contain;    color: var(--color-text-strong);    font: 400 .84375rem/1.2 var(--font-family-sans);    font-feature-settings: inherit;    /* A label, a description or a query echoed in the empty state wraps rather than scroll the list sideways. */    overflow-wrap: anywhere;    list-style: none;    scrollbar-width: thin;    scrollbar-color: var(--color-line-strong) transparent;    /*     * The list holds focus while aria-activedescendant moves through it: the active row shows where, with the     * ink outline the keys leave inside a row, so it never reads as a row under the pointer.     */    &:focus-visible {      outline: none;      .listbox-option[aria-selected="true"] {        outline: 2px solid var(--color-focus);        outline-offset: -2px;      }    }    /*     * Until an option is active (the script has not run yet, a press gave the list focus, or every option is     * filtered out) the list itself shows that it holds the keys.     */    &:focus-visible:not(:has(.listbox-option[aria-selected="true"]:not([hidden]))) {      @apply --focus-ring;    }    /* Floating: opened with showPopover() by the script that owns the field. */    &[popover] {      --surface-color: var(--color-surface-floating);      min-width: 11rem;      max-width: min(24rem, calc(100vw - 1rem));      max-height: min(20rem, 60dvh);      border: 0;      border-radius: calc(var(--listbox-option-radius) * var(--corner-scale) + var(--listbox-inset));      corner-shape: var(--corner-shape);      background: var(--color-surface-floating);      box-shadow: var(--shadow-floating);      transform-origin: top;      @apply --anchored;      @apply --pop;    }    @media (forced-colors: active) {      &[popover] {        outline: 1px solid CanvasText;        outline-offset: -1px;      }    }  }  /* An option: role="option" on any element. */  .listbox-option {    --icon-size: 1rem;    --icon-offset: -.0625rem;    --icon-color: var(--color-text-muted);    display: flex;    align-items: center;    gap: .625rem;    min-height: 2rem;    padding: .25rem .5rem;    border-radius: calc(var(--listbox-option-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    outline: none;    color: var(--color-text-strong);    scroll-margin: var(--listbox-inset);    user-select: none;    -webkit-user-select: none;    -webkit-tap-highlight-color: transparent;    cursor: pointer;    touch-action: manipulation;    /* A script filters by setting hidden; a display on this rule would otherwise bring the option back. */    &[hidden] {      display: none;    }    /* A row answers at once: no fade between rows as the pointer or the keys travel. */    @media (hover: hover) {      &:hover:not([aria-disabled="true"]) {        --icon-color: currentColor;        background: var(--color-surface-chip);      }    }    /* Pressed: a step deeper than the pointer's tone. */    &:active:not([aria-disabled="true"]) {      background: var(--color-surface-inset-hover);    }    &[aria-selected="true"] {      --icon-color: currentColor;      background: var(--color-surface-chip);    }    /* With real focus on the option, the ink outline says so. */    &:focus-visible {      --icon-color: currentColor;      background: var(--color-surface-chip);      outline: 2px solid var(--color-focus);      outline-offset: -2px;    }    &[aria-disabled="true"] {      --icon-color: currentColor;      color: var(--color-text-disabled);      cursor: not-allowed;    }    /* A checkable option keeps room for its mark at the end, so nothing moves when it is chosen. */    &[aria-checked]::after {      content: '';      flex: none;      width: 14px;      height: 14px;      margin-inline-start: auto;      opacity: 0;      background: currentColor;      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8L6.3532 11.3532A0.2 0.2 0 0 0 6.6412 11.3479L13 4.5'/%3E%3C/svg%3E") center / contain no-repeat;    }    /* Beside something at the end of the option, the mark follows it: only one of the two is pushed to the end. */    &[aria-checked]:has(.listbox-end)::after {      margin-inline-start: 0;    }    &[aria-checked="true"]::after {      opacity: 1;    }    @media (pointer: coarse) {      min-height: 2.75rem;    }    @media (forced-colors: active) {      &:is(:focus-visible, [aria-selected="true"]):not([aria-disabled="true"]) {        background: Highlight;        color: HighlightText;        forced-color-adjust: none;      }      /* Only a pointer that hovers lights a row: a tap would leave it lit on a touch screen. */      @media (hover: hover) {        &:hover:not([aria-disabled="true"]) {          background: Highlight;          color: HighlightText;          forced-color-adjust: none;        }      }      &[aria-disabled="true"] {        color: GrayText;      }      /* The check is a fill cut by a mask: kept out of forced colors, it takes the row's system ink. */      &::after {        forced-color-adjust: none;        background: currentColor;      }    }  }  /* A title with a line under it, for an option that needs a sentence. */  .listbox-body {    display: grid;    flex: 1 1 0;    gap: .125rem;    min-width: 0;    padding-block: .125rem;  }  .listbox-description {    margin: 0;    color: var(--color-text-muted);    font-size: .75rem;    line-height: 1.4;    text-wrap: pretty;  }  /*   * Where an option is: the steps of a path on one line under the title, a chevron between them. They are not   * links (an option is one target), so this is not a breadcrumb. The line never wraps: its steps give way   * together and end in an ellipsis.   */  .listbox-path {    display: flex;    min-width: 0;    margin: 0;    color: var(--color-text-muted);    font-size: .71875rem;    line-height: 1.4;    white-space: nowrap;  }  .listbox-crumb {    flex: 0 1 auto;    min-width: 0;    overflow: hidden;    text-overflow: ellipsis;    &:not(:first-child)::before {      content: '';      display: inline-block;      width: .75rem;      height: .75rem;      margin-inline: .125rem;      background: var(--color-text-disabled);      vertical-align: -.125rem;      mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5L10.3586 7.8586A0.2 0.2 0 0 1 10.3586 8.1414L6 12.5'/%3E%3C/svg%3E") center / contain no-repeat;    }    &:dir(rtl)::before {      scale: -1 1;    }  }  /*   * A passage under an option's words, where a search shows what it matched: two lines at most, then an ellipsis.   * Without line-clamp the passage runs to its end.   */  .listbox-excerpt {    display: -webkit-box;    margin: .125rem 0 0;    overflow: hidden;    color: var(--color-text-muted);    font-size: .75rem;    line-height: 1.45;    -webkit-box-orient: vertical;    -webkit-line-clamp: 2;    line-clamp: 2;  }  /*   * An icon names the option, so it stands on the title's line whatever the body holds under it: a description,   * a path or an excerpt. Centred on two lines it sat between the title and the line under, beside neither, and a   * list that mixes results with and without an excerpt showed its icons at two heights. A picture, an avatar or   * a thumbnail, is as tall as the two lines and still centers on them.   */  .listbox-option:has(.listbox-body) {    /* The title's line and the body's padding, in rem: the end reads it at its own smaller size. */    --listbox-line: calc(.84375rem * 1.2 + .25rem);    .icon {      align-self: start;      margin-block: calc((var(--listbox-line) - var(--icon-size)) / 2);    }  }  /*   * Centering reads as one row for a title and a line under it. An excerpt makes the words taller than that, so   * the option turns to its first line: the icon, the end and the check stand beside the title, each in a box   * as tall as the title's line with the body's own padding, and the row keeps a little more room around it.   */  .listbox-option:has(.listbox-excerpt) {    align-items: start;    padding-block: .375rem;    .listbox-end {      min-height: var(--listbox-line);    }    &[aria-checked]::after {      margin-block: calc((var(--listbox-line) - 14px) / 2);    }  }  /*   * A result's title leads smaller lines, so it takes a control's weight and they do not. A list of results   * keeps one weight whether or not a result has a passage to show.   */  .listbox-option:has(.listbox-path, .listbox-excerpt) {    font-weight: var(--font-weight-control);    :is(.listbox-description, .listbox-path, .listbox-excerpt, .listbox-end) {      font-weight: 400;    }  }  /* A match: the title's ink and a control's weight over the wash, so it is found at a glance in a muted line. */  .listbox-option .mark {    --mark-weight: var(--font-weight-control);  }  .listbox-option:not([aria-disabled="true"]) .mark {    --mark-ink: var(--color-text-strong);  }  /* A shortcut or a hint at the end of an option. */  .listbox-end {    display: inline-flex;    flex: none;    align-items: center;    gap: .25rem;    margin-inline-start: auto;    padding-inline-start: 1rem;    color: var(--color-text-muted);    font-size: .71875rem;    font-variant-numeric: tabular-nums;  }  /* Secondary ink must follow the system-selected foreground, including on highlighted options. */  @media (forced-colors: active) {    :is(.listbox-description, .listbox-path, .listbox-excerpt, .listbox-end) {      color: inherit;    }    /* The chevron is a fill cut by a mask: it takes the row's system ink, as the check does. */    .listbox-crumb:not(:first-child)::before {      forced-color-adjust: none;      background: currentColor;    }  }  /* A group: role="group" around a caption and its options. With every option filtered out, it steps aside. */  .listbox-group:not(:has(.listbox-option:not([hidden]))) {    display: none;  }  /*   * A quiet caption over a group of options. It belongs to the options under it: the room above parts its group from   * the one before, and the room below is small, so the caption reads with the options it leads. The first group still   * shown, or one after a separator, has nothing to part from or a hairline that does it, and keeps a little room.   * Without :nth-child(of), the first group keeps the larger room.   */  .listbox-label {    margin: 0;    padding: .75rem .5rem .25rem;    color: var(--color-text-muted);    font-size: .71875rem;    user-select: none;    -webkit-user-select: none;    .listbox-separator + .listbox-group & {      padding-block-start: .375rem;    }    .listbox-group:nth-child(1 of .listbox-group:has(.listbox-option:not([hidden]))) & {      padding-block-start: .375rem;    }  }  /* A hairline between groups, running to the list's edges. */  .listbox-separator {    height: 1px;    margin: var(--listbox-inset) calc(-1 * var(--listbox-inset));    border: 0;    background: var(--color-line-hair);    /* Forced colors repaint the background as the canvas; a system color keeps the rule. */    @media (forced-colors: active) {      background: CanvasText;    }  }  /* What the list says when nothing matches. It shows by itself once every option is hidden. */  .listbox-empty {    margin: 0;    padding: 1.5rem .75rem;    color: var(--color-text-muted);    text-align: center;    text-wrap: balance;  }  .listbox:has(.listbox-option:not([hidden])) .listbox-empty {    display: none;  }  /* A caption or a rule with no visible option left under its list has nothing to introduce. */  .listbox:not(:has(.listbox-option:not([hidden]))) :is(.listbox-label, .listbox-separator) {    display: none;  }}