Communitygithub.com

标签页 UI 系统

设计并实现一个用于组织相关但互斥内容的系统化框架,确保清晰的视觉提示、状态逻辑和响应式适配。

标签页 UI 系统 是什么?

Tab UI 系统是一种专为开发者设计的技能,用于在单个视图中构建标签页导航,使用户能够在相关但互斥的内容面板之间切换。它遵循渐进式披露原则,通过逻辑分组减少认知负载,无需页面重新加载。该技能支持多个平台(如 Claude Code、Cursor、Codex),并提供了从内容清单定义到可访问性蓝图(包括 ARIA 角色、键盘导航和焦点管理)的完整工作流。关键特性包括状态矩阵(默认、悬停、活动、焦点、禁用)、溢出处理的响应式策略(滚动、折叠为手风琴或选择菜单),以及避免隐藏活动状态和内容跳跃等常见失败模式的决策规则。输出包括 Tab 解剖规范、可访问性合规性检查清单和验证标准,确保标签页达到 WCAG AA 标准,在桌面和移动设备上都能稳健运行。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/coastdigitalgroup/coastai-skills/tree/HEAD/website-design/tab-ui-system

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

标签页 UI 系统 是做什么的?

目的

标签页 UI 系统提供了一种设计和构建标签页的方法论——标签页是允许用户在同一上下文中切换相关内容面板的导航元素。标签页是渐进式披露的关键模式,通过将信息组织成逻辑组来减少认知负载,而无需页面重新加载。一套系统化的方法可确保标签页具有清晰的活动状态、逻辑分组,并能在不同设备上优雅地适配。

使用场景

  • 产品详情页: 将规格、评论、配送信息和常见问题组织成可扫描的章节。
  • 账户设置: 将用户资料、安全、通知和计费设置分组。
  • 数据面板: 在不同的数据视图之间切换(例如,“概览”、“分析”、“历史”)。
  • 搜索结果: 按类型筛选结果(例如,“全部”、“图片”、“视频”、“新闻”)。
  • 复杂表单: 将大型表单分解为主题化的章节(如果步骤不需要严格按顺序完成)。

何时不使用

  • 顺序步骤: 如果用户必须按特定顺序完成内容,请改用 step-progress-system。
  • 全局导航: 标签页应管理页面内的内容;在不同页面间移动请使用 site-navigation-system。
  • 比较信息: 如果用户需要同时查看两个章节的内容,请不要使用标签页。考虑使用手风琴或并排布局。
  • 项目太少: 如果只有两个项目且内容较短,考虑同时显示两者或使用简单的切换开关。
  • 项目太多: 如果有超过 6-7 个标签页,界面会变得杂乱。考虑使用侧边栏导航或基于下拉框的筛选器。

输入

  1. 内容清单: 标签标签及其对应内容面板的列表。
  2. 使用上下文: 标签页将位于何处(例如,主要内容区域、侧边栏或模态框内)。
  3. 优先级: 这是页面的主要焦点还是次要细节?
  4. 现有系统: 流体间距、排版比例和交互状态定义。

输出

  1. 标签解剖规范: 触发器(标签页)、标签列表(容器)和面板(内容)的视觉定义。
  2. 状态矩阵: 针对默认、悬停、活动、焦点和禁用状态定义的视觉处理方式。
  3. 响应式策略: 处理溢出(滚动、换行或折叠为手风琴/选择)的规则。
  4. 可访问性蓝图: ARIA 角色、键盘映射和焦点管理规则。

工作流

1. 定义内容关系

确保所有标签页处于同一层级,并与同一父实体相关。标签应简短(1-3 个词)并使用一致的字母大小写。

2. 建立视觉解剖

应用 visual-hierarchy-system 定义标签列表:

  • 活动标签: 必须是最突出的。结合颜色、字体粗细和视觉指示器(如下边框或背景填充)。
  • 非活动标签: 应看起来可交互但次要。
  • 内容面板: 通常与活动标签共享一个视觉容器或对齐方式,以营造“连接”的感觉。

3. 定义交互逻辑

  • 即时切换: 内容应在交互后立即更改。
  • 悬停与点击: 标签页绝不能在悬停时切换;需要明确的点击或敲击。
  • 默认状态: 默认情况下通常激活第一个标签页,除非用户返回到特定状态。

4. 优化间距和触控

应用 fluid-spacing-system 和 interactive-state-system:

  • 触控目标: 每个标签触发器应满足 WCAG 2.2 SC 2.5.8(最小 24x24px);对于主要标签页 UI,建议 44x44px。
  • 内部间距: 在标签之间使用一致的间距(通常为 --space-s 或 --space-m)。
  • 活动指示器: 确保“活动”线条或背景足够厚,以便清晰可见。

5. 规划响应式

确定标签列表如何处理窄视口:

  • 水平滚动: 最常见的移动端模式。允许标签列表水平溢出,并带有微弱的渐变或箭头指示更多内容。
  • 手风琴转换: 对于长内容,在移动端将标签页转换为手风琴布局。
  • 选择菜单: 对于实用性的标签页,在移动端用 <select> 元素替换标签列表。

决策规则

  • “标签”规则: 如果标签长度差异很大,请使用左对齐标签。如果它们一致且数量较少,请使用居中或两端对齐标签。
  • 水平与垂直:
    • 水平: 标准的内容顶部组织。
    • 垂直: 最适合深层列表(设置)或水平空间有限但垂直空间充足的情况。
  • “七”规则: 将水平标签限制在 7 个项目以内。如果需要更多,请重新评估信息架构或使用垂直布局。
  • 活动指示器: 始终使用颜色以外的方式指示活动状态(例如,2px-3px 的下划线或粗体字重变化)。

约束条件

  • 可访问性: 遵循 ARIA APG 标签页模式——容器上使用 role="tablist",每个触发器上使用 role="tab" 并带有 aria-selected 和 aria-controls,以及 role="tabpanel" 并带有指向其标签页的 aria-labelledby。只有活动标签具有 tabindex="0";非活动标签使用 tabindex="-1"(漫游 tabindex)。
  • 激活模式: 对于快速、轻量的面板,优先使用自动激活(箭头键移动焦点并立即切换面板内容)。如果切换触发昂贵的网络请求,请使用手动激活(箭头键仅移动焦点;Enter/Space 确认)。
  • 键盘导航: 左/右箭头(对于垂直标签页则是上/下箭头)在标签之间移动;Home/End 跳转到第一个/最后一个标签;Tab 将焦点移出标签列表并进入活动面板。
  • 对比度: 活动和非活动状态必须满足 WCAG AA(文本对比度 4.5:1)。
  • 响应式: 标签页绝不能导致页面水平滚动;标签列表本身应处理溢出。

常见失败模式

  • 隐藏的活动状态: 使用难以看清的细微颜色变化,让用户不确定自己正在查看哪个部分。
  • 内容跳跃: 标签面板高度差异很大,导致用户切换标签时页脚上下跳动。
  • 误用于导航: 使用标签页链接到单独的页面,这打破了用户对即时内容切换的期望。
  • 移动端截断: 在移动端截断标签标签而不提供查看其余部分的方式。
  • 缺少焦点状态: 忘记为键盘用户设计可见的焦点环。

验证标准

  • 所有标签页都与同一上下文相关。
  • 活动状态在视觉上可区分(不仅仅是颜色)。
  • 每个标签触发器至少满足 WCAG 2.2 24x24px 的触控目标最小值(建议 44x44px)。
  • 正确分配 ARIA 角色(tablist、tab、tabpanel),并实现了 aria-selected 和漫游 tabindex。
  • 根据 ARIA APG 标签页模式支持键盘导航(箭头键、Home/End)。
  • 定义了响应式行为(滚动、手风琴或选择)。
  • 内容面板与标签页保持一致的视觉关系。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for progressive disclosure using accordions, ensuring structural integrity, visual affordances, and accessibility across different content densities and devices.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for long-form content, managing readability, vertical rhythm, and information density to ensure a superior reading experience.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for informational elements that communicate state (Badges) and categorization (Tags) with clarity and accessibility.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for non-overlay notifications, managing global announcements and contextual inline alerts to communicate system states without interrupting the user's flow.

coastdigitalgroup/coastai-skills

Design and implement a systematic, asymmetrical bento-grid layout framework to organize diverse content types cohesively while maintaining strict visual hierarchy, logical focus order, and responsive flexibility.

coastdigitalgroup/coastai-skills

Design a responsive, mobile-first bottom navigation bar and persistent action dock system for mobile websites and web applications, establishing spatial anchors, tab bar anatomy, badge indicators, thumb-zone ergonomics, safe area inset handling, active/inactive state contrast, and desktop responsive adaptation rules.

coastdigitalgroup/coastai-skills

Design a mobile-first bottom sheet overlay system with configurable detents, drag affordances, safe area padding, responsive desktop modal/popover adaptation, and WCAG AA accessibility compliance.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for secondary navigation trails that provide orientation, context, and one-click access to parent levels in deep information architectures.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for buttons and interactive triggers, managing visual hierarchy, variant logic, and action grouping to ensure clear intent and accessible interaction.

coastdigitalgroup/coastai-skills

Design a systematic framework for date and time selection, managing calendar grids, range pickers, and scheduling interfaces to ensure precision and accessibility.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for modular content containers that maintain hierarchy, structural integrity, and action alignment across variable content and responsive viewports.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for horizontal discovery components, managing navigation affordances, scroll behavior, and accessibility to ensure effective content density without compromising usability.

coastdigitalgroup/coastai-skills

Design a systematic, highly accessible, and developer-friendly UI layout framework for code blocks, snippet showcases, multi-file code tabs, line-highlighting, diff views, and syntax token contrast in technical documentation and developer platforms.

coastdigitalgroup/coastai-skills

Design a systematic framework for global command menus (Cmd+K panels) that combines keyboard-driven navigation, command execution, and shortcut discovery into an accessible, responsive overlay.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for threaded conversations, managing nesting depths, action hierarchies, and community signaling to foster engagement and readability.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for side-by-side comparison interfaces, managing high attribute density and responsive complexity to support informed decision-making.

coastdigitalgroup/coastai-skills

Design and implement a systematic framework for user privacy, managing consent banners, preference centers, and persistent privacy controls to balance legal compliance with user trust.

coastdigitalgroup/coastai-skills

Design and implement a systematic, highly accessible, and responsive visual layout framework for conversational chat widgets, live chat boxes, and chatbot panels that ensures clear message scannability, native focus flow, and seamless mobile keyboard adaptation.

coastdigitalgroup/coastai-skills

Design a systematic, accessible, and high-conversion framework for custom select dropdowns and comboboxes, defining anatomy, states, search-filtering, and responsive mobile-adaptive patterns.

coastdigitalgroup/coastai-skills

Design and implement a systematic color palette that ensures WCAG 2.2 accessibility compliance. Trigger this skill when asked to define brand colors, create UI themes, or establish a visual system for a website.

相关技能