跳到正文
cccskills
免费在 GitHub 公开

multi-select-input

Use when you need to choose multiple items from a list.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(2)

  • SKILL.md5.4 KB
  • references/pattern.md24.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Multi-select Input

Choose multiple items from a list

What it solves

A Multi-select Input is a form component that allows users to select multiple items from a predefined set of options. It differs from an autocomplete (which suggests options for freeform entry) by working with a bounded, known list of options — users can only select what exists in the list. The most common visual implementation is a tag/chip-based selector: selected items appear as removable tags inside the input field, and remaining options are shown in a dropdown. Additional patterns include checkbox lists, dual listboxes, and native <select multiple>.

When to use

  • Category and tag assignment – Assigning tags, labels, or categories to content.
  • Permissions and role management – Selecting multiple roles for a user.
  • Filter panels – Letting users apply multiple filters simultaneously.
  • Recipient selection – Choosing multiple email recipients from a contact list.
  • Feature selection – Configuring which features/modules to enable.

When to avoid

  • Freeform text with suggestions – Use Autocomplete instead.
  • Single selection from a small list – Use a Select/Dropdown or Radio group.
  • Binary choices – Use Checkboxes.
  • Very large option sets (> 1000 items) – Use a virtualized list or search-first approach.

Implementation workflow

  1. Confirm the pattern matches the problem and constraints before copying the example.
  2. Start from the anatomy and examples in references/pattern.md, then choose the smallest viable variation.
  3. Apply accessibility, performance, and interaction guardrails before layering visual polish.
  4. Use the testing guidance to verify behavior across keyboard, screen reader, responsive, and failure scenarios.

Accessibility guardrails

Keyboard Interaction Pattern

KeyAction
TabMoves focus to the multi-select input; Shift+Tab moves backward
Down ArrowOpens the dropdown; moves focus down through options
Up ArrowMoves focus up through options
EnterSelects / deselects the focused option
SpaceSelects / deselects the focused option (same as Enter in listbox)
EscapeCloses the dropdown without changing selection
BackspaceWhen search input is empty, removes the last selected tag

Performance guardrails

  • Dropdown open time: < 100ms
  • Option filtering (search): < 50ms for lists up to 1000 items
  • Tag addition rendering: < 16ms (one frame)
  • Select All operation: < 50ms for 100 items
  • Memory per instance: < 15KB for component; virtualize options list for > 500 items

Common mistakes

Using <select multiple>

The Problem: Native <select multiple> requires Ctrl+Click (or Cmd+Click) to select multiple items, which is an unintuitive interaction that most users are unaware of.

<!-- Bad: Requires Ctrl+click — users don't know this -->
<select multiple name="skills[]">
  <option>React</option>
  <option>TypeScript</option>
</select>

How to Fix It? Use a custom multi-select component with checkboxes or a tag-based UI.

Closing the Dropdown After Each Selection

The Problem: If the dropdown closes every time the user selects an option, they must reopen it for each additional selection — significantly slowing down multi-item workflows.

How to Fix It? Keep the dropdown open after selection; close only on Escape or external click.

option.addEventListener('click', (e) => {
  e.stopPropagation(); // Prevent close-on-outside-click from triggering
  toggleOptionSelection(option);
  updateTags();
  searchInput.focus(); // Keep focus in the input
  // DO NOT close the dropdown here
});

Not Handling Backspace for Tag Removal

The Problem: Users expect Backspace in an empty search input to remove the last selected tag. Omitting this makes the component feel incomplete and forces mouse usage.

How to Fix It? Listen for keydown on the search input.

searchInput.addEventListener('keydown', (e) => {
  if (e.key === 'Backspace' && searchInput.value === '') {
    const lastTag = getLastSelectedItem();
    if (lastTag) {
      removeSelection(lastTag);
    }
  }
});

Related patterns


For full implementation detail, examples, and testing notes, see references/pattern.md.

Pattern page: https://uxpatterns.dev/patterns/forms/multi-select-input

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

accordion

免费

Use when implementing expand and collapse content sections.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

Use when implementing user account configuration and preferences.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

Use when implementing social activity and updates stream.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

ai-chat

免费

Use when implementing conversational AI chat interfaces.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

Use when implementing handling AI-specific errors.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

Use when implementing loading states for AI operations.

中文简介正在准备中。当前显示原文说明。

thedaviddias/ux-patterns-for-developers2662026年10月5日 更新

查看 thedaviddias 的全部技能

报告此技能的问题