Communitygithub.com

coastdigitalgroup/coastai-skills

設計並實作一個用於 Z 軸的系統化框架,利用陰影、層疊和堆疊上下文來傳達層級與深度。

coastai-skills 是什麼?

Elevation and Depth System 技能提供一套完整的方法論,用於管理網頁介面中垂直維度(Z 軸)的視覺層次。它結合陰影比例、堆疊上下文分層(例如從基底、平面到浮動、覆蓋層)以及表面亮度調整,建立一個可預測且符合物理直覺的深度環境。此技能支援在設計系統中定義標準化的陰影代碼(如 elevation-sm 到 elevation-xl)和 z-index 分級策略,適用於儀表板、IDE 等多層界面,並透過互動狀態(懸浮、按壓)的陰影變化提供觸覺回饋。它特別強調無障礙性,要求深度提示不應取代結構性區別,且高層元素不得遮擋焦點指示器;同時在深色模式下改採表面亮度變化而非黑色陰影,以維持可讀性。輸出包含陰影代碼、堆疊上下文物件、基於 OKLCH 色彩空間的階層表面色板,以及互動規範,從而有效防止 Z-index 混亂與不一致的陰影效果。

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

在你喜歡的 AI 中提問

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

說明文件

Elevation and Depth System

目的

Elevation and Depth System 提供一套管理網頁介面垂直維度(Z 軸)的方法論。它利用陰影、表面處理和堆疊順序等視覺線索,建立清晰的圖層層級。此系統確保使用者理解重疊元素之間的關係、能夠識別可互動的介面,並體驗一個可預測、具觸感的環境,模擬真實世界的深度。

使用案例

  • 為設計系統定義一致的陰影比例。
  • 設計複雜的多層介面,例如儀表板或 IDE。
  • 建立堆疊順序(z-index)標準,防止 UI 元件相互衝突。
  • 為互動狀態提供觸覺回饋(例如,按鈕在懸停時浮起)。
  • 區分持續存在的頁面內容和臨時性的覆蓋層。

何時不應使用

  • 扁平/粗獷設計: 當刻意追求的視覺風格是二維且缺乏感知深度或陰影時。
  • 純文字內容: 簡單的文章或文件,沒有重疊的圖層或可互動的表面。
  • 效能受限的低階裝置: 當大量使用 CSS 濾鏡或複雜的 box-shadow 可能導致明顯的渲染延遲時。

輸入

  1. 品牌美學: 深度是「物理/材質」(擬真陰影)還是「圖形」(偏移色塊)?
  2. 元件清單: 所有需要高度設定的 UI 元素列表(卡片、導航欄、模態框、按鈕)。
  3. 主要光源: 通常假設來自上方或正中央上方。
  4. 間距系統: 使用 fluid-spacing-system 來對齊陰影擴散範圍與佈局邊距。

輸出

  1. 高度比例(陰影): 一組標準化的 5-6 個 box-shadow 代碼(例如 elevation-sm 到 elevation-xl)。
  2. 堆疊上下文圖(Z-Index): 一個按圖層功能分類的 z-index 數值定義比例。
  3. 表面色板: 根據高度變化的背景顏色定義(例如,較暗的表面「下沉」,較亮的表面「上升」)。
  4. 互動規範: 關於在 Hover、Active 和 Focus 狀態下高度變化的規則。

工作流程

1. 建立分層堆疊

將介面從底部到頂部分為功能圖層:

  • 層級 0(基底): 頁面背景/畫布。
  • 層級 1(平面): 位於基底上的內容(例如,扁平卡片、分隔線)。
  • 層級 2(升起): 可互動的元素或主要卡片,細微地「浮動」。
  • 層級 3(固定/浮動): 全域頁首、FAB(浮動動作按鈕)。
  • 層級 4(覆蓋層): 模態框、抽屜及其背景遮罩。
  • 層級 5(系統): 工具提示、提示訊息和關鍵警報。

2. 定義陰影比例

建立一個與基底距離相對應的漸進式陰影:

  • 小(2dp): 用於按鈕或小卡片的輕微分離。
  • 中(4dp-8dp): 下拉選單和導航的標準高度。
  • 大(12dp-24dp): 用於模態框和浮動圖層的高高度。
  • 特大(32dp+): 用於臨時焦點或系統警報的顯著深度。

注意:使用多層陰影(例如「銳利」陰影與「柔和」陰影)可產生更逼真、高品質的效果。

3. 指定表面顏色

深度不僅來自陰影,也來自光線反射:

  • 淺色模式: 較高層級的元素通常會稍微變亮,或保持純白,而基底則是灰白色。
  • 深色模式: 較高層級的元素必須變亮(使用半透明的白色覆蓋層),以模擬更接近光源的效果。
  • 實作方式: 使用 color-mix(in oklch, var(--surface-base) 100%, white X%)(或等效的 OKLCH 代碼函數)來程式化地生成每個高度層級的表面顏色,而不是為每個層級手動挑選新的十六進位值。OKLCH 能在不同色相間保持感知亮度步驟的一致性,這是單純的十六進位調整無法保證的。

4. 建立互動「浮升」效果

將 interactive-state-system 應用於 Z 軸:

  • 懸停(Hover): 增加陰影模糊和擴散範圍,模擬元素向使用者升起。
  • 作用中(Active / 點擊): 減少或移除陰影,模擬元素被按壓到表面之下。

5. 記錄堆疊策略(Z-Index)

使用 10 步或 100 步的數值範圍來防止「Z-Index 大戰」:

  • 0:預設值
  • 100:導航/頁首
  • 500:背景遮罩
  • 600:模態框/抽屜
  • 1000:工具提示/提示訊息

決策規則

  • 光源規則: 系統中所有陰影必須共享相同的隱含光源(通常是自上而下),以維持視覺邏輯。
  • 高度等於重要性: 最重要的臨時資訊(例如警報)應具有最高的高度和最顯著的陰影。
  • 陰影 vs. 邊框: 使用邊框來定義結構(層級 0-1),使用陰影來表達深度(層級 2+)。除非品牌風格高度「擬物化」,否則不要在相同元素上同時大量使用兩者。
  • 深色模式的高度: 在深色模式下,切勿在深色背景上使用深色陰影。應將表面顏色變亮(亮度偏移)作為主要的深度提示。

限制條件

  • 無障礙性: 高度提示(陰影)應作為結構性提示的輔助,而非取代。確保元素有足夠的對比或邊框,使其在沒有陰影的情況下仍可辨識。帶有高度設定的覆蓋層(模態框、下拉選單)絕不能出現在焦點指示器上方,以免遮擋或切斷它(WCAG 2.2 SC 2.4.11)。
  • 效能: 避免在頻繁動畫或位於高頻滾動容器內的元素上使用 box-shadow。
  • 響應式設計: 大陰影可能會在行動裝置上「溢出」螢幕;在小視口上應減少陰影擴散或改用邊框。

常見失敗模式

  • 不一致的光源: 有些陰影向右,有些向下,造成「搖晃」或破碎的介面。
  • Z-Index「魔術數字」: 使用 z-index: 99999 來解決問題,最終導致程式碼難以維護。
  • 渾濁的陰影: 使用純黑色(#000)作為陰影,而不是使用表面顏色的透明版本或深中性色。
  • 扁平覆蓋層: 設計一個沒有陰影或背景遮罩的模態框,使其與後方內容混為一體。
  • 過度設定高度: 給每個卡片都加上厚重的陰影,反而使層級扁平化,因為沒有東西能脫穎而出。

驗證標準

  • 已定義並使用一致的 5-6 步高度比例。
  • 所有陰影共享單一、一致的光源。
  • Z-index 數值已分組為邏輯、記錄明確的層級。
  • 深色模式使用表面亮度偏移來指示深度。
  • 互動狀態(懸停/活躍)包含垂直移動或陰影的變化。
  • 陰影不會在行動裝置上造成水平或垂直溢出。
  • 即使移除陰影,元素仍可區分(無障礙檢查)。
  • 較高層級的圖層從不遮擋其下方或內部元素的焦點指示器(WCAG 2.2 SC 2.4.11)。

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.

相關技能