@3mo/list

中文文档
0.12.6发布于 2026/10/22MITTypeScriptES Module构建来源已验证近 30 天下载 2635

Web components for lists with selectable, checkbox, radio and switch items, plus ARIA listbox and combobox controllers.

原始使用文档
文档目录22 节
  1. Installation
  2. Usage
  3. Examples
  4. Combobox
  5. Listbox
  6. Accessibility
  7. mo-list
  8. ListboxController
  9. ComboboxController
  10. API
  11. mo-list
  12. mo-checkbox-list-item
  13. mo-collapsible-list-item
  14. mo-list-item
  15. mo-list-item-ripple
  16. mo-navigation-list-item
  17. mo-radio-list-item
  18. mo-selectable-list
  19. mo-selectable-list-item
  20. mo-switch-list-item
  21. Links
  22. License

List

Web components for lists with selectable, checkbox, radio and switch items, plus ARIA listbox and combobox controllers.

npm Documentation

A list of items, such as mo-list-items and the ones with a checkbox, switch or radio button.

Installation

npm install @3mo/list
import '@3mo/list'

Usage

<mo-list>
    <mo-list-item icon='inbox'>Inbox</mo-list-item>
    <mo-list-item icon='drafts'>Drafts</mo-list-item>
    <mo-list-item icon='send'>Sent</mo-list-item>
    <mo-list-item icon='delete'>Trash</mo-list-item>
</mo-list>

Examples

  • Content — An item holds any content after its icon, such as a shortcut at its end, and an element with role='separator' divides the groups.
  • Disabled — A disabled item fades and ignores presses; an element inside it can still take them with pointer-events: auto.
  • Subgrid Layout — A list laid out as a grid whose items take its columns through subgrid lines up the icons, labels and shortcuts of all items.
  • Checkbox Items — mo-checkbox-list-item makes the whole item the label of its checkbox.
  • Switch Items — mo-switch-list-item does the same for a switch.
  • Radio Items — mo-radio-list-item does the same for a radio button.
  • Selection Control Alignment — selectionControlAlignment='start' places the control before the content instead of at its end.
  • Selectable Items — A toggleable selectable item is selected and deselected by a press, and shows its state by its background.
  • Collapsible Items — mo-collapsible-list-item opens its details below the item it holds, to any depth.
  • Selectable List — mo-selectable-list keeps one selection over all its selectable items, whatever their control, as their indices in value; arrow keys move between them.
  • Selectable Collapsible Items — Selectable items inside collapsible ones join the list's selection too; here :has() outlines the group that holds it.

Combobox

  • Default — ↓ or ↑ opens the list onto the chosen country and Esc closes it; each new filter makes its first match active, so Enter takes it.
  • Search In Popup — A button opens a popup with its own search box, which is the combobox.

Listbox

  • Default — Tab in, then the arrows, Home, End and typing a name move; Space or Enter selects.
  • Selection Follows Focus — selectionFollowsFocus selects whichever option the arrows reach, as a single-select listbox of few options may.
  • Horizontal — orientation: 'horizontal' moves with ← and →, which follow the writing direction.
  • Multiple Selection — Space or a click toggles one option, Shift+arrow and Shift+Space extend a range, Ctrl+Shift+Home or End select to either end, and Ctrl+A selects all or none.
  • Filter As You Type — With combobox, focus stays in the input and the active option is announced on it by element reference; Home, End, ← and → stay the input's.
  • Grouped — Options in labelled groups: the arrows run straight on from one group into the next, while a screen reader counts within each.

Accessibility

mo-list

A list of listitems: every item is a tab stop, and Enter and Space click it. For a choice among the items use mo-selectable-list, a listbox. ArrowRight opens a mo-collapsible-list-item and ArrowLeft closes it. It does not announce whether it is open yet, and the two keys do not swap in a right-to-left language.

ListboxController

The list is a listbox, with aria-multiselectable while multiple and aria-orientation='horizontal' when horizontal. Each option is an option with aria-selected, and aria-disabled while disabled. Focus roves: Tab lands on the first selected option, else on the first one. The arrows move without selecting, unless selectionFollowsFocus selects as they move in single selection.

KeyDoes
ArrowDown ArrowUpThe next or previous option; ArrowRight and ArrowLeft when horizontal.
Home End, PageUp PageDownThe first or last option, or a page further.
A letterTypeahead.
Space EnterSelects the option, as a click does; toggles it while multiple.
Shift + an arrowMultiple: moves and extends the selection from where it started.
Ctrl Shift Home / EndMultiple: selects from the option to the first or last one.
Ctrl AMultiple: selects all, or none while all are selected.

Name the list with aria-label or aria-labelledby.

ComboboxController

The input is a combobox with aria-expanded and aria-controls pointing at the listbox, whose options follow the listbox pattern. Focus stays in the input: the active option is named by aria-activedescendant, set as an element reference so it reaches options in another shadow root, and gets data-keyboard-focus so it can show a focus ring.

KeyDoes
ArrowDown PageDownClosed: opens on the selected option, else on the first.
ArrowUp PageUpClosed: opens on the selected option, else on the last.
Home End, Enter SpaceClosed, where the input takes no typing: opens, on the first or last option for Home and End, on the selected one for Enter and Space.
ArrowDown ArrowUpOpen: the next or previous option.
Home EndOpen: the first or last option; in an input that takes typing they move the caret instead.
A letterTypeahead, or the typing that filters the options.
EnterChooses the active option and closes; Space too, where the input takes no typing.
Escape TabCloses; Tab moves focus on as well.

Name the input and the listbox, for example after a visible label.

Another popup takes the listbox's place through popup: a tree's controller given the input as its combobox, for options nested under others. Its keys and roles are the tree's own.

API

mo-list

Events

NameDetailDescription
itemsChangeHTMLElement[]Dispatched when the list items change

Slots

NameDescription
(default)The list items.

mo-checkbox-list-item

A list item with a checkbox, which a press anywhere on the item toggles.

Properties

NameAttributeTypeDefaultDescription
selectionControlAlignmentselectionControlAlignment"start" | "end""end"The alignment of the checkbox relative to the list item content
selectedselectedCheckboxSelectionfalseThe value of the checkbox
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space
indeterminateWhether the checkbox is indeterminate

Events

NameDetailDescription
changeDispatched when the checkbox value changes

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

mo-collapsible-list-item

A list item that opens into the nested items below it.

Properties

NameAttributeTypeDefaultDescription
openopenbooleanfalseWhether the list item is open

Slots

NameDescription
(default)The parent list item
detailsThe nested list items

CSS parts

NameDescription
summaryThe summary element hosting the parent list item
detailsThe details element hosting the nested list items
expand-collapse-icon-buttonThe expand/collapse icon button

mo-list-item

An item of a list, with an optional icon before its content.

Properties

NameAttributeTypeDefaultDescription
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

mo-list-item-ripple

Properties

NameAttributeTypeDefaultDescription
disableddisabledbooleanfalseWhether the ripple is disabled

mo-navigation-list-item

Properties

NameAttributeTypeDefaultDescription
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

mo-radio-list-item

A list item with a radio button, which a press anywhere on the item selects.

Properties

NameAttributeTypeDefaultDescription
namenamestring | undefinedThe name of the radio
selectionControlAlignmentselectionControlAlignment"start" | "end""end"The alignment of the radio relative to the list item content
selectedselectedbooleanfalseWhether the radio is selected
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space

Events

NameDetailDescription
changeDispatched when the radio value changes

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

mo-selectable-list

A list that keeps one selection over its selectable items, whichever their control, by their indices.

Properties

NameAttributeTypeDefaultDescription
selectabilityselectabilitySelectability"single"The selectability of the list
valuevaluenumber[]"new Array<number>()"The selected list items' indices

Events

NameDetailDescription
changenumber[]Dispatched when the selected list items change
itemsChangeHTMLElement[]Dispatched when the list items change

Slots

NameDescription
(default)Default slot for list items

mo-selectable-list-item

A list item that a press selects, shown by its background.

Properties

NameAttributeTypeDefaultDescription
toggleabletoggleablebooleanfalseWhether the list item selection can be toggled on and off
selectedselectedbooleanfalseWhether the list item is selected
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space

Events

NameDetailDescription
changeDispatched when the list item is selected or deselected

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

mo-switch-list-item

A list item with a switch, which a press anywhere on the item toggles.

Properties

NameAttributeTypeDefaultDescription
selectionControlAlignmentselectionControlAlignment"start" | "end""end"The alignment of the switch relative to the list item content
selectedselectedbooleanfalseWhether the switch is selected
disableddisabledbooleanfalseWhether the list item is disabled
iconiconMaterialIcon | undefinedIcon to be displayed in the list item
preventClickOnSpacepreventClickOnSpacebooleanfalseWhether the list item should prevent click on space

Events

NameDetailDescription
changeDispatched when the switch value changes

Slots

NameDescription
(default)Default slot for content

CSS parts

NameDescription
iconThe icon before the content.

License

MIT © 3MO GmbH

版本与发布记录

@3mo/list 共发布 79 个版本,首次发布于 2023/02/03;过去 12 个月发布了 14 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.12.6latest2026/10/2217 天前
0.12.52026/10/1028 天前
0.12.42026/10/0830 天前
0.12.32026/09/301 个月前
0.12.22026/09/301 个月前
0.12.12026/09/281 个月前

关于 @3mo/list 的常见问题

@3mo/list 是什么?

Web components for lists with selectable, checkbox, radio and switch items, plus ARIA listbox and combobox controllers.

如何安装 @3mo/list?

在项目目录运行 npm install @3mo/list,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@3mo/flex(x)、@3mo/icon(x)、@a11d/lit(x)、@3mo/radio(x)、@3mo/theme(>=0.5.4)、@3mo/switch(x)、@3mo/checkbox(x)、@material/web(1.x)、@3mo/focus-ring(x)、@3mo/indexability(>=0.3.0)、@3mo/navigability(x)、@3mo/selectability(>=0.3.0)、@3mo/focus-controller(x)、@3mo/disabled-property(x)、@3mo/mutation-observer(x)、@3mo/expand-collapse-icon-button(x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@3mo/list 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@3mo/list 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@3mo/list 可以商用吗?

@3mo/list 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@3mo/list 的下载量有多少?

根据 npm 官方下载统计,@3mo/list 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,635 次,日均约 88 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@3mo/list 还在维护吗?

最新版本 0.12.6 发布于 2026/10/22(17 天前);至今共发布 79 个版本,其中过去 12 个月发布了 14 个;首次发布于 2023/02/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。