Communitygithub.com

coastdigitalgroup/coastai-skills

設計並記錄 UI 元素在使用者互動期間(懸停、聚焦、啟用、停用等)的視覺行為,以確保可用性與無障礙性。

coastai-skills 是什麼?

「互動狀態系統」技能提供了一套框架,用於定義 UI 元件如何回應使用者輸入。它能確保每個互動元素(按鈕、連結、輸入框、卡片)在滑鼠、鍵盤與觸控等所有互動模式下,都具有清晰、一致且無障礙的視覺回饋。此系統為開發者消除歧義,並為最終使用者保證高品質、反應靈敏的操作體驗。此技能支援所有主流 UI 框架,且特別強調遵循 WCAG 2.2 無障礙標準,包括焦點指示器、觸控目標大小與互動提示等規範。其運作章法是先盤點所有互動元件,再為各狀態(預設、懸停、聚焦、啟用、停用等)定義色彩與視覺變化,最後建立轉場動畫與無障礙規格文件。

相容平台~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/coastdigitalgroup/coastai-skills/tree/HEAD/website-design/interactive-state-system

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

互動狀態系統

目的

互動狀態系統技能提供了一套框架,用於定義 UI 元件如何回應使用者輸入。它能確保每個互動元素(按鈕、連結、輸入框、卡片)在滑鼠、鍵盤與觸控等所有互動模式下,都具有清晰、一致且無障礙的視覺回饋。此系統為開發者消除歧義,並為最終使用者保證高品質、反應靈敏的操作體驗。

使用情境

  • 為設計系統或 UI 元件庫定義元件行為。
  • 稽核現有網站中「無反應」或無互動回饋的元素。
  • 確保遵循 WCAG 2.2 有關焦點指示器、目標大小與互動提示的規範。
  • 標準化回饋模式(例如:所有破壞性操作的行為保持一致)。

何時不應使用

  • 靜態內容: 純資訊性元素,無點擊、輕觸或鍵盤互動需求。
  • 實驗性動態設計: 目標是複雜、非標準的動畫,而非功能性的狀態回饋。
  • 標準瀏覽器預設樣式: 專案完全依賴未經修飾的原生瀏覽器元素(但在專業網站設計中較少見)。

輸入

  1. 元件清單: 設計中所有互動元素的列表。
  2. 品牌色彩系統: 現有的主色、輔助色與語義色彩色階。
  3. 無障礙目標: (例如:WCAG Level AA)決定各狀態的對比度要求。

輸出

  1. 狀態矩陣: 一份全面對照表,列出每個元件的預設、懸停、聚焦、啟用和停用狀態。
  2. 互動指南: 關於轉場、持續時間 (毫秒) 與緩動函數的規則。
  3. 無障礙規格: 明確定義焦點環與僅限鍵盤使用的視覺提示。

工作流程

1. 識別互動元素

依互動類型將元素分類:

  • 操作: 按鈕、連結、選單項目。
  • 輸入: 文字欄位、核取方塊、單選按鈕、下拉選單。
  • 容器: 可點擊的卡片、手風琴標題、頁籤。

2. 定義狀態調色盤

決定每個狀態下視覺變數的變化方式:

  • 懸停 (滑鼠): 背景色、邊框或立體感(陰影)的輕微變化。
  • 聚焦 (鍵盤): 高對比度環或外框。必須與懸停狀態明顯區分。
  • 啟用/按下: 視覺上的「壓縮」效果(例如:輕微變暗或縮小),表示點擊/輕觸成功。
  • 停用: 降低不透明度並移除互動提示(游標樣式改變)。
  • 已訪問 (連結): 為已導覽過的連結使用不同顏色(對內容密集的網站至關重要)。

3. 建立焦點邏輯

設計一套「全域焦點樣式」,確保鍵盤使用者隨時知道自己的位置。

  • 規則: 焦點指示器與背景的對比度至少為 3:1,且與元件的非聚焦狀態對比度也至少為 3:1。
  • 規則 (WCAG 2.2 SC 2.4.11): 焦點指示器絕不能被其他內容完全遮蔽(例如,捲動時固定頁首蓋住已聚焦的元素)。指示器的至少一部分必須始終保持可見。

4. 為觸控最佳化 (行動裝置)

由於觸控裝置上不存在懸停狀態:

  • 確保「啟用」狀態能提供立即回饋。
  • 確認觸控目標符合 WCAG 2.2 SC 2.5.8(最小 24x24px),且在版面允許時優先使用 44x44px 以方便拇指觸及。
  • 移除依賴懸停的資訊(改用點擊觸發的工具提示或永久標籤)。

5. 記錄轉場動畫

定義狀態變化的方式:

  • 持續時間: 150ms 至 250ms 為狀態變化的標準範圍。
  • 緩動: ease-in-out 或 cubic-bezier(0.4, 0, 0.2, 1)。

決策規則

  • 狀態持續性: 只要元素保有焦點,焦點指示器就必須保持可見。
  • 提示優先: 互動元素在預設狀態下必須看起來「可點擊」(例如:按鈕應比不可點擊的標籤具有更重的視覺重量)。
  • 避免純顏色狀態: 不要僅依賴顏色來表示狀態(例如:錯誤狀態應包含圖示或邊框粗細變化)。
  • 立即回饋: 互動回應應感覺即時(啟動時間 <100ms)。

限制條件

  • 無障礙性: 焦點指示器不能透過 CSS outline: none 隱藏,除非提供強大的替代方案。
  • 響應式設計: 狀態必須在小型螢幕上運作,且不能依賴滑鼠懸停。
  • 效能: 避免在頻繁觸發的狀態(如懸停)上使用沉重的陰影或複雜的濾鏡,以防止版面抖動。

常見失敗模式

  • 「隱形」焦點: 移除瀏覽器預設焦點環卻未替換,導致鍵盤使用者無法使用網站。
  • 僅限懸停的邏輯: 將重要資訊或操作隱藏在懸停狀態中,使其在行動裝置上無法存取。
  • 模糊的啟用狀態: 按鈕在點擊時沒有變化,導致使用者多次點擊。
  • 令人困惑的停用狀態: 元素看起來已停用但實際上可點擊,或相反情況。

驗證標準

  • 每個互動元素都已定義懸停、聚焦和啟用狀態。
  • 焦點指示器符合 3:1 對比度要求,且絕不會被其他內容完全遮蔽 (WCAG 2.2 SC 2.4.11)。
  • 觸控目標至少為 24x24px (WCAG 2.2 SC 2.5.8),建議使用 44x44px。
  • 沒有重要資訊僅隱藏在懸停互動中。
  • 停用狀態在視覺上可區分,並設有 pointer-events: none(或等效邏輯)。
  • 系統包含明確的狀態轉場/動畫指南。

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.

相關技能