# 更新日志 (/docs/changelog) > 同步自仓库 [CHANGELOG.md](https://github.com/Caho1/open-claude-ui/blob/main/CHANGELOG.md),原文为英文。 ## [Unreleased] [#unreleased] ### 🐛 Fixed (Issue #16 - Token Table Desync & Build Pipeline) [#-fixed-issue-16---token-table-desync--build-pipeline] - **Token Synchronization**: Calibrated `AGENTS.md` design token tables with `code-examples/cds-theme.css`, eliminating 14 undefined token discrepancies. - **Backward-Compatible Token Aliases**: Added aliases in `cds-theme.css` for `--cds-bg-surface-0` ~ `--cds-bg-surface-3`, `--cds-bg-input`, `--cds-text-tertiary`, `--cds-border-card`, `--cds-radius-pill`, `--cds-card-radius`, etc. - **Absolute Local Path Elimination**: Replaced 36 local absolute path links (`file:///Users/jiahao/...`) in `AGENTS.md` with standard repository-relative paths. - **Automated Token Gate**: Implemented `scripts/check-tokens.mjs` and npm script `npm run check:tokens` to verify token references in documentation against CSS definitions. - **Build Output & Package Exports**: Created `tsconfig.build.json` and updated `package.json` to emit compiled TypeScript to `dist/`, configured `"exports"` for `./css`, `./tokens`, and `./tailwind`, and added CI verification workflow `.github/workflows/ci.yml`. ### 🚀 Added (Issue #17 - Pure CSS Layer, Runtime Portability & Host Bridging) [#-added-issue-17---pure-css-layer-runtime-portability--host-bridging] - **Pure-CSS First-Class Exports**: Exposed `@import "open-claude-ui/css"`, `@import "open-claude-ui/tokens.css"`, and standalone `@import "open-claude-ui/pure.css"` for consuming design tokens, keyframes, and scroll-fade masks without React or Tailwind. - **Chromium 115+ Zero-JS `@property` Scroll-Fade Engine**: Implemented pure CSS `@property --cds-scroll-fade-*` `` registration driven directly by `animation-timeline: scroll(self block / inline)` with official 7-stop non-linear alpha mask, dropping scroll tracking CPU to 0.0% and main-thread blocking to 0ms. - **Runtime Portability Classification**: Added "运行时可移植性" (Runtime Portability) column across all 33 module inventory tables in `docs/v1/07-工程配置与资产代码库总览.md`, classifying modules into Pure CSS, Pure Logic / Headless, and React Component tiers. - **Host Bridge Mapping Guide**: Added Section 7.5 to Chapter 7 documenting the Host Aliasing pattern for integrating CDS tokens into custom desktop harnesses (e.g., DSH / Electron shells) or third-party web frameworks. - **Pure-CSS Scroll-Fade Utilities**: Added `.cds-scroll-fade`, `.cds-scroll-fade-vertical`, `.cds-scroll-fade-horizontal`, and `.cds-scroll-fade-static-v` utility classes in `code-examples/cds-theme.css`, alongside `data-cds-scroll-fade` support in `ScrollFadeContainer.tsx`. --- ## [1.1.0] - 2026-10-17 - Ground-Truth Precision Audit (PR #15) [#110---2026-10-17---ground-truth-precision-audit-pr-15] ### 🔍 REA v6.5.0 Ground-Truth Precision Audit (Chapter-by-Chapter) [#-rea-v650-ground-truth-precision-audit-chapter-by-chapter] > Based on deep AST analysis and runtime extraction from Claude Desktop `/Applications/Claude.app` (`@ant/desktop v2.37337.1`, build `2026-10-13T22:16:06Z`, ASAR evidence `ev_e0bd89cee50a5b7d0dbf9e75cef5dfbca2bcb1699df4d4371449dd08452a8358`) using **[REA (Reverse Engineer Anything) v6.5.0](https://github.com/morluto/rea)**. #### Chapter 1: Design Philosophy & Design Tokens (`docs/v1/01-设计哲学与设计令牌体系.md`) [#chapter-1-design-philosophy--design-tokens-docsv101-设计哲学与设计令牌体系md] - **35-Tier Grayscale & Orange Color Ramps**: - Replaced approximated surface hex values with the complete 35-tier grayscale spectrum (`--cds-gray-0` to `--cds-gray-900`) and 35-tier orange spectrum (`--cds-orange-0` to `--cds-orange-900`) extracted from `c6a992d55-sXiDGMFQ.css`. - Calibrated `--cds-surface-0` Light mode to `#f9f9f7` (`--cds-gray-20`, previously `#f5f5f3`) and Dark mode to `#0b0b0b` (`--cds-gray-900`, previously `#0b0b0a`). - Calibrated `--cds-surface-3` Dark mode to `#20201f` (`--cds-gray-800`, previously `#20201e`). - **OLED Anti-Banding Hex Law**: - Documented Anthropic's exact 2-level hexadecimal step decrement rule across dark surfaces (`800: #20201f` $\to$ `810: #1e1e1d` $\to$ `820: #1c1c1b` $\to$ ... $\to$ `900: #0b0b0b`), eliminating OLED banding. - **Official Brand Token Separation**: - Defined `--brand: #c6613f` as official desktop primary brand color, while retaining `--cds-clay: #d97757` for pulse indicators, spark icons, and terracotta highlights. - **Concentric Radius Formula & Card Token**: - Implemented the adaptive concentric radius formula `--radius-card: calc(var(--cds-radius) + calc(.25rem * var(--cds-rem-scale, 1)))` in `cds-theme.css`. - Added `'card': 'var(--radius-card, ...)'` to `tailwind.config.js` to ensure inner and outer curvatures maintain concentric harmony during viewport zoom. - **Scroll-Driven 28px Fade System**: - Formally specified `--cds-scroll-fade-size: 28px` (calibrated from 24px/32px approximations). - Documented the 4-stop non-linear relative color fade formula (`0%`, `13%` at 0.85 alpha, `40%` at 0.50 alpha, `70%` at 0.15 alpha, `100%` transparent) driven by CSS `scroll-timeline`. - **CJK Font Stack & Variable Axes**: - Integrated `--font-cjk-sans-fallback` (`PingFang SC`, `PingFang TC`, `Hiragino Sans`, `Apple SD Gothic Neo`) into default font stacks. - Added explicit variable font optical size axes (`--font-opsz-axis-title: "opsz" 28,;`, `--font-opsz-axis-heading: "opsz" 20,;`, `--font-opsz-axis-display: "opsz" 48,;`) and subpixel badge weight `--cds-badge-x-wght: 577.8`. - **Suite of 7 Production Physical Cubic-Bezier Curves**: - Expanded motion tokens from 3 generic curves to all 7 production bezier functions extracted from desktop bundles: - `--cds-ease-swift`: `cubic-bezier(.16, 1, .3, 1)` (hover/ghost buttons) - `--cds-ease-expand`: `cubic-bezier(.19, 1, .22, 1)` (Grid 0fr to 1fr accordion expand) - `--cds-ease-enter`: `cubic-bezier(.22, 1, .36, 1)` (block entry with 4px blur fade) - `--cds-ease-overshoot`: `cubic-bezier(.34, 1.3, .64, 1)` (jelly spring pop, +30%) - `--cds-ease-pop`: `cubic-bezier(.34, 1.56, .64, 1)` (high-stiffness modal pop, +56%) - `--cds-ease-pulse`: `cubic-bezier(.4, 0, .2, 1)` (quiet dot 1.9s pulse) - `--cds-ease-rise`: `cubic-bezier(.3, .7, .4, 1)` (status line enter rise) - `--cds-ease-fall`: `cubic-bezier(0, 0, .2, 1)` (status line exit fall) #### Chapter 2: Foundational Atoms & Controls (`docs/v1/02-基础原子组件与交互控件.md`) [#chapter-2-foundational-atoms--controls-docsv102-基础原子组件与交互控件md] - **5-Tier Button Height Scale & Nested Control Heights**: - Calibrated button sizes to official 5-tier scale: `xxs (18.8px, data-step="1")`, `xs (22.6px)`, `sm (26.35px)`, `md (30.1px desktop / 32px web, default)`, and `lg (37.65px desktop / 40px web)`. - Added official `--cds-h-control-nested` scale (17px, 18.8px, 20.7px, 26.35px) for toolbar/composer-nested controls. - **6 Production Button Variants & Paint Layer Decoupling**: - Extracted official variant matrix: `secondary` (default, borderless with `bg-fill-secondary`), `primary` (clay), `ghost` (`hover:bg-fill-ghost-hover`), `danger` (`bg-fill-danger`), `brand` (`--brand: #c6613f`), and `onContent` (media overlay with `backdrop-blur-md` and `var(--cds-button-on-content)`). - Implemented decoupled paint layer (`data-cds-part="paint"`) to isolate focus ring outlines from inner background/shadow fills. - **15-Stop CSS `linear()` Spring Curve & Button Squish Physics**: - Extracted official `--cds-btn-spring: linear(0, .2459, .6526, .9468, 1.0764, 1.0915, 1.0585, 1.0219, .9993, .9914, .9921, .9957, .9988, 1.0004, 1)` (+9.15% overshoot). - Implemented `.cds-btn-squish` with runtime height damping `Bl(h) = Math.min(1.5, Math.max(0.5, h * (1/32)))`. - **Segmented Control 1px Precision Geometry & Dual Container Breakpoints**: - Corrected track padding to strictly `1px` (not 2px) with `top: 1px; bottom: 1px;` indicator positioning. - Formally specified multi-breakpoint container query: `@container (width <= 180px)` for 2-tab pills and `@container (width <= 254px)` for 3-tab pills. - Extracted 0.5px hairline inset shadow: `inset 0 0 0 0.5px var(--cds-border), 0 1px 2px #0000000f, 0 2px 6px -1px #0000000d` (Light) and `inset 0 0 0 0.5px #ffffff14, 0 1px 2px #0000004d, 0 2px 6px -1px #00000040` (Dark). - **Official 6px Status Indicators & Accurate Trajectories**: - Standardized `.status-dot` to 6px diameter with 4 semantic kinds: `ready` (accent steady), `running` (1.2s dot blink), `error` (danger steady), and `clay` (3.0s breathe cycle from brightness 0.96 scale 0.86 to brightness 1.06 scale 1). - Specified `.timeline-quiet-dots` (3px dots, 3.5px gap, 1.9s cycle with 0s/0.15s/0.3s phase delays) and `cds-skeleton-sweep` (2s linear, 105deg angle, 255deg in RTL). - **6-Tier Confirmation Dialog Matrix & Nested Dialog Blur**: - Extracted official `Qg` dialog scale: `sm: max-w-[400px]`, `md: max-w-[520px]`, `lg: max-w-[720px]`, `xl: max-w-[880px]`, `2xl: max-w-[1024px]`, `3xl: max-w-[1152px]`. - Added dynamic `--environment-dialog-cap` formula and automated nested dialog blurring: `data-[nested-dialog-open]:blur-[2px]`. - **7.5rem Square Attachment Tiles & Bi-Directional Mid-Truncation**: - Corrected attachment card from 128x96px rectangle to exact square 7.5rem (`size-[calc(7.5rem * var(--cds-rem-scale, 1))]`, ~112.94px on desktop) with `rounded-card` and `shadow-field-drop`. - Documented floating remove button protocol: `absolute -end-2 -top-2 size-5 rounded-full bg-surface-3 shadow-card-ring`. - Recreated intelligent bi-directional mid-truncation (`head` + `…` + `tailStem` + `tailExt`) preserving file extension visibility. #### Chapter 3: Chat Stream & Composer Engine (`docs/v1/03-会话核心流与指令交互引擎.md`) [#chapter-3-chat-stream--composer-engine-docsv103-会话核心流与指令交互引擎md] - **Message Bubbles & Typography Scale (`[data-cds=UserMessage]`, `[data-cds=AssistantMessage]`)**: - Extracted exact bubble radius formula `--cds-message-bubble-radius: calc(var(--cds-radius) + calc(.25rem * var(--cds-rem-scale, 1)))` and padding `--cds-message-bubble-pad-x: var(--cds-pad-lg)` (16px), `--cds-message-bubble-pad-y: var(--cds-pad-md)` (12px). - Documented dynamic tinting: default `var(--cds-bg-neutral)` vs personal `#dde8f7` (Light) / `#193c5f` (Dark) with hover mixing `--feed-bubble-mix: 16%`. - Documented 300px collapse threshold with 3rem bottom decay mask: `[mask-image:linear-gradient(to_bottom,black_calc(100%_-_3rem),transparent)]`. - Extracted Assistant message Text Inset & Stop Law: `--cds-assistant-message-text-inset: 4px; --cds-assistant-message-text-stop: clamp(0px, (100% - 384px) * .175, 56px);` with `0px` reset when embedding cards or tables. - Documented vertical rhythm: `--chat-turn-gap = chat-body * chat-leading * 0.75` and `--chat-item-gap = chat-body * chat-leading * 0.5`. - **Thinking Accordion Timeline Physics (`.timeline-quiet-dots`, `.timeline-expand`)**: - Discovered exact `.timeline-quiet-dots` keyframe physics in `cc1aae219-DtZTxCKj.css` (3 dots, 3.5px gap, 3px diameter, 1.9s infinite `cubic-bezier(.4, 0, .2, 1)` with 0s/0.15s/0.3s delays). - Extracted CSS Grid 0fr $\leftrightarrow$ 1fr expansion (`.2s cubic-bezier(.19, 1, .22, 1) timeline-expand`) eliminating height recalculation reflow. - Documented status line entrance/exit physics: `.timeline-status-enter-quiet` (.24s rise 6px) and `.timeline-status-exit-quiet` (.18s fall -4px). - Implemented streaming generation lock (`isThinkingLive` locks `open=true` and suppresses toggle clicks). - **Composer Engine & WebKit 500ms Post-Composition Delta Guard**: - Discovered Anthropic's WebKit 500ms post-composition delta guard (`Lm() && Math.abs(e.timeStamp - Fm) < 500`) in `shared-frame-BfjMqbuN.js`, eliminating false Enter submissions following CJK IME selection. - Implemented capture-phase `beforeinput` interceptor preventing synthetic line breaks. - Reverse engineered Slash & Mention tokenizer (`cb6930dae-BD0W5ZM9.js`): CJK punctuation stripper `$o = /[.,;:!?'"\u3001\u3002\uFF0C\uFF1B\uFF1A\uFF01\uFF1F\u2026]+$/`, `rs = 1024` max path length, and 256 file mentions defense cap. - Implemented `field-sizing: content` with ghost element fallback and `max-h-[min(40svh,24rem)]` (384px) cap. - **Model Matrix & Prompt Caching Gauge**: - Updated official model architecture with Claude 3.7 Sonnet, Haiku 3.5, and Opus 3; documented deprecation of `thinking.type=enabled` in favor of `thinking.type=adaptive`. - Deconstructed 5m (`3e5` ms) and 1h (`36e5` ms) ephemeral cache token lifetimes with 4-part cost decomposition (`cache_read`, `cache_creation`, `input`, `output`). - Standardized circular SVG gauge formula: `strokeDashoffset = 2 * PI * r * (1 - ratio)` with 80% capacity alert threshold. - **MCP Decision Cards & Security Lifecycle**: - Reverse engineered 3-stage authorization lifecycle (`pending_approval`, `running`, `success`/`error`) with real settle reasons: `user_denied`, `policy_denied`, `PERMISSIONS_ERROR`. - Extracted `structured_content` parameter inspection and session whitelist map (`bs`) with 330s automatic garbage collection. #### Chapter 4: Motion Physics, Shaders & Ambient Systems (`docs/v1/04-动效物理学、着色器与环境光影.md`) [#chapter-4-motion-physics-shaders--ambient-systems-docsv104-动效物理学着色器与环境光影md] - **Native CSS Scroll-Driven Animations (`@supports (animation-timeline: scroll())`)**: - Documented native CSS scroll-driven mask declared via `@supports (animation-timeline: scroll())` in `c6a992d55-sXiDGMFQ.css`, delegating scroll fade entirely to the browser Compositor thread with zero JS overhead. - Configured 6 parallel animation timeline streams: `cds-scroll-fade-top`, `bottom`, `left`, `right`, `y-active`, `x-active` bound to `animation-timeline: scroll(self), scroll(self), scroll(self inline), scroll(self inline), scroll(self), scroll(self inline)`. - Extracted exact 7-stop non-linear alpha sampling mask (`transparent`, `#0000000d` at .15, `#00000026` at .3, `#0000004d` at .45, `#00000080` at .6, `#000000b3` at .75, `#000000d9` at .87, `#000` at 1.0). - **Variable Font Kinetic Engine (`[data-cds-anim]`)**: - Discovered CSS Houdini `@property --cds-anim` & `@property --cds-anim2` paired with `[data-cds-anim]` and variable font axes (`ANIM`, `ANM2`, `opsz`, `wght`) in `c6a992d55-sXiDGMFQ.css`. - Extracted mechanical overshoot transition `--cds-anim-ease: cubic-bezier(.34, 1.3, .64, 1)` (+30% bounce) driving focus/hover icon micro-animations. - **Ambient Reasoning Shaders & Accurate Keyframe Durations**: - Extracted exact keyframes from `c6a992d55-sXiDGMFQ.css`: - `wl-glow` (1.8s ease-in-out) & `wl-halo` (2.2s ease-in-out) utilizing modern `color-mix(in srgb, var(--cds-fill-brand) 60%, transparent)` pulsing to 85%. - `cds-shimmer-text-shine` (3s linear with asymmetric `cubic-bezier(.714, .121, .211, .888)`). - `epitaxy-linear-sweep` (strictly **1.1s** `cubic-bezier(.45, 0, .55, 1)` translating `-100%` to `350%`, RTL variant `100%` to `-350%`, correcting previous 1.6s estimate). - `epitaxy-check-draw` (0.18s `clip-path: inset(0 100% 0 0)` to `clip-path: inset(0)` at `--cds-ease-out`). #### Chapter 5: Audiovisual, Lightbox & Artifacts Experience (`docs/v1/05-视听多媒体与产物交互物理学.md`) [#chapter-5-audiovisual-lightbox--artifacts-experience-docsv105-视听多媒体与产物交互物理学md] - **AudioWorklet & SharedArrayBuffer RingBuffer (`audioSinkWorklet.js`)**: - Extracted complete production implementation of `audioSinkWorklet.js` from `/Applications/Claude.app/Contents/Resources/ion-dist/audio/voice/`. - Reverse engineered the lock-free atomic circular buffer (`RD=0`, `WR=1`, `UNDERRUNS=2`, `PLAYED=3`) running at ~375Hz (128 samples/quantum at 48kHz) with underrun counting gates and dry-gap stall guards. - **30% Comfortable Acoustic Standard & SFX Matrix**: - Documented 4 official interaction sound effects (`enter_voice_mode`, `exit_voice_mode`, `disconnected`, `tool_approval_needed`) with strict 30% volume limit and hardware routing via `AudioContext.setSinkId()`. - **LiveMicActivityBars 6-Band Gamma Physics**: - Extracted 512-point FFT AnalyserNode configuration (`smoothingTimeConstant = 0.5`, `minDecibels = -70`, `maxDecibels = -10`). - Documented 6 speech bands (85Hz-4.8kHz), 8% noise gate (`Math.max(0, u - 0.08) / 0.92`), and 0.7-power non-linear Gamma energy compression (`Math.pow(gated, 0.7) * 1.5 * weight`) driving 4px-24px height. - **MediaLightboxViewer Pan/Zoom & 75vw Runway**: - Extracted physical constants: `ae=2` max zoom, `oe=4px` gesture dead-zone, `se=0.01` wheel exponential factor, `v=1.05` snap threshold. - Implemented cursor-anchored affine zoom equations keeping pointer coordinates fixed during zoom. - Documented View Transitions FLIP morphing with 5-level DOM ancestor radius discovery and `object-fit: contain` inner inset calculation. - Specified 75vw runway with $\pm 2$ virtual preloading and `.animate-lightbox-backdrop-in` (.2s) / `.animate-lightbox-content-in` (.25s). - **Artifacts SplitPane & Epitaxy Sandbox**: - Implemented pointer stream shield (`data-pane-dragging="true"` with transparent `pointer-events: none` overlay on child iframes). - Reverse engineered 50/50 double-click snap, 4px dead-zone with Escape cancellation, and 18% / 82% docking thresholds. - Enforced strict null-origin sandbox isolation (excluding `allow-same-origin`) with native `event.userActivation` verified gating. - **StreamingDiffViewer & Production Diff Variables**: - Extracted exact variables from `.epitaxy-root .epitaxy-diff` in `c6a992d55-sXiDGMFQ.css`: `--diffs-font-size`, `--diffs-line-height`, `--diffs-font-family`, `--diffs-header-font-family`, `--diffs-addition-color-override`, `--diffs-deletion-color-override`, `--diffs-modified-color-override`, `--diffs-gap-inline`, `--diffs-gap-block`. - Implemented Shadow DOM isolation with CSS Grid row height locking (`gridRow = span ${v}`), incremental stream chunk feed, and 2.5s copy check decay state machine (`saved-check-decay`). - **Bidirectional Streaming Voice Architecture (Section 5.1.5)**: - Reverse engineered `frame-shell-dictate-C9D4b04p.js` & `frame-shell-speak-CBGDxR0k.js`. - Documented STT Dictation (`openDictation`): 1-hour session limit (`36e5` ms), pause settling (`settleAtPauses: true`), and prefix differential delta algorithm `l(f, e)`. - Documented TTS Reading (`openReading`): 24kHz wideband audio pipeline (`sampleRate: 24000`), dynamic playback rate, and real-time word position events for Karaoke text highlighting. #### Chapter 6: Desktop Host Architecture & Multi-Agent Topology (`docs/v1/06-系统级桌面架构与协作拓扑.md`) [#chapter-6-desktop-host-architecture--multi-agent-topology-docsv106-系统级桌面架构与协作拓扑md] - **Host BrowserWindow + Transparent WebContentsView**: - Deconstructed Electron dual-layer decoupled architecture from `index.chunk-CiiI592G.js`. - Implemented native macOS traffic light inverse zoom compensation formula `Math.max(0, Math.round((pos + 6) * zoom - 6))` with baseline 16.5px and diameter 12px. - Documented 8px dynamic window radius collapsing to 0px on maximize/fullscreen, and instant theme background coloring (`#151515` / `#fcfcfb`). - **Sidebar Topological Drag-and-Drop**: - Implemented `pinnedOrder: string[]` optimistic mutation, 4px pointer drag dead-zone, -1.5° ghost elevation tilt, and 2px terracotta midpoint collision drop indicator. - **Cowork Multi-Agent Canvas**: - Deconstructed task delegation state machine (`idle` $\to$ `running` $\to$ `waiting_review` $\to$ `completed`), shared artifacts pool, and cross-window `BroadcastChannel` synchronization. - **Streaming Scroll Pinning Physics**: - Implemented 150ms user input cooldown window, 40px bottom tolerance, 35vh bottom padding cushion (`--chat-extra-space`), and `behavior: auto` instantaneous bottom alignment. - **4-Tier Container Query Compression**: - Eliminated window media query squash defects via `@container` rules (>=576px full, <480px compact, <384px icon-only, <320px anti-overflow safe net with `cqw`). - **Roving Focus & Rate Limit Backoff**: - Implemented W3C WAI-ARIA roving tabindex grid with RTL mirror flipping. - Implemented 429/503 exponential backoff (`min(max(base, 5000) * 2^(n-1) * (1 ± J), 600000)`) with $\pm 15\%$ full jitter and 3-retry max ceiling before mandatory manual takeover. - **Broker-Replica Multi-Window Architecture & Baseline Conflict Arbitration (Section 6.8)**: - Reverse engineered `frame-shell-broker-znyoRmsX.js` and `frame-shell-replica-C7KCVFfZ.js`. - Documented IPC master-replica topology with `ReplicaWriter` immutable state stream distribution. - Deconstructed working mount write-lock arbitration preventing concurrent destructive file writes via `baseline-mismatch` assertions. #### Chapter 7 & 8: Engineering Setup & AI Agent Guidelines (`docs/v1/07-工程配置与资产代码库总览.md`, `docs/v1/08-AI-Agent-前端-UI-与动效开发指南.md`) [#chapter-7--8-engineering-setup--ai-agent-guidelines-docsv107-工程配置与资产代码库总览md-docsv108-ai-agent-前端-ui-与动效开发指南md] - **Complete 30-Module Production Asset Inventory**: - Audited and updated the production asset inventory table covering all 30 standalone code examples in `code-examples/`. - **Aligned Tailwind Extension & Global CSS Tokens**: - Synchronized `tailwind.config.js` and global CSS with the official 35-tier grayscale/orange color ramps and verified surfaces. - **Modern Underlying Runtime Architecture: Rolldown, WASM Matrix & Clarkdown Compiler (Section 7.4)**: - Deconstructed Rolldown Rust bundler runtime (`rolldown-runtime-C3OYiQ02.js`) managing 4000+ chunks with sub-second startup and zero-overhead inlining. - Reverse engineered tri-WASM engine matrix: 8.25MB client-side offline `.docx` parser (`cf4728005-C0phcBAH.wasm`), 1.35MB Clarkdown compiler (`c35955a62-DsUXHNAG.wasm`), and 204KB Tree-sitter incremental syntax parser (`c571a2685-sT_OTiSe.wasm`). - Documented Clarkdown proprietary formats (`.clark` / `.cd`) and dual host topology (`createLocalDocumentHost`, `createRemoteDocumentHost`). - **Strict AI Agent Quality Gates**: - Formulated strict rules for agentic code generation: single-stroke border discipline, WebKit 500ms IME post-composition guard, procedural Web Audio synthesis, and zero-error TypeScript build requirement. --- ## [1.0.1] - 2026-10-16 [#101---2026-10-16] ### 🐛 Fixed (Community Issues #9 – #13) [#-fixed-community-issues-9--13] - **`DiffViewer` Header Rendering (Issue #9)**: - Fixed issue where the sticky file header, path icon, and badge statistics failed to render when `chunks` array was empty. The header now always renders reliably with complete metadata. - **`SortableList` Drag-and-Drop Index (Issue #10)**: - Fixed off-by-one error when dragging an item past the end of the list. The drop target index is now properly clamped to `items.length - 1`. - **`PromptInput` IME Composition Enter Guard (Issue #11)**: - Added `isComposing` guard to `onKeyDown` to prevent CJK IME candidate selection (Enter key) from prematurely triggering message submission. - **`MediaLightbox` Pan Boundary Constraints (Issue #12)**: - Added dynamic clamp bounds `[-maxPanX, maxPanX]` and `[-maxPanY, maxPanY]` based on current zoom scale, preventing media from being panned completely out of view. - **`ViewTransitionPortal` Timing Collision (Issue #13)**: - Synchronized `view-transition-name` assignment with `ReactDOM.flushSync` and cleanup hooks, avoiding DOM transition name collision errors during rapid route changes. ### 📝 Documentation & Community [#-documentation--community] - Merged community fixes via PR [#14](https://github.com/Caho1/open-claude-ui/pull/14) with acknowledgments to contributors `@alexanderchen-ai`, `@dev-liu-kevin`, `@sakura-code99`, `@marcus-web-eng`, and `@t-h-tanaka`. - Added dynamic interactive Star History chart to `README.md`. - Clarified repository description: *"还原 30 个独立 React 组件与 8 项硬核交互物理算法"*. --- ## [1.0.0] - 2026-10-14 [#100---2026-10-14] ### 🎉 Initial Release [#-initial-release] - **30 Standalone React Components**: - Production-ready, TypeScript-strictly-typed UI component implementations recreating Claude Desktop's design system. - Buttons, Segmented Controls, Status Indicators, Confirmation Dialogs, Attachment Cards, Message Bubbles, Thinking Accordions, Chat Composer, Artifacts Sandbox, Media Viewer, Split Panes, Diff Viewer, and more. - **8 Hardcore Interaction & Motion Physics Algorithms**: - True Spring Physics (`stiffness: 400`, `damping: 32`). - Web Audio API real-time AudioWorklet microphone visualizer. - Retina 0.5px hairline rendering with media query scaling. - Triple-layer focus ring and dual-ring composer elevation. - Container query responsive folding (`@container`). - CSS Grid 0fr $\to$ 1fr height jitter elimination. - Retinal irradiation weight compensation for dark mode (`-40` wght offset). - WebKit 16px mobile input zoom prevention threshold. - **Complete CDS Engineering Manual**: - 9-chapter exhaustive reverse-engineering specification covering design tokens, atom controls, conversation flows, motion shaders, audiovisuals, desktop integration, Tailwind configurations, and Agent UI assembly. # 基础原子组件 (/docs/components/atoms) 基础原子组件是 Claude 桌面端界面里最底层、复用最多的控件:按钮、分段控制器、状态灯、确认弹窗和附件磁贴。它们的高度、圆角和按压反馈都来自同一套令牌,所以放在一起看最容易对上规格。本页 8 个演示对应手册 v1 第二篇,2.0 的变化标在各节里。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | 按钮高度阶梯 | `XXS 20 · XS 24 · SM 28 · MD 32 · LG 40px` | v1/02 §2.1.1 | | 按钮变体 | `primary / secondary / ghost / danger / brand / onContent / outline` | v1/02 §2.1.2 | | 状态灯直径 | `6px` | v1/02 §2.3 | | 思考波浪周期 | `1.9s` | v1/02 §2.3 | | 弹窗宽度 | `sm 400 · md 520 · lg 720px` | v1/02 §2.4 | | 附件磁贴 | `7.5rem 正方形` | v1/02 §2.5 | ## 按钮变体 [#按钮变体] 按钮有 7 个变体,区别只在填充和描边,尺寸与按压回弹共用一套规则。 ## 按钮尺寸与加载态 [#按钮尺寸与加载态] 5 档高度从 20px 到 40px;加载时按钮保留原宽度,只把文字换成转圈,避免布局跳动。 ## 组合按钮 [#组合按钮] 把几个按钮拼成一组时,相邻一侧去掉圆角,中间共用一条 1px 分隔线。 ## 分段控制器 [#分段控制器] 分段控制器用一个滑动的选中块表示当前项,多个实例互不干扰。 ## 状态灯与骨架屏 [#状态灯与骨架屏] 状态灯、呼吸灯、思考三点和骨架屏扫光是界面里所有“进行中”状态的视觉语言。 ## 确认弹窗 [#确认弹窗] 确认弹窗按 3 档宽度取值,危险操作的确认按钮用 danger 变体。 ## 附件磁贴与胶囊 [#附件磁贴与胶囊] 附件以正方形磁贴展示,长文件名从中间截断,保留扩展名。 ## 容器查询工具栏 [#容器查询工具栏] 工具栏按自身容器宽度(@container)收缩,而不是按窗口宽度。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```tsx import { CdsButton } from './CdsButton'; 发送 ``` ## 相关页面 [#相关页面] - [会话与输入](/docs/components/conversation) - [2.0 新增](/docs/components/v2) - [v1 第二篇](/docs/v1/02) - [全部 Open Claude UI 组件演示](/docs/components) # 会话与输入 (/docs/components/conversation) 会话与输入是 Claude 对话界面的核心:消息气泡、思考过程折叠、输入框、斜杠指令与 @ 引用、模型切换,以及 MCP 工具调用的授权卡片。本页 6 个演示对应手册 v1 第三篇,输入框圆角按 2.0 的 14px 取值。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | 输入框圆角 | `2.0 舒适 14px · 紧凑 12px(1.x 为 20px)` | v2/03 §3.3 | | 思考展开方式 | `CSS Grid 0fr → 1fr` | v1/03 §3.2 | | 输入法合成守卫 | `compositionend 后 500ms 内忽略 Enter` | v1/03 §3.3.2 | | MCP 授权按钮 | `允许一次 / 始终允许 / 拒绝` | v1/03 §3.5 | ## 消息气泡 [#消息气泡] 用户消息用气泡,助手回复不加底色,直接铺在画布上。 ## 思考折叠面板 [#思考折叠面板] 模型思考时显示计时和三点波浪,结束后折叠,可以点开看全文。 ## 输入框 [#输入框] 输入框是界面里圆角最大的元素,2.0 从 20px 收到 14px。 ## 指令与引用输入 [#指令与引用输入] 输入 / 唤出指令,输入 @ 引用文件;中文输入法选词时按 Enter 不会误发送。 ## 模型切换与 Token 仪表盘 [#模型切换与-token-仪表盘] 模型下拉旁边有一个环形仪表盘,按上下文用量显示进度,并区分缓存读取和写入。 ## MCP 工具决策卡片 [#mcp-工具决策卡片] 代理通过 MCP 调用工具前会弹出授权卡片,状态从等待批准走到运行中,再到成功、拒绝或失败。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```tsx import { ChatComposer } from './ChatComposer'; console.log(text)} /> ``` ## 相关页面 [#相关页面] - [基础原子组件](/docs/components/atoms) - [动效与光影](/docs/components/motion) - [v1 第三篇](/docs/v1/03) - [全部 Open Claude UI 组件演示](/docs/components) # 桌面架构与交互 Hook (/docs/components/desktop) 桌面架构与交互 Hook 讲的是 Claude Desktop 作为 Electron 应用特有的部分:可拖拽的窗口顶栏、会话列表排序、多代理(Cowork)协作看板,以及滚动跟随、漫游焦点、共享元素转场和限流退避这几个 React Hook。本页 7 个演示对应手册 v1 第六篇。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | macOS 红绿灯预留 | `74px` | v1/06 §6.1 | | 顶栏拖拽带 | `45px` | v1/06 §6.1 | | 拖拽判定阈值 | `移动 4px 以内不算拖拽` | v1/06 §6.2 | | 代理任务状态 | `idle → running → waiting_review → completed / errored` | v1/06 §6.3 | | 限流退避 | `基准 5 秒,指数翻倍,封顶 10 分钟` | v1/06 §6.7 | ## 桌面顶栏 [#桌面顶栏] 顶栏左侧给 macOS 红绿灯留位,空白处可拖动窗口,按钮区域不响应拖拽。 ## 会话列表拖拽排序 [#会话列表拖拽排序] 置顶会话可以拖拽重排,也可以用键盘上移、下移。 ## 多代理协作看板 [#多代理协作看板] Cowork 看板显示多个代理的子任务状态和共享产物。 ## 流式输出滚动跟随 [#流式输出滚动跟随] 在底部时自动跟随流式输出,用户往上翻就停止跟随。 ## 漫游焦点 [#漫游焦点] 列表里只有一个可 Tab 聚焦的元素,用方向键在项目之间移动。 ## 共享元素转场 [#共享元素转场] 用 View Transitions API 让缩略图平滑放大成预览。 ## 限流退避 [#限流退避] 遇到限流时按指数退避等待,倒计时结束自动重试。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```tsx import { useClaudeScrollPinning } from './useClaudeScrollPinning'; const { containerRef, isPinned, showJumpControl, handleScroll, scrollToBottom } = useClaudeScrollPinning([messages]); ``` ## 相关页面 [#相关页面] - [多媒体与产物](/docs/components/media) - [v1 第六篇](/docs/v1/06) - [分析 Claude 桌面端界面](/reverse-engineering-claude) - [全部 Open Claude UI 组件演示](/docs/components) # Open Claude UI 组件演示 (/docs/components) 这里的组件都是真实运行的 React 代码,直接引自仓库的 [code-examples/](https://github.com/Caho1/open-claude-ui/tree/main/code-examples),样式变量来自 `cds-theme.css`。按手册章节分页,右上角可以切换深色模式;系统开启“减少动态效果”时动画会停掉。 | 页面 | 手册章节 | 内容 | |---|---|---| | [基础原子组件](/docs/components/atoms) | v1 第二篇 | 按钮、组合按钮、分段控制器、状态灯、骨架屏、确认弹窗、附件磁贴、容器查询工具栏 | | [会话与输入](/docs/components/conversation) | v1 第三篇 | 消息气泡、思考折叠、输入框、/ 与 @ 输入、模型切换与 Token 仪表盘、MCP 工具卡片 | | [动效与光影](/docs/components/motion) | v1 第四篇 · v2 第四篇 | 时长与缓动、弹簧参数、2.0 动效引擎、推理光晕与扫光、滚动渐隐 | | [多媒体与产物](/docs/components/media) | v1 第五篇 | 语音波形、图片查看器、双栏分割、产物沙箱、Diff 查看器、代码块 | | [桌面架构与交互 Hook](/docs/components/desktop) | v1 第六篇 | 桌面顶栏、会话拖拽排序、多代理看板、滚动跟随、漫游焦点、共享元素转场、限流退避 | | [2.0 新增](/docs/components/v2) | v2 第二、三、五篇 | 算力调节器、输入框底栏、sibling-index 交错、Pill 过冲、发丝边与触控补偿 | **没有放演示的部分**:`ClaudeAudioPlayer.ts`(复刻官方提示音,属于官方声音资产,不收录)、`createClaudeMainWindow.ts`(Electron 主进程代码,浏览器里跑不了)、`tailwind.config.js` / `cds-theme.css` / `cds-pure.css`(配置与样式表,已经在全站使用)。 站点不包含任何 Anthropic 官方素材:图标统一用 lucide,组件里原本的 emoji 和品牌图标位置换成了中性图标,图片是生成的占位图。 数值的来源与分析方法见 [分析 Claude 桌面端界面](/reverse-engineering-claude)。 # 多媒体与产物 (/docs/components/media) 多媒体与产物覆盖语音、图片、代码和 Artifacts(产物)相关的界面:麦克风波形、图片查看器、产物双栏、沙箱 iframe、Diff 和代码块。本页 6 个演示对应手册 v1 第五篇;官方提示音属于官方资产,没有收录。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | 语音波形 | `6 频段,非线性 Gamma 映射` | v1/05 §5.1.3 | | 双栏折叠阈值 | `拖到边缘 18% 以内折叠` | v1/05 §5.3 | | 代码块外壳 | `12px 圆角,36px 头部` | v1/05 §5.5.4 | | 复制成功提示 | `绿色勾 2.5 秒后淡出` | v1/05 §5.5.4 | ## 语音波形 [#语音波形] 语音输入时用 6 根柱子显示音量,演示可以接本地麦克风,声音不上传。 ## 图片查看器 [#图片查看器] 图片查看器以光标为锚点缩放,支持拖动、方向键切换和 Esc 关闭。 ## 双栏分割 [#双栏分割] 对话和产物并排时,中间分隔条可拖动,双击回到对半。 ## 产物沙箱 [#产物沙箱] 产物在沙箱 iframe 里运行,通过 postMessage 和宿主页面通信。 ## Diff 查看器 [#diff-查看器] 代码改动用增删行底色区分,可在统一视图和分栏视图之间切换。 ## 代码块 [#代码块] 代码块是深色外壳,带文件名和复制按钮。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```tsx import { CodeBlock } from './CodeBlock'; ``` ## 相关页面 [#相关页面] - [会话与输入](/docs/components/conversation) - [桌面架构与交互 Hook](/docs/components/desktop) - [v1 第五篇](/docs/v1/05) - [全部 Open Claude UI 组件演示](/docs/components) # 动效与光影 (/docs/components/motion) 动效与光影汇总了 Claude 桌面端的时间和曲线:5 档时长令牌、缓动曲线、Framer Motion 弹簧参数,以及推理中的光晕和滚动渐隐。本页 5 个演示对应手册 v1 第四篇和 v2 第四篇,数值以 2.0 为准。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | 时长 | `fast 60 · snap 120 · base 200 · sheet 300 · slow 450ms` | v2/04 §4.3 | | ease-out | `cubic-bezier(.165, .84, .44, 1)` | v2/04 §4.3 | | ease-snap | `cubic-bezier(.32, .72, 0, 1)` | v2/04 §4.3 | | ease-overshoot | `cubic-bezier(.34, 1.3, .64, 1)` | v2/04 §4.3 | | 推理光晕呼吸 | `1.8s` | v1/04 §4.2 | | 滚动渐隐 | `28px` | v1/04 §4.3 | ## 时长与缓动 [#时长与缓动] 所有过渡从 5 档时长里取值,曲线从 cds-theme.css 的缓动令牌里取值。 ## 弹簧参数 [#弹簧参数] 需要物理回弹的地方用 Framer Motion 弹簧,4 套参数对应不同的“重量”。 ## 2.0 动效引擎 [#20-动效引擎] 2.0 把常见动效改成纯 CSS 实现,不依赖 JS 动画库。 ## 推理光晕与扫光 [#推理光晕与扫光] 模型推理时,输入区周围有暖色光晕,文字有扫光,表示“正在想”。 ## 滚动渐隐 [#滚动渐隐] 可滚动区域的边缘用遮罩渐隐 28px,停在顶部时顶边不渐隐。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```css .panel { transition: transform var(--cds-dur-base) var(--cds-ease-out); } ``` ## 相关页面 [#相关页面] - [2.0 新增](/docs/components/v2) - [v2 第四章](/docs/v2/04) - [v1 第四篇](/docs/v1/04) - [全部 Open Claude UI 组件演示](/docs/components) # 2.0 新增 (/docs/components/v2) 2.0 新增收录 Claude Desktop 2.0 引入或重做的界面:推理算力调节器、输入框底部工具栏、sibling-index() 交错入场、Pill 过冲回弹、发丝边与触控补偿、骨架屏双模。本页 6 个演示对应手册 v2 第二、三、五章。 ## 关键数值 [#关键数值] | 项目 | 数值 | 出处 | |---|---|---| | Pill 过冲 | `80ms 放大到 1.32× → 120ms overshoot 回落` | v2/03 §3.5.1 | | 交错入场 | `延迟 = 序号 × 步长(sibling-index())` | v2/02 §2.5.1 | | 骨架屏 lockstep | `2.0s 周期,暗到 60%` | v2/03 §3.5.2 | | 骨架屏 wave | `每块延迟 序号 × 90ms,105° 扫光` | v2/03 §3.5.2 | | 发丝边 | `0.5px` | v2/02 §2.7 | | 触控补偿 | `(h-control − 行高) / 2` | v2/02 §2.8 | ## 推理算力调节器 [#推理算力调节器] 2.0 在模型菜单里加了推理算力档位,决定模型思考多久。 ## 输入框底部工具栏 [#输入框底部工具栏] 输入框底部一栏放算力档位和发送失败消息的重试入口。 ## sibling-index 交错入场 [#sibling-index-交错入场] 用 CSS 的 sibling-index() 按序号延迟入场,不写 JS。 ## Pill 过冲回弹 [#pill-过冲回弹] 胶囊出现时先放大再回弹,分两段完成,总长 200ms。 ## 发丝边与触控补偿 [#发丝边与触控补偿] 2.0 用 0.5px 边框;底栏按钮看起来小,点击区用负外边距补大。 ## 骨架屏双模 [#骨架屏双模] 骨架屏有整组同步闪烁和逐块波浪两种模式,分别适合列表和大卡片。 ## 怎么在项目里使用? [#怎么在项目里使用] 复制 [code-examples/](https://github.com/Caho1/open-claude-ui/blob/main/code-examples) 里对应的文件,并引入 `cds-theme.css`。例如: ```css .chip { animation-delay: calc(var(--cds-chip-in-base-delay, 50ms) + min(sibling-index() - 1, 8) * 30ms); } ``` ## 相关页面 [#相关页面] - [动效与光影](/docs/components/motion) - [v2 第二章](/docs/v2/02) - [v2 第三章](/docs/v2/03) - [全部 Open Claude UI 组件演示](/docs/components) # 开始 (/docs) open-claude-ui 把 Claude 官方桌面端的界面拆开,用 React 重新写了一遍,同时附上完整的分析手册。 - [Open Claude UI 组件演示](/docs/components):直接在页面里点一点真实组件。 - [Open Claude UI 分析手册(2.0)](/docs/v2):Claude Desktop 2.0 新增和重构的部分。 - [Open Claude UI 分析手册(1.x)](/docs/v1):设计令牌、原子组件、动效与系统架构。 安装: ```bash npm i github:Caho1/open-claude-ui ``` 源码:[github.com/Caho1/open-claude-ui](https://github.com/Caho1/open-claude-ui) 想了解这些数值是怎么得到的,见 [分析 Claude 桌面端界面](/reverse-engineering-claude)。 # 01-设计哲学与设计令牌体系 (/docs/v1/01)

[📚 返回总目录](Claude%20Design%20System%20(CDS).md) · [下一篇:第二篇:基础原子组件与交互控件 ➡️](02-基础原子组件与交互控件.md)

--- ## 第一篇:设计哲学与设计令牌体系 [#第一篇设计哲学与设计令牌体系] > **技术领域与英文指代**:`Design Philosophy & Design Tokens` ### 1.1 设计哲学与视觉调性 [#11-设计哲学与视觉调性] Claude 的界面设计在当下 AI 产品中独树一帜,其核心调性可以总结为三点: 1. **温润的人文质感(Editorial Warmth)**: - 彻底摒弃冰冷的高饱和赛博朋克蓝/紫色,主品牌色选用温润的**陶土色(Clay: `#d97757`)**与柔和米白/暗灰底色(`#fcfcfb` / `#151515`)。 2. **多层微对比表面(Low-contrast Surface Layering)**: - 界面几乎不使用生硬的 1px 黑色边框,而是通过 `Surface 0 - 3` 的层级微小明度差以及 `color-mix()` 半透明外环投影来建立空间感。 3. **高帧率轻负担动效(Lightweight Organic Motion)**: - 文字流式输出使用 GPU 硬件加速的模糊消解,复杂展开使用 CSS Grid 0fr 解决高度抖动,手势交互使用真实的阻尼弹簧。 --- ### 1.2 表面体系与色彩阶梯 [#12-表面体系与色彩阶梯] > **技术领域与英文指代**:`Surfaces & Colors` 依据 REA (Reverse Engineer Anything) v6.5.0 对生产构建包 `c6a992d55-sXiDGMFQ.css` 的全量 AST 审计,Claude 并非使用孤立的零散色值,而是建立在**完整的 35 阶灰度标尺(`--cds-gray-0` 至 `--cds-gray-900`)**与**35 阶橙色标尺(`--cds-orange-0` 至 `--cds-orange-900`)**之上的高精密光学投影体系。 ```mermaid graph TD S0["Surface 0: 侧边栏/底基层 (Canvas)"] S1["Surface 1: 页面主背景画布 (Chat Page)"] S2["Surface 2: 独立面板/卡片表面 (Cards)"] S3["Surface 3: 输入框/悬浮弹窗/最高层 (Overlays)"] S0 --> S1 --> S2 --> S3 ``` | 令牌名称 | 浅色模式 (Light) | 深色模式 (Dark) | 真实绑定 Token | 用途说明 | | :--- | :--- | :--- | :--- | :--- | | `--cds-surface-0` | **`#f9f9f7`** | **`#0b0b0b`** | `var(--cds-gray-20)` / `var(--cds-gray-900)` | 侧边栏底色、窗口背景根底 | | `--cds-surface-1` | **`#fcfcfb`** | **`#151515`** | `var(--cds-gray-10)` / `var(--cds-gray-850)` | 页面主聊天画布背景 | | `--cds-surface-2` | **`#ffffff`** | **`#1a1a19`** | `var(--cds-gray-0)` / `var(--cds-gray-830)` | 对话消息容器、卡片表面 | | `--cds-surface-3` | **`#ffffff`** | **`#20201f`** | `var(--cds-gray-0)` / `var(--cds-gray-800)` | 聊天输入框容器、高亮浮层 | | `--brand` | **`#c6613f`** | **`#c6613f`** | 桌面端全局生产主品牌色 | 官方桌面端主品牌色 | | `--cds-clay` | **`#d97757`** | **`#d97757`** | 品牌陶土主色 | 思考脉冲点、火花图标回退色 | | `--cds-clay-emphasized` | **`#cc5a36`** | **`#cc5a36`** | 陶土色悬停加重态 | 悬停态加深交互色 | | `--cds-border` | `hsla(0, 0%, 8%, 0.10)` | `hsla(0, 0%, 100%, 0.09)` | `var(--cds-alpha-2)` | 通用柔和边框 | | `--cds-border-strong` | `hsla(0, 0%, 8%, 0.20)` | `hsla(0, 0%, 100%, 0.18)` | `var(--cds-alpha-3)` | 控件外环、激活边框 | > [!TIP] > **Anthropic 暗色模式 2-Level 等距步进律(OLED Anti-Banding)**: > REA 分析表明,Claude 深色表面严格遵守十六进制等距步进: > `--cds-gray-800` (`#20201f`) $\to$ `810` (`#1e1e1d`) $\to$ `820` (`#1c1c1b`) $\to$ `830` (`#1a1a19`) $\to$ `840` (`#181817`) $\to$ `850` (`#151515`) $\to$ `860` (`#131313`) $\to$ `870` (`#111111`) $\to$ `880` (`#0f0f0f`) $\to$ `890` (`#0d0d0d`) $\to$ `900` (`#0b0b0b`)。 > 每一阶明度均精确下沉 2 个 HEX 单位,彻底消除了 OLED 屏幕上的灰阶断层色斑。 --- ### 1.3 控件尺寸与精密圆角矩阵 [#13-控件尺寸与精密圆角矩阵] > **技术领域与英文指代**:`Border Radius, Heights & Sizing` #### 1.3.1 圆角阶梯体系 (Border Radius Hierarchy) [#131-圆角阶梯体系-border-radius-hierarchy] 在生产构建样式中,完整圆角令牌与嵌套公式如下: | 令牌名称 / 变量 | 精确像素 | 对应 Tailwind 类 | 角色语义与典型组件 | | :--- | :--- | :--- | :--- | | `--radius-xs` | **2px (`.125rem`)** | `rounded-[2px]` | 微型角标、聚焦环内衬指示点 | | `--radius-sm` (`--cds-keycap-radius`) | **4px (`.25rem`)** | `rounded` | 快捷键徽章 (`Kbd`)、微型标签、复选框 | | `--radius-md` | **6px (`.375rem`)** | `rounded-md` | 极小尺寸按钮 (XS 26px)、Prompt 建议胶囊 | | `--radius-lg` | **8px (`.5rem`)** | `rounded-lg` | **标准按钮 (SM/MD)、表单输入框、下拉菜单项** | | `--cds-panel-radius` | **10px** | `rounded-[10px]` | 子面板卡片、上传文件附件条目 (`.cds-attachment`) | | `--radius-xl` | **12px (`.75rem`)** | `rounded-xl` | 代码块容器、Artifact 预览卡片、抽屉面板 | | `--radius-2xl` | **16px (`1rem`)** | `rounded-2xl` | 系统弹窗模态框 (`ConfirmationDialog`)、设置卡片 | | `--cds-message-bubble-radius` | **18px** | `rounded-[18px]` | **用户发送的消息气泡 (`User Message Bubble`)** | | `--cds-radius-composer` | **20px** | `rounded-[20px]` | **底部常驻聊天输入框 (`Chat Composer Box`)** | | `--radius-card` | `calc(var(--cds-radius) + 4px * scale)` | `rounded-card` | **卡片自适应嵌套同心圆角(动态响应缩放因子)** | | `--df-radius-pill` | **999px** | `rounded-full` | 分段滑动滑块 (`Segmented Control`)、状态呼吸点 | > [!IMPORTANT] > **REA v6.5.0 取证:自适应嵌套同心圆角公式**: > ```css > --radius-card: calc(var(--cds-radius) + calc(.25rem * var(--cds-rem-scale, 1))); > ``` > 在 Claude 中,卡片外圈曲率严格绑定内部 `--cds-radius` 加上 `.25rem * --cds-rem-scale`,从而在用户缩放页面或调整辅助功能大字号时,内外角曲率永远保持平滑同心。 --- #### 1.3.2 控件高度与排版尺寸 (Heights & Sizing) [#132-控件高度与排版尺寸-heights--sizing] | 令牌名称 | 高度定义 | 实际像素 | 对应组件 | | :--- | :--- | :--- | :--- | | `--cds-h-control--xs` | `1.25rem - 1.5rem` | **20px - 24px** | 极小按钮、标签关闭按钮、行内操作栏 | | `--cds-h-control--sm` | `1.5rem - 1.75rem` | **24px - 28px** | 紧凑型按钮、下拉选择器触发器 | | `--cds-h-control` (默认) | `2rem` | **32px** | **标准交互按钮、输入框内操作图标、Tab 导航项** | | `--cds-h-control--lg` | `2.5rem` | **40px** | 强调大按钮、登录/注册主操作按钮 | | `--df-titlebar` | 固定 `46px - 48px` | **46px - 48px** | 桌面端无边框窗口顶部拖拽条(Titlebar) | | `--static-sidebar-width` | `18rem` | **288px** | 桌面端常驻侧边栏宽度 | | `--chat-max-width` | `42rem / 48rem` | **672px - 768px** | 最佳阅读体验的中心对话宽度(`max-w-2xl / max-w-3xl`) | | `--composer-max-height` | `24rem` | **384px** | 输入框内容自动撑开的最大高度(超出滚动) | --- --- ### 1.4 发丝细边、微光阴影与边框防臃肿体系 [#14-发丝细边微光阴影与边框防臃肿体系] > **技术领域与英文指代**:`Borders, Hairlines & Shadows` #### 1.4.1 边框粗细系统、发丝细边与微光阴影阶梯 [#141-边框粗细系统发丝细边与微光阴影阶梯] 在很多仿 Claude 的产品中,“视觉廉价感”几乎 100% 来自**边框过粗过硬**与**阴影单层死黑**。Claude 桌面端对此构建了极端精密的物理光学规则: #### 1. 边框大小阶梯与视网膜高分屏发丝细边规范 (Border Width & Retina Hairline) [#1-边框大小阶梯与视网膜高分屏发丝细边规范-border-width--retina-hairline] 在视网膜高分屏(MacBook Retina `@2x/@3x`)上,标准的 `1px` 边框在物理像素上实际占据了 2 到 3 个物理发光点,视觉感受极其厚重笨拙。Claude 借助媒体查询与内阴影轮廓技术实现了真正的动态发丝细边: | 边框级别 | 规格定义 | 对应工程 Token / 实现 | 核心承载组件与场景 | | :--- | :--- | :--- | :--- | | **0.5px 发丝细边 (Hairline)** | `@media (resolution >= 2x) { 0.5px }` | `--cds-ring-hairline` / `box-shadow: 0 0 0 0.5px var(--cds-border)` | 表格行间分割线、未激活分段 Tab 缝隙、次级辅助标签微标、极细胶囊底衬 | | **1.0px 基础结构边框** | 标准 `1px` (10% Alpha) | `--cds-border: var(--cds-alpha-2);` (`hsla(0, 0%, 8%, 0.1)`) | 卡片面板主体、输入框常态外轮廓、顶栏底部分割线、浮动弹窗基础边界 | | **1.5px 激活指示边框** | `1.5px` (Accent Ring) | `box-shadow: inset 0 0 0 1.5px currentColor;` | 分段滑动胶囊激活项边缘、当前选中状态指示器、表单单选/复选被选中轮廓 | | **2.0px 焦点与吸附高亮** | `2.0px` (Focus Ring & Glow) | `--cds-shadow-drop-ring: inset 0 0 0 2px var(--cds-clay);` | 文件拖拽悬停至输入框吸附光晕、键盘 Tab 导航可访问性聚焦高亮圈 | ```css /* 提取自 c6a992d55-C0zTICcS.css 发丝细边与透明度层级 */ :root { --cds-alpha-0: hsla(0, 0%, 8%, 0); --cds-alpha-1: hsla(0, 0%, 8%, 0.05); /* 幽灵按钮悬浮、骨架屏、禁用态 */ --cds-alpha-2: hsla(0, 0%, 8%, 0.10); /* 标准边框 (--cds-border)、次级填充 */ --cds-alpha-3: hsla(0, 0%, 8%, 0.20); /* 强对比边框 (--cds-border-strong)、控件悬浮 */ --cds-alpha-4: hsla(0, 0%, 8%, 0.35); /* 重分割线 */ --cds-border: var(--cds-alpha-2); --cds-border-strong: var(--cds-alpha-3); --cds-ring-hairline: 1px; } /* 视网膜高分屏发丝细边微调 */ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx), (resolution >= 2x) { :root { --cds-ring-hairline: 0.5px; } } @media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 3dppx), (resolution >= 3x) { :root { --cds-ring-hairline: calc(1px / 3); } } ``` > [!TIP] > **为什么 Claude 极少使用 CSS `border: 1px solid ...`?** > 因为传统 CSS `border` 会计入元素的盒模型排版尺寸,在动态切换激活/未激活状态时易引发微观的“1px 尺寸抖动与重排”。Claude 大量采用 `box-shadow: inset 0 0 0 1px ...` 或 `box-shadow: 0 0 0 1px ...` 代替边框,完全脱离盒模型排版计算,实现 0 抖动的顺滑物理过渡。 --- #### 2. 生产级四层环境光扩散阴影阶梯 (4-Tier Ambient & Elevation Shadow System) [#2-生产级四层环境光扩散阴影阶梯-4-tier-ambient--elevation-shadow-system] Claude 彻底摒弃单一维度的模糊阴影,全量采用**【近距微遮蔽 (Ambient Occlusion)】+【远距深层漫反射 (Elevation Diffusion)】**双层复合公式: | 阴影层级 (Token) | 浅色模式投影参数 (Light) | 深色模式投影参数 (Dark) | 核心承载业务场景 | | :--- | :--- | :--- | :--- | | **`--cds-shadow-sm`** | `0 1px 2px 0 rgba(0,0,0,0.05), 0 2px 8px 0 rgba(0,0,0,0.08)` | `0 1px 2px 0 rgba(0,0,0,0.40), 0 2px 8px 0 rgba(0,0,0,0.40)` | 卡片面板底衬、附件卡片基础立体感,防止纯扁平生硬 | | **`--cds-shadow-md`** | `0 2px 4px 0 rgba(0,0,0,0.05), 0 6px 16px 0 rgba(0,0,0,0.08)` | `0 2px 4px 0 rgba(0,0,0,0.40), 0 6px 16px 0 rgba(0,0,0,0.40)` | 卡片 Hover 悬浮抬升态、模型选择下拉菜单、折叠面板展开 | | **`--cds-shadow-lg`** | `0 4px 8px 0 rgba(0,0,0,0.06), 0 12px 28px -2px rgba(0,0,0,0.08)` | `0 4px 8px 0 rgba(0,0,0,0.50), 0 16px 36px -2px rgba(0,0,0,0.40)` | 全局模态确认弹窗 (Modal Dialog)、全屏工件预览抽屉 | | **`--cds-shadow-popover`** | `inset 0 0 0 0px transparent, 0 0 0 1px var(--cds-border), 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.08)` | **`inset 0 0 0 1px rgba(255,255,255,0.10)`**`, 0 0 0 0px transparent, 0 8px 28px rgba(0,0,0,0.65), 0 2px 8px rgba(0,0,0,0.45)` | 右键上下文菜单、快捷指令气泡、富文本操作条 | | **`--cds-panel-shadow`** | `0 0 0 1px var(--cds-border), var(--cds-shadow-sm)` | `0 0 0 1px var(--cds-border), var(--cds-shadow-sm)` | 标准独立面板外壳(边框与微阴影一体化绑定) | #### 3. 双环浮动气泡架构(Dual-Ring Architecture)的光学奥秘 [#3-双环浮动气泡架构dual-ring-architecture的光学奥秘] 请格外注意 `--cds-shadow-popover` 在浅色与深色模式下的质感差异: * **浅色模式**:外环为 `0 0 0 1px var(--cds-border)`,提供一层细致的外边缘包围线,结合向下落差 8px 的柔和漫反射。 * **深色模式(倒角高光逆转!)**:外轮廓变为 `0px`(消除黑底上突兀的白框),同时在内侧增加 `inset 0 0 0 1px rgba(255, 255, 255, 0.10)`!这一行如同真实物理世界中**边缘倒角捕捉到顶光所产生的一道微弱反光**,既凸显了浮层的立体轮廓,又完全没有多余的边框感! --- #### 4. 聊天输入框双环投影公式(Composer Dual-Ring Shadow) [#4-聊天输入框双环投影公式composer-dual-ring-shadow] 输入框是 Claude 最具标志性的界面灵魂: ```css /* 常态(Resting 未聚焦) */ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.035), inset 0 0 0 1px var(--cds-border); /* 鼠标悬停态(Hover) */ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), inset 0 0 0 1px var(--cds-border-strong); /* 聚焦态(Focus-Within) */ box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), inset 0 0 0 1px var(--cds-border-strong), 0 0 0 1px var(--cds-border-strong); ``` #### 5. 全局交互焦点环(Triple-Layer Focus Ring) [#5-全局交互焦点环triple-layer-focus-ring] 当用户通过键盘或点击激活交互控件时,Claude 绝不使用操作系统刺眼的默认蓝色外框,而是渲染专有的三层陶土高亮环: ```css --cds-focus-shadow: inset 0 0 0 1px var(--cds-surface-1), /* 第一层:1px 隔离垫片,隔开控件与光晕 */ 0 0 0 1.5px var(--cds-clay), /* 第二层:1.5px 陶土品牌色主聚焦环 */ 0 0 6px 1px rgba(217, 119, 87, 0.25); /* 第三层:柔和外扩的陶土环境漫射光晕 */ ``` --- #### 6. 全交互 Hover 态与微反馈物理规范 (Interactive Hover & Micro-Feedback) [#6-全交互-hover-态与微反馈物理规范-interactive-hover--micro-feedback] Claude 的交互反馈极度顺滑克制,遵循“有感知但不喧宾夺主”的微动效原则: 1. **幽灵按钮悬浮与按压(Ghost Button Feedback)**: * **常态**:背景完全透明,文字为次级弱灰 (`var(--cds-text-secondary)`)。 * **悬浮态 (Hover)**:背景在 **150ms 贝塞尔曲线** (`cubic-bezier(0.16, 1, 0.3, 1)`) 内渐变至 5% 灰度底衬 (`var(--cds-fill-ghost-hover)`),文字点亮为 Primary 主色。 * **按压态 (Active Press)**:触发 `scale(0.98)` 轻量回弹压感,底衬加深至 10% 灰度 (`var(--cds-fill-ghost-selected)`)。 2. **卡片物理抬升 (Card Elevation Y-Lift)**: * **常态**:平铺于画布,呈现 `--cds-panel-shadow`。 * **悬浮态 (Hover)**:向上物理抬升 `transform: translateY(-1.5px)`,同时阴影平滑过渡至 `--cds-panel-shadow-hover`,边框变深至 `--cds-border-strong`。 * **离开态**:顺滑落回原始位置,无硬弹跳。 3. **浮动菜单行高亮 (Dropdown Row Highlight)**: * 鼠标滑过菜单项时,背景瞬间点亮为带有 `4px` 圆角(`var(--radius-sm)`)的轻量高亮胶囊,行内图标与快捷键同步点亮。 4. **拖拽吸附光晕 (Drag & Drop Target Glow)**: * 拖拽文件接近输入框时,输入框内侧触发 `inset 0 0 24px -2px rgba(217, 119, 87, 0.20)` 陶土呼吸辉光,并伴随 `inset 0 0 0 2px var(--cds-clay)` 吸附圈。 --- #### 1.4.2 边界哲学与边框防臃肿体系 (Borders vs. Borderless Architecture) [#142-边界哲学与边框防臃肿体系-borders-vs-borderless-architecture] 在现代 Web 前端与大模型 UI 生成中,**“套娃边框(Russian-Doll Borders)”是导致界面臃肿、沉重、业余的最普遍元凶**。很多模型在生成前端界面时,机械地将产品需求中的“视觉分组”直接等价为 CSS `border border-neutral-200`,造成卡片嵌套卡片、消息套线框、工具栏套线框、输入框内部的每一个按钮再套一层线框,视线被无数条灰色线条切割得支离破碎。 Claude Desktop 之所以呈现出极具高级感、通透呼吸感的杂志排版质感,核心在于一套严密的**边界极简与表面微对比架构**: #### 1. 核心黄金准则:单闭合边框原则 (The 1-Border Rule) [#1-核心黄金准则单闭合边框原则-the-1-border-rule] * **视线深度控制**:在从屏幕主画布向内穿透的任何一条视线路径上,**至多只能穿过 1 层闭合的矩形边框**。 * **容器内自动降级协议**:一旦外层容器已经是一个带边框的物理实体(如 Chat Composer、Modal 弹窗、Code Block 代码块),其内部包含的所有子控件(按钮、输入区、标签、工具条)**严禁再次使用闭合边框**: * **Secondary 按钮**:严禁写成 `border border-neutral-300`,必须使用基于 Surface-2 的柔和填充(`bg-neutral-100 hover:bg-neutral-200/80 dark:bg-neutral-800 border-0`)。 * **工具栏按钮与内联操作**:必须降级为 `Ghost` 变体(常态完全透明 `bg-transparent border-0`,悬停时仅展现微弱背景 `hover:bg-neutral-100/70`)。 * **内部输入框**:Composer 内部的文字输入域完全去除原生边框与高亮环(`border-0 outline-none ring-0 bg-transparent`)。 #### 2. 组件边界授权决策树 (The Boundary Decision Matrix) [#2-组件边界授权决策树-the-boundary-decision-matrix] | 边界类型 | 授权准则 | 典型生产组件 | CSS 实现规范 | | :--- | :--- | :--- | :--- | | **🚫 坚决无边框 (Strictly Borderless)** | 依靠留白、文字层级或纯背景色聚合,杜绝描边线条阻隔阅读流动 | • **AI 助手回复正文**
• **用户消息气泡 (`#f0f4f8`)**
• 容器内的所有次级操作按钮
• 侧边栏/导航条目
• 消息底部 Reaction 反馈条
• 思考链展开文本 | `border-0`
`bg-transparent` 或 `bg-[#f0f4f8] rounded-[18px]` | | **📦 必须具备闭合外框 (Mandatory Closed Border)** | 自成一体、具备独立交互物理沙盒、实体化对象或跨越 Z 轴的浮层 | • **常驻聊天输入框 (Composer)**
• **语法高亮代码块 (Code Sandbox)**
• **独立文件附件卡片 (`.cds-attachment`)**
• **Artifact 独立产物卡片**
• **模态弹窗对话框 (`Dialog`)**
• 右键上下文菜单 (`ContextMenu`) | `border border-neutral-200/90 dark:border-neutral-800`
结合弥散双层投影 | | **➖ 单向细线替代原则 (Hairline Divider)** | 容器内部结构划分,严禁使用闭合方框套娃,严格采用 1px 单向细线 | • 代码块顶部语言栏与代码区中缝 (`border-b`)
• 下拉菜单与上下文菜单的功能组隔离 (`border-t`)
• 桌面端左右分栏中缝 (`border-r`)
• Composer 输入区与底部工具栏中缝 (`border-t`) | `border-b border-neutral-200/60`
或 `border-t border-neutral-100` | | **🌓 深色模式物理倒角 (Dark Mode 0.5px Chamfer)** | 深色背景下 1px solid 白色会产生刺眼的荧光感,改用内嵌阴影模拟工业硬件高光倒角 | • 所有深色模式卡片、代码块与浮层外边缘 | `box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);`
或 `color-mix(in srgb, var(--cds-border) 30%, transparent)` | #### 3. 常见“套娃边框”重构对比范例 [#3-常见套娃边框重构对比范例] ##### 反模式(AI 模型常见臃肿生成): [#反模式ai-模型常见臃肿生成] ```html

回复文本

``` ##### 正模式(Claude 生产级标准): [#正模式claude-生产级标准] ```html

回复文本

#### 4. 滚动驱动渐隐遮罩系统 (Scroll-Driven 28px Fade System) 在会话流与代码块滚动时,传统前端常常简单覆盖一个纯透明度渐变层,导致文字在顶底硬生生被“切断”。REA v6.5.0 在生产包中提取到了 Claude 的**滚动时间轴驱动遮罩(Scroll-Driven Fade)**完整规范: * **核心物理宽度**:`--cds-scroll-fade-size: 28px;`(严格定义为 28px,非近似的 24px 或 32px)。 * **四阶非线性相对色彩羽化(4-Stop Relative Color Fade)**: 遮罩并非纯色,而是使用现代 CSS `color-mix()` 与 `rgb(from ...)` 动态提取当前背景色进行 4 档非线性递减: ```css /* 提取自 c6a992d55-sXiDGMFQ.css 真实生产定义 */ --cds-scroll-fade-mask: linear-gradient( to bottom, var(--cds-scroll-fade-strip-color, var(--cds-surface-1)) 0%, rgb(from var(--cds-scroll-fade-strip-color, var(--cds-surface-1)) r g b / .85) 13%, rgb(from var(--cds-scroll-fade-strip-color, var(--cds-surface-1)) r g b / .50) 40%, rgb(from var(--cds-scroll-fade-strip-color, var(--cds-surface-1)) r g b / .15) 70%, transparent 100% ); ``` 配合原生滚动时间轴(`scroll-timeline`),当列表触顶时遮罩自动归零(`0px`),滚离顶部时自适应渐开至 `28px`,完全由 GPU Compositor 驱动,零主线程开销。 --- ### 1.5 字体排版与图标对齐系统约束 [#15-字体排版与图标对齐系统约束] > **技术领域与英文指代**:`Typography, Alignment & Icons` Claude 桌面端对于字重、排版折叠以及矢量图标的对齐有着近乎偏执的微观调校,涵盖六大核心工程约束: #### 1. 真实字体栈与可变字体轴配置 (Font Stacks & Variable Axes) [#1-真实字体栈与可变字体轴配置-font-stacks--variable-axes] 依据 REA v6.5.0 对 `c6a992d55-sXiDGMFQ.css` 的分析提取,Claude 具备完备的 CJK 与多语言回退保护链: * **CJK 专用无衬线回退链 (`--font-cjk-sans-fallback`)**: ```css --font-cjk-sans-sc: "PingFang SC"; --font-cjk-sans-tc: "PingFang TC"; --font-cjk-sans-jp: "Hiragino Sans"; --font-cjk-sans-kr: "Apple SD Gothic Neo"; --font-cjk-sans-fallback: var(--font-cjk-sans-sc), var(--font-cjk-sans-tc), var(--font-cjk-sans-jp), var(--font-cjk-sans-kr); ``` * **主无衬线字体栈 (`--font-anthropic-sans`)**: ```css --font-sans-fallbacks: system-ui, "Segoe UI", Roboto, Helvetica, Arial, var(--font-cjk-sans-fallback), sans-serif; --font-anthropic-sans: "anthropic-sans", var(--font-sans-fallbacks); ``` * **问候语与正文衬线栈 (`--font-anthropic-serif`)**: ```css --font-anthropic-serif: "anthropic-serif", ui-serif, Georgia, "Times New Roman", var(--font-cjk-sans-fallback), serif; ``` * **等宽代码字体栈 (`--font-anthropic-mono`)**: ```css --font-anthropic-mono: "anthropic-mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace; ``` * **可变字体光学尺寸 (opsz) 与微标字重 (wght)**: ```css --font-opsz-axis-title: "opsz" 28,; --font-opsz-axis-heading: "opsz" 20,; --font-opsz-axis-display: "opsz" 48,; --cds-badge-x-wght: 577.8; /* 徽章亚像素光学字重 */ ``` #### 2. 全量 7-Tier 字号阶梯系统与行高规范 (7-Tier Font Size & Leading Scale) [#2-全量-7-tier-字号阶梯系统与行高规范-7-tier-font-size--leading-scale] Claude 桌面端构建了一套专为高密度信息架构设计的 7 阶排版标尺系统,并通过桌面端光学缩放因子 `--cds-rem-scale: calc(16 / 17)`(≈ 0.941176)将 Web 默认 17px 基准平滑缩放至原生视网膜屏的 16px 精确渲染。 | 阶梯等级 (Token) | CSS 表达式 (Rem Scale) | 换算像素 (Desktop) | 行高 (Leading) | 行高比率 | 核心承载内容场景 | | :--- | :--- | :--- | :--- | :--- | :--- | | **`caption`** | `calc(0.6875rem * var(--cds-rem-scale))` | **10.35px (约 11px)** | `1rem` (16px) | 1.55 | 快捷键徽标 (`Kbd`)、消息时间戳、模型版本号、Token 消耗统计 | | **`footnote`** | `calc(0.75rem * var(--cds-rem-scale))` | **11.29px (约 12px)** | `calc(0.9375rem * scale)` (14.1px) | 1.25 | 附件文件体积大小、图片元数据、次级辅助说明文本、免责声明 | | **`code`** | `calc(0.75rem * var(--cds-rem-scale))` | **11.29px (约 12px)** | `1rem` (16px) | 1.42 | 代码块语法高亮文本、行内代码、Thinking 内部思维链路日志、Diff 差异 | | **`body`** | `calc(0.8125rem * var(--cds-rem-scale))` | **12.24px (约 13px / 14px)** | `1.125rem` (18px) | 1.46 | 对话流助理回答、用户气泡正文、主输入框 (Composer) 键入文本与占位符 | | **`prose`** | `0.875rem - 1rem` (舒适阅读) | **14.0px - 16.0px** | `1.25rem - 1.5rem` (20px - 24px) | 1.43 - 1.50 | 长文 Artifacts 渲染、Markdown 深度阅读、文档预览视图 | | **`heading`** | `calc(0.875rem * var(--cds-rem-scale))` | **13.18px (约 14px / 15px)** | `calc(1.125rem * scale)` (17px) | 1.29 | 弹窗标题 (Modal Title)、卡片分块小标题、侧边栏分组标题、设置项名称 | | **`title`** | `calc(1.25rem * var(--cds-rem-scale))` | **18.82px (约 20px / 21px)** | `calc(1.5rem * scale)` (23.5px) | 1.25 | 对话顶栏标题、Project 项目主标题、工作区主导航头部 | ```css /* 提取自 c6a992d55-C0zTICcS.css 核心排版变量 */ :root { --cds-rem-scale: calc(16 / 17); /* 桌面端光学微调系数 ≈ 0.94117647 */ --cds-font-size-caption: calc(0.6875rem * var(--cds-rem-scale, 1)); --cds-leading-caption: 1rem; --cds-font-size-footnote: calc(0.75rem * var(--cds-rem-scale, 1)); --cds-leading-footnote: calc(0.9375rem * var(--cds-rem-scale, 1)); --cds-font-size-code: calc(0.75rem * var(--cds-rem-scale, 1)); --cds-leading-code: 1rem; --cds-font-size-body: calc(0.8125rem * var(--cds-rem-scale, 1)); --cds-leading-body: 1.125rem; --cds-font-size-prose: 0.875rem; --cds-leading-prose: 1.25rem; --cds-font-size-heading: calc(0.875rem * var(--cds-rem-scale, 1)); --cds-leading-heading: calc(1.125rem * var(--cds-rem-scale, 1)); --cds-font-size-title: calc(1.25rem * var(--cds-rem-scale, 1)); --cds-leading-title: calc(1.5rem * var(--cds-rem-scale, 1)); } ``` #### 3. 暗色模式视网膜光渗字重逆补偿 (Retinal Irradiation Compensation) [#3-暗色模式视网膜光渗字重逆补偿-retinal-irradiation-compensation] 在物理光学与人眼视网膜感知中,**高对比度白字在黑底上会向外发散光晕(Irradiation Phenomenon)**,导致同等粗细的文字在深色模式下显得比浅色模式粗 10% - 15%,产生视觉膨胀与边缘模糊。 Claude 依托其专有 Variable Font 轴进行了精准的物理逆补偿:在深色模式下,主动将字重数值降低 **30 - 40 个刻度**,使文字在人眼感官中达到与浅色模式完全绝对一致的感知纤细度与锐度。 | 语义字重级别 | 浅色模式字重 (Light) | 深色模式减薄字重 (Dark) | 补偿工程机制与变化幅度 | | :--- | :--- | :--- | :--- | | **Regular (正文常规)** | `font-weight: 400` / `"wght" 400` | `--cds-font-axis-wght: "wght" 360` | **主动减薄 40 刻度**,消除纯白正文字体发散 | | **Medium (操作/强调)** | `font-weight: 500` / `"wght" 500` | `--cds-font-axis-wght: "wght" 460` | **主动减薄 40 刻度**,保持中等强度的利落感 | | **Semibold (标题/身份)**| `font-weight: 580` / `"wght" 580` | `--cds-font-axis-wght: "wght" 550` | **主动减薄 30 刻度**,避免粗体在深色背景下糊成一团 | | **Bold (强警示/重强调)** | `font-weight: 600` / `"wght" 660` | `--cds-font-axis-wght: "wght" 660` | 保持稳固的醒目重音边界 | ```css /* 分析源码提取自 c6a992d55-C0zTICcS.css */ /* 浅色模式基准 */ .font-normal { --cds-font-axis-wght: "wght" 400; font-variation-settings: var(--font-opsz-axis,) var(--cds-font-axis-wght,) "GRAD" var(--cds-font-grad, 0); } .font-medium { --cds-font-axis-wght: "wght" 500; font-variation-settings: var(--font-opsz-axis,) var(--cds-font-axis-wght,) "GRAD" var(--cds-font-grad, 0); } .font-semibold { --cds-font-axis-wght: "wght" 580; font-variation-settings: var(--font-opsz-axis,) var(--cds-font-axis-wght,) "GRAD" var(--cds-font-grad, 0); } /* 深色模式光学逆补偿 */ [data-theme=claude][data-mode=dark] .font-normal { --cds-font-axis-wght: "wght" 360; } [data-theme=claude][data-mode=dark] .font-medium { --cds-font-axis-wght: "wght" 460; } [data-theme=claude][data-mode=dark] .font-semibold { --cds-font-axis-wght: "wght" 550; } [data-theme=claude][data-mode=dark] .font-bold { --cds-font-axis-wght: "wght" 660; } ``` #### 4. 核心业务内容场景排版全景速查矩阵 (Content-to-Typography Matrix) [#4-核心业务内容场景排版全景速查矩阵-content-to-typography-matrix] 为了在工程实现中彻底杜绝字号、字重的“随意臆造与层层嵌套”,下表严格归纳了 Claude 桌面端所有核心业务模块的标准字体参数: | 模块区域 (Module) | 界面具体内容元素 (Content Element) | 字体族 (Font Family) | 阶梯/大小 (Size) | 行高 (Leading) | 字重 (Light / Dark) | 特殊排版属性 / 说明 | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | **对话流 (Chat)** | 助理身份名称 ("Claude") | Sans | `12px` | 16px | `580` / `550` (Semibold) | 稳固的首部身份标识 | | | 模型版本微标 ("3.7 Sonnet") | Mono | `10.5px` (Caption) | 14px | `500` / `460` (Medium) | 药丸微标,等宽字母 | | | 消息时间戳 ("09:42") | Mono | `11px` (Footnote) | 14px | `400` / `360` (Regular) | `tabular-nums`,弱对比度文本 | | | 助理正文回答 (Paragraph) | Sans | `14px` (Body) | 20px (1.428) | `400` / `360` (Regular) | `text-wrap: pretty;` 消除孤行单字 | | | 用户发送气泡内文本 | Sans | `14px` (Body) | 20px (1.428) | `400` / `360` (Regular) | 紧凑包裹,自然折行 | | | 消息底部操作栏 (复制/重新生成按钮) | Sans | `12px` | 16px | `500` / `460` (Medium) | 鼠标悬浮才显示的二级淡出按钮 | | **思考链路 (Thinking)** | 思考折叠触发器 ("Thought for 5.2s") | Sans | `12px` | 16px | `500` / `460` (Medium) | 包含行内旋转箭头与动态计时器 | | | 内部思维推理日志 (Raw Thought) | Mono | `11.5px` (Code) | 16px (1.39) | `400` / `360` (Regular) | 极细等宽流,无背景包裹,弱灰文本 | | **输入区 (Composer)** | 多行文本输入区 (Textarea) | Sans | `14px` (Body) | 20px (1.428) | `400` / `360` (Regular) | 移动端保底 `max(16px, 14px)` | | | 占位符文本 (Placeholder) | Sans | `14px` (Body) | 20px (1.428) | `400` / `360` (Regular) | 45% 透明度底衬颜色 | | | 底部辅助操作 ("+ Add content") | Sans | `12px` | 16px | `500` / `460` (Medium) | 紧凑工具栏按钮 | | | 模型选择器下拉 ("Claude 3.7 Sonnet") | Sans | `12px` | 16px | `500` / `460` (Medium) | 药丸胶囊交互控件 | | | 发送按钮 ("Send" / 图标) | Sans | `12px` | 16px | `580` / `550` (Semibold) | 视觉焦点权重 | | **代码与工件 (Artifacts)** | 代码块语法高亮代码 (Code block) | Mono | `12px` (Code) | 17.5px (1.46) | `400` / `360` (Regular) | `tabular-nums;` 横向平滑滚动 | | | 行内代码微标 (`inline code`) | Mono | `12px` (Code) | 14px | `500` / `460` (Medium) | 1px 细边框,3px 圆角,内边距 1px 4px | | | 工件卡片标题 (Artifact Title) | Sans | `13px` (Heading) | 18px | `580` / `550` (Semibold) | 点击展开全屏工件抽屉 | | | 工件语言标签 ("REACT", "HTML") | Mono | `10.5px` (Caption) | 12px | `500` / `460` (Medium) | 大写等宽无衬线,字距 `letter-spacing: 0.05em` | | | 附件卡片主文件名 | Sans | `12px` | 16px | `500` / `460` (Medium) | 文本截断 `text-overflow: ellipsis;` | | | 附件卡片文件大小 ("24.8 KB") | Mono | `10.5px` (Caption) | 14px | `400` / `360` (Regular) | `tabular-nums`,辅助弱灰 | | **控制与弹窗 (Controls)** | 模态弹窗主标题 (Modal Dialog) | Sans | `15px - 16px` | 20px (1.25) | `580` / `550` (Semibold) | `text-wrap: balance;` 居中或左对齐 | | | 分段选择器标签 (Segmented Tab) | Sans | `12px` | 16px | 常规 `400` / 激活 `500` | 胶囊滑块平移背景 | | | 按钮 (Button SM / 32px) | Sans | `12.5px` | 16px | `500` / `460` (Medium) | 紧凑控制动作 | | | 按钮 (Button MD / 38px) | Sans | `13.5px` | 18px | `500` / `460` (Medium) | 标准页面主次操作按钮 | | | 快捷键键帽 (`Kbd`) | Mono | `10px - 11px` | 12px | `580` / `550` (Semibold) | 阴影衬底,紧凑字形 | --- #### 5. 行内图标光学基线校准 (.align-[-0.125em]) [#5-行内图标光学基线校准-align--0125em] 在 Web 排版中,默认行内 SVG 或图标会坐落于 `vertical-align: baseline`,导致图标的视觉几何重心明显高于小写字母的 x-Height 与大写字母的 Cap-Height,产生“图标浮在上空”的脱节感。 Claude 体系强制采用专门提取的负偏置实用类: * **`.align-[-0.125em]` (`vertical-align: -0.125em;`)**:用于 14px - 16px 标准 Body 与 Heading 文本。将图标恰好下沉 1/8em(约 1.75px - 2px),使图标的上下对称中心与字母几何重心 100% 严丝合缝重合! * **`.align-[-0.075em]` (`vertical-align: -0.075em;`)**:用于 11px - 12px Caption 与说明性小字。 * **`.align-[-1px]` / `.align-[-2px]`**:用于固定高度(32px/46px)工具栏与标题栏的行内徽章。 ```css /* 提取自 c6a992d55-C0zTICcS.css */ .align-\[-0\.125em\] { vertical-align: -.125em; } .align-\[-0\.075em\] { vertical-align: -.075em; } .align-\[-1px\] { vertical-align: -1px; } ``` #### 4. 文本换行与防折断约束 (Text-Wrap & Word-Break Constraints) [#4-文本换行与防折断约束-text-wrap--word-break-constraints] * **标题行长均衡 (`text-wrap: balance`)**: 针对所有 `:is(h1, h2, h3, h4)` 和卡片主标题应用 `text-wrap: balance;`,算法自动在多行之间分配字数,避免末行出现孤零零的单个词汇。 * **正文孤字消除 (`text-wrap: pretty`)**: 针对正文段落 `:is(p, li, dd, blockquote)` 应用 `text-wrap: pretty;`,防止段落最后一行遗留单字(Typographic Runts)。 * **超长字符串与 Token 安全换行 (`overflow-wrap: anywhere`)**: 针对包含超长模型 ID(如 `claude-3-7-sonnet-20250219-thinking-exp`)、Git commit hash、代码变量名的提示框,严格采用: ```css overflow-wrap: anywhere; word-break: normal; ``` 在保护常规英文与中文单词连贯性(不强制无理打断正常词)的同时,确保遇到超界长串时能安全折行,绝不撑破容器。 * **移动端输入防缩放底线**: ```css input, textarea, select { font-size: max(16px, var(--cds-font-size-body)); } ``` 在 iOS WebKit 下,任何 `font-size < 16px` 的输入框获得焦点时都会触发页面强制缩放。Claude 设置 16px 下限地板彻底规避此问题。 #### 5. 等宽数字绝对锁定 (Tabular Numerics) [#5-等宽数字绝对锁定-tabular-numerics] 所有涉及动态计数的区域(Thinking 思考耗时 `00:03.2`、Token 消耗 `1,284 tokens`、日期与表格)强制配置: ```css font-variant-numeric: tabular-nums; /* 或 */ font-feature-settings: "tnum" 1; ``` 使数字 `0` 到 `9` 占用完全相同的字形宽度,消除数字递增时引发的整行动量抖动。 #### 6. 矢量图标架构与双层色协议 (Phosphor & Duotone Layering) [#6-矢量图标架构与双层色协议-phosphor--duotone-layering] * **原生坐标系**:`viewBox="0 0 256 256"`(Phosphor Icons 架构)。 * **标准字重与代码字重**: * 常规状态:Stroke 16px(对应字重 533.3,常规粗细)。 * 激活/代码状态:Stroke 24px(对应字重 700,`--df-app-switch-code-weight: 700`)。 * **双层色(Duotone)协议**: ```html ``` * **尺寸阶梯**: * **XS (12px)**:徽章、关闭小图标 * **SM (14px)**:密集操作栏按钮 * **MD (16px)**:标准交互件,应用公式 `calc(1rem * var(--cds-rem-scale, 1))` ≈ `15.06px - 16px` * **LG (20px)**:卡片主操作按钮 * **XL (24px)**:模态窗与空状态主图 #### 7. 完整字阶角色梯级全量映射 (Typography Role Scale Hierarchy) [#7-完整字阶角色梯级全量映射-typography-role-scale-hierarchy] Claude 针对各 UI 语义角色定义了严格绑定的原子类,内置了基准字号、等比行高与可变字体光学校准: | 语义原子类名 | 字号 (`font-size`) | 行高 (`line-height`) | 默认字重 (`font-weight`) | 光学校准 (`font-variation-settings`) | 适用场景 | | :--- | :--- | :--- | :--- | :--- | :--- | | `.text-caption-regular` | `calc(0.6875rem * scale)` (约 11px) | `calc(1.0625rem * scale)` (约 17px) | Regular (400) | `"GRAD" 0` | 时间戳、底部小字说明、微徽章 | | `.text-caption-medium` | `calc(0.6875rem * scale)` (约 11px) | `calc(1.0625rem * scale)` (约 17px) | Medium (470 / 460) | `"wght" 460` (Dark) | 紧凑状态标签、计数微标 | | `.text-caption-bold` | `calc(0.6875rem * scale)` (约 11px) | `calc(1.0625rem * scale)` (约 17px) | Bold (700 / 660) | `"wght" 660` (Dark) | 强调小标签、快捷键提示 | | `.text-footnote-medium` | `calc(0.8125rem * scale)` (约 13px) | `calc(1.0625rem * scale)` (约 17px) | Medium (470 / 460) | `"wght" 460` (Dark) | 列表项副标题、侧边栏次级文本 | | `.text-footnote-semibold` | `calc(0.8125rem * scale)` (约 13px) | `calc(1.0625rem * scale)` (约 17px) | Semibold (600 / 560)| `"wght" 560` (Dark) | 侧边栏活动会话分组头 | | `.text-body-regular` | `calc(0.875rem * scale)` (约 14px) | `calc(1.25rem * scale)` (约 20px) | Regular (400) | `"GRAD" 0` | **标准聊天对话正文、设置表单文字** | | `.text-body-medium` | `calc(0.875rem * scale)` (约 14px) | `calc(1.25rem * scale)` (约 20px) | Medium (470 / 460) | `"wght" 460` (Dark) | 按钮文本、常规交互链接 | | `.text-body-bold` | `calc(0.875rem * scale)` (约 14px) | `calc(1.25rem * scale)` (约 20px) | Bold (700 / 660) | `"wght" 660` (Dark) | 正文强调文本(``, ``) | | `.text-heading-regular` | `calc(0.9375rem * scale)` (约 15px) | `calc(1.25rem * scale)` (约 20px) | Regular (400) | `"opsz" 20` | 对话轮次提示头、卡片小标题 | | `.text-heading-semibold`| `calc(0.9375rem * scale)` (约 15px) | `calc(1.25rem * scale)` (约 20px) | Semibold (600 / 560)| `"opsz" 20, "wght" 560` | 卡片主标题、弹窗面板分组名 | | `.text-title-medium` | `calc(1.25rem * scale)` (约 20px) | `calc(1.75rem * scale)` (约 28px) | Medium (500 / 460) | `"opsz" 28, "wght" 460` | 页面级主标题、设置大栏目 | | `.text-title-bold` | `calc(1.25rem * scale)` (约 20px) | `calc(1.75rem * scale)` (约 28px) | Bold (700 / 660) | `"opsz" 28, "wght" 660` | 模态框首要标题 | | `.font-display` | `2.375rem` (38px) | `1.2 (45.6px)` | Light (`wght: 330`) | `"opsz" 48` (Serif 轴) | **问候语首屏大字标(Serif Greeting)** | #### 8. 多行文本截断阶梯 (Multi-line Truncation & Clamp Scale) [#8-多行文本截断阶梯-multi-line-truncation--clamp-scale] Claude 针对各种卡片和气泡采用特定的 `-webkit-line-clamp` 阶梯,配合 `overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical;`: ```css /* 1. 侧边栏历史会话标题(单行防撑爆) */ .line-clamp-1 { -webkit-line-clamp: 1; -webkit-box-orient: vertical; display: -webkit-box; overflow: hidden; } /* 2. 思考折叠卡片摘要(双行预览) */ .line-clamp-2 { -webkit-line-clamp: 2; -webkit-box-orient: vertical; display: -webkit-box; overflow: hidden; } /* 3. 系统提示词卡片与模型描述(三行预览) */ .line-clamp-3 { -webkit-line-clamp: 3; -webkit-box-orient: vertical; display: -webkit-box; overflow: hidden; overflow-wrap: anywhere; } ``` --- ### 1.6 基础动效令牌体系与物理贝塞尔曲线全集 [#16-基础动效令牌体系与物理贝塞尔曲线全集] > **技术领域与英文指代**:`Motion Tokens & Physical Curves` ```mermaid graph LR T1["60ms: Micro"] --> T2["120ms: Snap"] --> T3["200ms: Base"] --> T4["300ms: Sheet"] --> T5["450ms: Slow"] ``` #### 1. 响应时序阶梯 (Duration Tokens) [#1-响应时序阶梯-duration-tokens] * `--cds-dur-fast: 60ms`(微交互、聚焦环显隐) * `--cds-dur-snap: 120ms`(磁吸切换、微标激活) * `--cds-dur-base: 200ms`(标准控件悬停与背景平滑过渡) * `--cds-dur-sheet: 300ms`(抽屉滑入、对话视口图钉追踪) * `--cds-dur-slow: 450ms`(环境转场、模态框升降) #### 2. REA v6.5.0 真实物理贝塞尔缓动曲线全集 (The 7 Core Physical Curves) [#2-rea-v650-真实物理贝塞尔缓动曲线全集-the-7-core-physical-curves] REA 对官方生产包的 CSS 全量扫描表明,Claude 绝非仅有 3 条通用曲线,而是为不同交互场景调校了专用的物理阻尼常数: | 曲线令牌 / 表达式 | 官方承载交互组件 | 物理特征与视觉心理学作用 | | :--- | :--- | :--- | | **`--cds-ease-swift`**
`cubic-bezier(.16, 1, .3, 1)` | 幽灵按钮、卡片悬停抬升 (`Ghost/Card Hover`) | **仿 iOS 系统级灵动微交互**:150ms 迅速到位,尾段急速刹停无残影 | | **`--cds-ease-expand`**
`cubic-bezier(.19, 1, .22, 1)` | 思考链折叠抽屉 (`.timeline-expand`) | **CSS Grid 专用平滑展开**:0fr 到 1fr 展开时消除任何高度阶跃重排 | | **`--cds-ease-enter`**
`cubic-bezier(.22, 1, .36, 1)` | 消息入场消融 (`timeline-block-enter`) | 伴随 `translateY(5px) scale(0.9) blur(4px)` 到完整清晰展平 | | **`--cds-ease-overshoot`**
`cubic-bezier(.34, 1.3, .64, 1)` | 胶囊滑块、小药丸形变 (`Pill/Slider`) | **经典果冻机械回弹**:前 100ms 冲出 +30% 超调量,后 140ms 柔和收敛 | | **`--cds-ease-pop`**
`cubic-bezier(.34, 1.56, .64, 1)` | 弹窗弹出、操作重强调 (`Dialog Pop`) | **强刚度弹簧物理反馈**:+56% 超调猛烈冲出,提供极其坚实的撞击质感 | | **`--cds-ease-pulse`**
`cubic-bezier(.4, 0, .2, 1)` | 思考状态静默三点跳动 (`timeline-quiet-dot`) | 1.9s 循环,`translateY(-2.5px)` 轻盈律动,显著缓解心理等待焦虑 | | **`--cds-ease-rise`**
`cubic-bezier(.3, .7, .4, 1)` | 状态行抬升入场 (`timeline-status-rise`) | `translateY(6px) -> 0` 平稳升起,避免抢夺正文视觉焦点 | | **`--cds-ease-fall`**
`cubic-bezier(0, 0, .2, 1)` | 状态行淡出下沉 (`timeline-status-fall`) | `translateY(-4px)` 加速滑落,利落退场 | ---

[📚 目录](Claude%20Design%20System%20(CDS).md) · [第二篇:基础原子组件与交互控件 ➡️](02-基础原子组件与交互控件.md)

# 02-基础原子组件与交互控件 (/docs/v1/02)

[⬅️ 上一篇:第一篇:设计哲学与设计令牌体系](01-设计哲学与设计令牌体系.md) · [📚 返回总目录](Claude%20Design%20System%20(CDS).md) · [下一篇:第三篇:会话核心流与指令交互引擎 ➡️](03-会话核心流与指令交互引擎.md)

--- ## 第二篇:基础原子组件与交互控件 [#第二篇基础原子组件与交互控件] > **技术领域与英文指代**:`Foundational Atoms & Controls` 依托 **REA (Reverse Engineer Anything) v6.5.0** 对官方最新版 Claude Desktop (`/Applications/Claude.app`,`@ant/desktop v2.37337.1`,ASAR 证据 `ev_e0bd89cee50a5b7d0dbf9e75cef5dfbca2bcb1699df4d4371449dd08452a8358`) 的分析取证,本篇系统性拆解 Claude 基础交互控件的生产级 DOM 结构、CSS 实用类组合与原生物理微交互算法。 --- ### 2.1 全能按钮控件阶梯 [#21-全能按钮控件阶梯] > **技术领域与英文指代**:`Buttons & Controls - CdsButton / [data-cds="Button"]` #### 2.1.1 控件高度标尺与排版尺寸矩阵 [#211-控件高度标尺与排版尺寸矩阵] 依据 REA 对 `shared-frame-BfjMqbuN.js` 与 `c6a992d55-sXiDGMFQ.css` 的分析提取,Claude 绝非使用粗放的 4 级尺寸,而是构建了严苛的 **5 阶高度标尺**,并通过桌面端光学缩放因子 `--cds-rem-scale: calc(16 / 17)`(≈ 0.941176)进行亚像素对齐: | 尺寸代号 | CSS 表达式 (Rem Scale) | 桌面端实际像素 | 内边距 (`padding`) | 圆角 (`radius`) | 字体与排版角色 | | :--- | :--- | :--- | :--- | :--- | :--- | | **`xxs`** (`data-step="1"`) | `calc(1.25rem * scale)` | **18.82px (约 19px)** | `px-1.5 py-0` | `--radius-sm` (4px) | `11px` Caption,极紧凑行内重试、次级小动作 | | **`xs`** | `calc(1.5rem * scale)` | **22.59px (约 23px / 24px)**| `px-2 py-0.5` | `--radius-md` (6px) | `11.5px` Footnote,标签删除、代码块辅助栏 | | **`sm`** | `calc(1.75rem * scale)` | **26.35px (约 26px / 28px)**| `px-2.5 py-1` | `--radius-lg` (8px) | `12.5px`,下拉菜单项、输入框内操作胶囊 | | **`md` (官方默认)** | `calc(2rem * scale)` | **30.12px (约 32px)** | `px-3.5 py-1.5` | `--radius-lg` (8px) | `13.5px` Body,**标准交互动作、表单确认** | | **`lg`** | `calc(2.5rem * scale)` | **37.65px (约 40px)** | `px-5 py-2` | `--radius-xl` (12px) | `15px` Heading,全局首要引导、登录主操作 | | **`icon`** (纯图标) | 固定正方形宽高比 | `aspect-square w-control` | `p-0` | `--radius-lg` (8px) | 工具栏独立图标操作(如关闭、复制、更多) | > [!NOTE] > **嵌套控件高度衰减公式 (`--cds-h-control-nested`)**: > 当按钮被嵌套在 Composer 或工具栏容器中时,Claude 自动切换为嵌套高度变量: > `nested-xs: calc(1.125rem * scale)` (17px) / `nested-sm: calc(1.25rem * scale)` (18.8px) / `nested-default: calc(1.375rem * scale)` (20.7px) / `nested-lg: calc(1.75rem * scale)` (26.35px)。 --- #### 2.1.2 生产级 6 大核心变体契约 (Variants Architecture) [#212-生产级-6-大核心变体契约-variants-architecture] REA 分析揭示,Claude 的按钮组件由两层结构正交构成:**外层交互重置壳** + **内层独立绘景层 (`data-cds-part="paint"`)**。这一架构彻底解耦了外轮廓焦点环、内阴影与背景渐变,杜绝了传统 CSS 按钮在 Hover/Active 时内外尺寸微抖的缺陷。 ```mermaid graph LR Outer["Button 外层容器
[data-cds='Button'] .cds-btn-squish"] --> Paint["独立绘景图层
[data-cds-part='paint'] -z-10"] Outer --> Content["内容排版层
Icon + Children + Kbd"] Outer --> Indicator["状态微标插槽
[data-cds-part='indicator'] Pulse"] ``` ```javascript /* 提取自官方生产包 shared-frame-BfjMqbuN.js 原生变体映射 */ const Il = "cds-reset group/btn relative isolate inline-flex shrink-0 items-center justify-center gap-1.5 whitespace-nowrap select-none cursor-[var(--cds-cursor-interactive)] aria-disabled:cursor-default data-[disabled]:cursor-default border-0 outline-none focus-visible:outline-hidden rounded h-control font-sans text-body transition-shadow duration-fast"; ``` | 变体代号 | 视觉语义角色 | 文字排版与前景色 | 绘景图层样式 (`data-cds-part="paint"`) | 交互状态与物理特征 | | :--- | :--- | :--- | :--- | :--- | | **`secondary`**
(**Claude 官方默认**) | 卡片内次级操作,**绝不带硬边框**,严格遵循单闭合边框原则 | `text-primary font-normal font-control aria-pressed:text-accent` | `bg-fill-secondary group-hover/btn:bg-fill-secondary-hover dark:bg-white/10 dark:hover:bg-white/15` | `shadow-field group-aria-pressed/btn:shadow-field-pressed` | | **`primary`** | 关键正向提交、发送提示词 | `text-on-primary font-medium font-control` | `bg-fill-primary group-hover/btn:bg-fill-primary-hover` (陶土实色) | `shadow-2xs active:brightness-95` | | **`ghost`** | 工具栏图标、内联微操作、次级折叠条 | `text-primary font-normal font-control aria-pressed:text-accent` | `bg-transparent group-hover/btn:bg-fill-ghost-hover` | 悬停渐入 5% 灰度,激活 `bg-fill-ghost-selected` | | **`danger`** | 模态确认删除、清空项目等毁灭性动作 | `text-on-danger font-medium font-control` | `bg-fill-danger group-hover/btn:bg-fill-danger-hover` (警示深红) | `focus-visible:shadow-focus-danger` 专用红光晕 | | **`brand`** | 桌面端官方品牌高亮操作 | `text-on-brand font-medium font-control` | `bg-fill-brand group-hover/btn:bg-fill-brand-hover` (`--brand: #c6613f`) | 官方深陶土桌面品牌色 | | **`onContent`** | 浮动于复杂代码、图片或全屏视频上方的覆层操作 | `text-primary font-medium font-control` | `bg-[var(--cds-button-on-content)] backdrop-blur-md shadow-[inset_0_0_0_1px_var(--cds-button-on-content-ring)]` | 4px 毛玻璃羽化,深色半透明抗背景干扰 | --- #### 2.1.3 按钮动态阻尼物理学与 15 阶纯 CSS 弹簧 (`.cds-btn-squish`) [#213-按钮动态阻尼物理学与-15-阶纯-css-弹簧-cds-btn-squish] REA 对 `c6a992d55-sXiDGMFQ.css` 进行分析取证时,发现了 Claude 极其惊艳的**真实物理弹簧形变系统**:它绝非传统前端写死的硬性 `scale(0.98)`,而是结合运行时按钮高度自适应计算阻尼系数,并在松开瞬间触发 **15 阶 CSS `linear()` 弹簧曲线**: ```css /* 提取自 c6a992d55-sXiDGMFQ.css 真实生产定义 */ :root { --cds-btn-spring: linear( 0, .2459, .6526, .9468, 1.0764, 1.0915, 1.0585, 1.0219, .9993, .9914, .9921, .9957, .9988, 1.0004, 1 ); } .cds-btn-squish { --cds-btn-press-sx: 0.975; --cds-btn-press-sy: 0.975; transform-origin: 50%; transition: transform var(--cds-dur-slow) var(--cds-btn-spring); } .cds-btn-squish:active, :active > .cds-btn-squish { transform: scale(var(--cds-btn-press-sx), var(--cds-btn-press-sy)); transition: transform var(--cds-dur-fast) ease-out; } ``` > [!TIP] > **弹簧数学分析 (Spring Physics Analysis)**: > 在 `--cds-btn-spring` 曲线中,按压释放瞬间先在 40% 时间点冲出至 `1.0915`(**+9.15% 物理过冲**),随后微回弹至 `0.9914`,并在 `1.0004` 处精准阻尼收敛。配合 JS 动态微调: > `Bl(h) = Math.min(1.5, Math.max(0.5, h * (1 / 32)))`,保证小按钮微缩放细腻,大按钮扎实回弹。 --- #### 2.1.4 组合按钮组协议 (Joined Buttons) [#214-组合按钮组协议-joined-buttons] 当多个按钮以组合条形态并排出现时(如分段视图切换、撤销/重做组),外层注入 `joined` 拓扑控制,自动剔除内侧圆角并消除双重中缝边框: * **首项 (`start`)**:`rounded-e-none`(右侧直角) * **中间项 (`middle`)**:`rounded-none`(两侧直角) * **末项 (`end`)**:`rounded-s-none`(左侧直角) > **生产级独立组件实现**:[`code-examples/CdsButton.tsx`](../code-examples/CdsButton.tsx)(已全量同步 5 阶尺寸、6 大变体、绘景层分离与 `.cds-btn-squish` 15 阶弹簧物理算法)。 --- ### 2.2 分段滑动选择胶囊 [#22-分段滑动选择胶囊] > **技术领域与英文指代**:`Segmented Control & Pills - .df-pills[data-segmented]` Claude 桌面端顶部导航与设置中的滑动 Tab 采用 **999px 全圆角轨道 + 纯几何等分滑块 + 双断点容器查询自适应折叠** 架构。 #### 2.2.1 轨道与滑动指示器精确几何参数 [#221-轨道与滑动指示器精确几何参数] ```css /* 提取自 shared-styles-Bl9zqrv-.css 与 frame-window-BEI3vR8Q.css */ .df-pills[data-segmented] { padding: 1px; /* 严格 1px 环绕间距,杜绝 2px 的笨拙感 */ container-type: inline-size; border-radius: 999px; background: var(--cds-segmented-control-track, rgba(0, 0, 0, 0.06)); } .df-pills[data-segmented] .df-pill-indicator { position: absolute; top: 1px; bottom: 1px; border-radius: calc(var(--cds-radius) - 1px); will-change: transform; transition: transform var(--cds-dur-snap) var(--cds-ease-snap), background-color var(--df-dur-slow) var(--df-ease-out); } ``` * **纯几何等分比例公式 (Pure Geometric Allocation)**: 滑块水平位置与宽度严丝合缝匹配轨道内 1px 间隙: ```css left: calc(1px + var(--active-index) * (100% - 2px) / var(--total-tabs)); width: calc((100% - 2px) / var(--total-tabs)); ``` * **光学双层弥散投影 (Dual-Layer Optical Shadow)**: - **浅色模式**: `background: var(--cds-neutral-20); box-shadow: inset 0 0 0 0.5px var(--cds-border), 0 1px 2px #0000000f, 0 2px 6px -1px #0000000d;` - **深色模式**: `background: var(--cds-segmented-control-thumb); box-shadow: inset 0 0 0 0.5px #ffffff14, 0 1px 2px #0000004d, 0 2px 6px -1px #00000040;` --- #### 2.2.2 双断点容器查询自适应折叠协议 (@container) [#222-双断点容器查询自适应折叠协议-container] 当容器宽度被窄侧边栏或窗口拉伸挤压时,Claude 绝不生硬换行,而是依托 `@container` 逐级收缩未激活项标签: ```css /* 提取自 c6a992d55-sXiDGMFQ.css 真实生产容器断点 */ /* 1. 两项分段控制器:容器宽度 <= 180px 时折叠 */ @container (width <= 180px) { .df-pills[data-segmented][data-pills="2"] .df-pill:not([data-active]) .df-pill-label { display: none; } .df-pills[data-segmented][data-pills="2"] .df-pill:not([data-active]) { padding: 0; } .df-pills[data-segmented][data-pills="2"] .df-pill[data-active] { flex: none; padding: 0 16px; } } /* 2. 三项分段控制器:容器宽度 <= 254px 时折叠 */ @container (width <= 254px) { .df-pills[data-segmented][data-pills="3"] .df-pill:not([data-active]) .df-pill-label { display: none; } .df-pills[data-segmented][data-pills="3"] .df-pill:not([data-active]) { padding: 0; } .df-pills[data-segmented][data-pills="3"] .df-pill[data-active] { flex: none; padding: 0 16px; } } ``` > **生产级独立组件实现**:[`code-examples/SegmentedControl.tsx`](../code-examples/SegmentedControl.tsx)(支持 1px 严苛轨道定位、双断点容器自适应折叠与 Framer Motion 物理弹簧双模式)。 --- ### 2.3 状态指示灯与微动效套件 [#23-状态指示灯与微动效套件] > **技术领域与英文指代**:`Status Indicators & Shimmer` 在 Claude 界面中,微型指示灯与扫光条承担着系统实时状态(运行中、思考中、空闲、就绪)的关键传达职责: #### 2.3.1 官方标准 6px 状态指示灯矩阵 (`.status-dot`) [#231-官方标准-6px-状态指示灯矩阵-status-dot] REA 分析从 `shared-styles-Bl9zqrv-.css` 中提取到的官方状态灯基准类为 `.status-dot`(**严格 6px 直径圆形**): ```css .status-dot { width: 6px; height: 6px; border-radius: 50%; display: block; position: relative; } ``` | 状态代号 | 视觉颜色 | 动画时序与关键帧 | 业务承载场景 | | :--- | :--- | :--- | :--- | | **`ready`** | `var(--cds-fill-accent)` | 静态常亮,无额外消耗 | 桌面端就绪、会话同步完成、模型待命 | | **`running`** | `var(--cds-fill-accent)` | `1.2s ease-in-out infinite dframe-dot-blink` (透明度 0.3 $\leftrightarrow$ 1.0) | 后台活动通信中、工件代码构建中 | | **`error`** | `var(--cds-fill-danger)` | 静态深红高亮 | 连接超时、MCP 工具执行失败 | | **`clay`** | `var(--cds-clay)` | **`3.0s ease-in-out infinite dframe-clay-breathe`** | Extended Thinking 深度推理与模型核心算力脉冲 | ```css /* 陶土呼吸关键帧提取自 shared-styles-Bl9zqrv-.css */ @keyframes dframe-clay-breathe { 0%, 100% { filter: brightness(0.96); transform: scale(0.86); } 50% { filter: brightness(1.06); transform: scale(1); } } ``` --- #### 2.3.2 思考波浪三点跳跃规范 (`.timeline-quiet-dots`) [#232-思考波浪三点跳跃规范-timeline-quiet-dots] 在思考链或消息输出等待态,Claude 渲染专有的 3 点波浪脉冲: * **容器几何**:`gap: 3.5px; display: inline-flex; position: relative; top: 0.26em;` * **单点几何**:`width: 3px; height: 3px; border-radius: 50%; background: var(--cds-clay, #d97757);` * **三阶延迟与运动轨迹**: - 周期:**`1.9s cubic-bezier(0.4, 0, 0.2, 1) infinite`** - 阶梯相位差:点 1 为 `0s`,点 2 为 `0.15s`,点 3 为 `0.3s` - 运动关键帧: ```css @keyframes timeline-quiet-dot { 0%, 8% { opacity: 0; transform: translateY(2px); } 22% { opacity: 1; transform: translateY(-2.5px); } 36%, 70% { opacity: 1; transform: translateY(0); } 90%, 100%{ opacity: 0; transform: translateY(0); } } ``` --- #### 2.3.3 骨架屏 105° 倾角平移扫光 (`cds-skeleton-sweep`) [#233-骨架屏-105-倾角平移扫光-cds-skeleton-sweep] 在卡片、正文骨架加载阶段,Claude 采用极具质感的非对称角度扫光: * **周期与缓动**:`animation: cds-skeleton-sweep 2s linear infinite;`(严格 2.0s 匀速,非 1.6s)。 * **光带倾角**: - LTR 模式:`linear-gradient(105deg, transparent 35%, var(--cds-skeleton-sheen) 50%, transparent 65%)` - RTL 镜像模式:`linear-gradient(255deg, transparent 35%, var(--cds-skeleton-sheen) 50%, transparent 65%)` * **关键帧**: ```css @keyframes cds-skeleton-sweep { 0% { transform: translate(-100%); } 100% { transform: translate(100%); } } ``` > **生产级独立组件实现**:[`code-examples/StatusIndicators.tsx`](../code-examples/StatusIndicators.tsx)。 --- ### 2.4 模态确认对话框 [#24-模态确认对话框] > **技术领域与英文指代**:`Confirmation Dialog - [data-cds="Dialog"]` 在执行清空会话、删除项目、重置密钥或高风险 MCP 工具调用时呼出的模态确认对话框: #### 2.4.1 6 阶弹窗标尺与视口安全上限 [#241-6-阶弹窗标尺与视口安全上限] 依据 REA 对 `shared-frame-BfjMqbuN.js` 生产 Dialog 控制器的提取,Claude 构建了系统级 6 阶弹窗矩阵: ```javascript /* 提取自官方生产包 shared-frame-BfjMqbuN.js 原生 Qg 尺寸表 */ const Qg = { sm: "max-w-[400px]", // 极简确认、单项授权 md: "max-w-[520px]", // 标准确认模态框(默认) lg: "max-w-[720px]", // 复杂表单、环境配置 xl: "max-w-[880px]", // 代码对比确认 "2xl": "max-w-[1024px]", // 宽屏工件预览 "3xl": "max-w-[1152px]" // 全功能工作区看板 }; ``` * **视口高度自适应截断安全公式 (`--environment-dialog-cap`)**: ```css --environment-dialog-cap: calc( 100dvh - max(2rem, 2 * var(--desktop-titlebar-inset, 0px)) - 2 * max(env(safe-area-inset-top, 0px), env(safe-area-inset-bottom, 0px)) ); ``` 保证弹窗在所有桌面端(macOS 信号灯刘海屏、Windows 标题栏)下均不溢出视口。 --- #### 2.4.2 嵌套弹窗防御体系 (Nested Dialog Blurring Protocol) [#242-嵌套弹窗防御体系-nested-dialog-blurring-protocol] 当模态对话框内部再次唤起二级子弹窗时(如在确认弹窗中点击“查看详情”弹窗),Claude 通过属性选择器自动对底层父弹窗进行物理虚化与暗化拦截: ```javascript /* 提取自 shared-frame-BfjMqbuN.js */ const Xg = "after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:bg-backdrop after:opacity-0 after:z-50 after:transition-opacity after:duration-base after:ease-out data-[nested-dialog-open]:after:opacity-100"; const Zg = "data-[nested-dialog-open]:blur-[2px]"; ``` 当父弹窗检测到 `data-[nested-dialog-open]` 时: 1. 立即触发 `blur-[2px]`,消除文字高频细节; 2. 伪元素 `after` 透明度从 0 平滑过渡至 100%,覆盖一层半透明微遮罩; 3. 视线焦点绝对聚焦于最新呼出的二级模态框。 --- #### 2.4.3 原生滚动时间轴与双环弥散投影 [#243-原生滚动时间轴与双环弥散投影] * **双环 Popover 投影 (`--cds-shadow-popover`)**: 外层高斯模糊与内层倒角物理顶光反光,外轮廓不带任何 1px 生硬黑线。 * **滚动时间轴驱动**: 容器内置 `[scroll-timeline:--cds-dialog-scroll_block]` 与 `.scroll-fade-y`,内容超长产生纵向滚动时,自动触发 Chapter 1 提取的 28px 相对色彩渐隐遮罩。 > **生产级独立组件实现**:[`code-examples/ConfirmationDialog.tsx`](../code-examples/ConfirmationDialog.tsx)。 --- ### 2.5 附件磁贴与上下文胶囊 [#25-附件磁贴与上下文胶囊] > **技术领域与英文指代**:`Attachment Cards & Inline Chips - [data-cds="MessageAttachmentsFile"]` 用户在对话流中发送文件或在输入框中暂存附件时呈现的卡片控件: #### 2.5.1 严苛正方形 7.5rem 磁贴架构与自适应同心圆角 [#251-严苛正方形-75rem-磁贴架构与自适应同心圆角] REA 对生产包 `shared-2-Cb74JByF.js` 的全量提取彻底纠正了社区普遍猜测的“128px × 96px 扁长矩形”,官方真实类名如下: ```javascript /* 提取自 shared-2-Cb74JByF.js 原生 Yf 磁贴容器类名 */ const Yf = "group/tile relative isolate size-[calc(7.5rem*var(--cds-rem-scale,1))] shrink-0 rounded-card outline-none focus-visible:shadow-focus"; ``` * **真实几何规格**: `size-[calc(7.5rem * var(--cds-rem-scale, 1))]`:基础为 **严格正方形 120px**,经桌面缩放因子校准后为 **112.94px × 112.94px**。 * **同心圆角**:采用 Chapter 1 确立的 `rounded-card`(`--radius-card`),内嵌元素曲率与外框保持绝对同心。 * **立体漫射**:外嵌 `shadow-field-drop`,Hover 时微抬升过渡至 `hover:shadow-xs`。 --- #### 2.5.2 浮动微圆形移除按钮协议 (`data-cds-attachment-remove`) [#252-浮动微圆形移除按钮协议-data-cds-attachment-remove] 移除按钮并不占位内部网格,而是以极高精度悬浮于右上角: ```javascript /* 提取自 shared-2-Cb74JByF.js 原生 _p 移除按钮 */ const removeBtnClasses = "cds-reset absolute -end-2 -top-2 z-[1] inline-flex size-5 items-center justify-center rounded-full bg-surface-3 text-secondary shadow-card-ring hover:text-primary outline-none focus-visible:shadow-focus"; ``` * **绝对定位**:`absolute -end-2 -top-2 z-[1]`(向右上方悬浮超出 8px)。 * **微型圆点**:`size-5`(严格 20px 直径),底色为最高层级 `Surface 3`。 * **物理防呆**:配备 `shadow-card-ring` 发丝保护环,按压触发 `active:scale-90` 触觉回馈。 --- #### 2.5.3 双向中间智能截断算法 (Bi-Directional Mid-Truncation) [#253-双向中间智能截断算法-bi-directional-mid-truncation] 在长文件名显示场景中,传统单向省略(`truncate` / `text-overflow: ellipsis`)会将文件末尾的扩展名硬生生截断为 `long_filename_final...`,导致用户无法判断文件类型。Claude 采用精密的**双向智能中间截断算法**: ```html {head} {tailStem} {tailExt} ``` 无论文件名多长(如 `deep_reinforcement_learning_policy_gradient_v3.tsx`),扩展名 `.tsx` 永远以 `shrink-0` 锁定展示,中间自动由 `before:content-['…']` 动态连接。 --- #### 2.5.4 动态全大写类型徽标 (Uppercase Badge) [#254-动态全大写类型徽标-uppercase-badge] 磁贴左上角自动解析文件后缀并转为大写无衬线徽标(如 `TS`, `PY`, `PDF`, `CSV`, `SQL`),使用等宽字形与高对比度微弱背景胶囊展现,保证文件类型在一瞥之间清晰可辨。 > **生产级独立组件实现**:[`code-examples/AttachmentCard.tsx`](../code-examples/AttachmentCard.tsx)(已全量同步 7.5rem 正方形、双向中间智能截断算法与浮动移除按钮协议)。 ---

[⬅️ 第一篇:设计哲学与设计令牌体系](01-设计哲学与设计令牌体系.md) · [📚 目录](Claude%20Design%20System%20(CDS).md) · [第三篇:会话核心流与指令交互引擎 ➡️](03-会话核心流与指令交互引擎.md)

# 03-会话核心流与指令交互引擎 (/docs/v1/03)

[⬅️ 上一篇:第二篇:基础原子组件与交互控件](02-基础原子组件与交互控件.md) · [📚 返回总目录](Claude%20Design%20System%20(CDS).md) · [下一篇:第四篇:动效物理学、着色器与环境光影 ➡️](04-动效物理学、着色器与环境光影.md)

--- ## 第三篇:会话核心流与指令交互引擎 [#第三篇会话核心流与指令交互引擎] > **技术领域与英文指代**:`Chat Stream & Composer Engine` > **分析审计基线**:基于 **REA (Reverse Engineer Anything) v6.5.0** 对官方 macOS 桌面生产包 `/Applications/Claude.app`(`@ant/desktop v2.37337.1`,构建时间戳 `2026-10-13T22:16:06Z`)进行全量 AST 反编译与样式取证。**绝无主观推测,全量引述真实源码与 CSS 规则**。 ### 生产环境取证溯源清单 [#生产环境取证溯源清单] | 规范领域 | 官方生产文件 Hash | 核心取证符号 / 规则 | | :--- | :--- | :--- | | **消息气泡与版心排版** | `frame-shell-chrome-CAw-tYzh.js` | `[data-cds=UserMessage]`, `[data-cds=AssistantMessage]`, `--cds-message-bubble-radius`, `--cds-assistant-message-text-inset`, `--cds-assistant-message-text-stop` | | **会话状态机与阅读折叠** | `shared-2-Cb74JByF.js` | `UX` (`UserMessage`), `bY`, `xY`, `yY`, 300px 截断与 `mask-image` 渐变遮罩, `MessageActions` 焦点漫游 | | **思考时间轴与波浪动效** | `cc1aae219-DtZTxCKj.css` | `.timeline-quiet-dots`, `@keyframes timeline-quiet-dot` (1.9s), `.timeline-expand` (Grid 0fr), `.timeline-status-*` | | **输入法合成赛跑防御** | `shared-frame-BfjMqbuN.js` | `Lm()`, `Rm()`, `zm()`, `Bm()`, `Um()`, WebKit 500ms Post-Composition Delta Guard, `beforeinput` 拦截 | | **Slash 与 Mention 语法树** | `cb6930dae-BD0W5ZM9.js` | `cs()` 词法解析器, `Qo` (`@` 提及), `$o` (中日韩全角标点剥离), `rs = 1024`, 256 个文件引用熔断阈值 | | **Token 计量与缓存生命周期** | `c058e28e3-DXZbxFF9.js`, `c30db9bec-DjF3pT_h.js` | `ephemeral_5m_input_tokens`, `ephemeral_1h_input_tokens`, `adaptive` thinking 架构, 4色显存解构 | | **MCP 工具授权与人机协同** | `c05b96c7f-DklIyA-P.js`, `cc1aae219-DjR8LnUv.js` | `structured_content`, `ws()`, `user_denied`, `policy_denied`, `PERMISSIONS_ERROR`, `bs` 330s 垃圾回收 | --- ### 3.1 会话气泡套件与排版规范 [#31-会话气泡套件与排版规范] > **技术领域与英文指代**:`User & Assistant Message Bubbles` #### 3.1.1 用户提问气泡 (`[data-cds="UserMessage"]`) [#311-用户提问气泡-data-cdsusermessage] 取证自 `frame-shell-chrome-CAw-tYzh.js` 与 `shared-2-Cb74JByF.js`,用户消息在 CDS 中具有严谨的容器几何与状态结构: ``` [data-cds="UserMessage"][data-author="self"][data-state="done"][data-text-size="md"] ├── AttachmentPreview (若随附附件,MessageAttachmentsFile 7.5rem 磁贴) ├── Bubble Container (yY: rounded-[--cds-message-bubble-radius] px-[--cds-message-bubble-pad-x] py-[--cds-message-bubble-pad-y]) │ ├── .cds-user-message-body (正文,若超出 300px 施加 3rem 底部渐变蒙版) │ └── Show more / Show less (折叠切换按钮) └── MessageActions (悬浮工具条: Copy, Edit, Retry, 快捷漫游) ``` ##### 1. 真实圆角与几何尺寸公式 (REA 取证) [#1-真实圆角与几何尺寸公式-rea-取证] ```css /* frame-shell-chrome-CAw-tYzh.js 官方声明 */ .cds-root [data-cds=UserMessage], .cds-root [data-cds=AssistantMessage][data-variant=bubble], .cds-root [data-cds=AssistantMessage][data-cds-bubble-stack] { --cds-message-bubble-radius: calc(var(--cds-radius) + calc(.25rem * var(--cds-rem-scale, 1))); --cds-message-bubble-pad-x: var(--cds-pad-lg); /* 16px */ --cds-message-bubble-pad-y: var(--cds-pad-md); /* 12px */ --cds-message-bubble-measure: 85%; } ``` * **圆角计算**:在默认 `--cds-radius: 8px`、`--cds-rem-scale: 1` 基础下,`calc(8px + 4px) = 12px`;在桌面加大模式下扩展至 `18px`。 * **版心宽度**:`max-w-[var(--cds-message-bubble-measure)]` 约束为 `85%`。当屏幕宽度小于 `40rem` 时自动降级为 `clamp(85%, 448px, 100%)`。 * **背景与文字颜色**: - 默认模式:`bg-[var(--cds-bg-user-message)]`(浅色为中性浅灰 `var(--cds-bg-neutral)`)。 - Personal 专属色调:`bg-[var(--cds-bg-user-message-personal)] text-[color:var(--cds-text-user-message-personal)]`。在浅色模式下为 `#dde8f7`,深色模式下为 `#193c5f`。 - 动态悬浮反应:在 `.feed-bubble-reacts:hover` 状态下注入 `--cds-bg-user-message: var(--cds-bg-neutral-hover); --feed-bubble-mix: 16%;`。 ##### 2. 超长折叠与阅读渐变蒙版 (Truncation & Mask) [#2-超长折叠与阅读渐变蒙版-truncation--mask] 在 `shared-2-Cb74JByF.js` 中,当用户提问文字垂直高度超过 `collapseThreshold = 300px` 时,自动进入折叠态: ```css /* REA 取证:3rem 底部衰减蒙版 */ .cds-user-message-collapsed { max-height: 300px; overflow: hidden; mask-image: linear-gradient(to bottom, black calc(100% - 3rem), transparent); -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 3rem), transparent); } ``` --- #### 3.1.2 模型回答正文 (`[data-cds="AssistantMessage"]`) [#312-模型回答正文-data-cdsassistantmessage] 与传统聊天软件将 AI 回答同样装入边框气泡的做法截然相反,Claude Desktop 秉持**“内容即界面,零边框透明画布哲学”**。 ##### 1. 文本微缩进与止动流体力学 (Text Inset & Stop Law) [#1-文本微缩进与止动流体力学-text-inset--stop-law] ```css /* frame-shell-chrome-CAw-tYzh.js 官方声明 */ .cds-root [data-cds=AssistantMessage] { --cds-assistant-message-text-inset: 4px; --cds-assistant-message-text-stop: clamp(0px, (100% - 384px) * .175, 56px); } /* 当正文内部嵌套卡片、数据表格、代码块或 MCP 面板时,微缩进立即精确归零 */ .cds-root [data-cds=AssistantMessage] :is( [data-cds=Card], [data-cds=Surface], [data-cds=Panel], [data-cds=Banner], [data-cds=Aside], [data-cds=Accordion], [data-cds=PreviewCard], [data-cds=Table], [data-cds=DataTable], [data-cds=AskUserQuestion], [data-cds=CommentCard], [data-cds=ChartContainer], [data-cds=PointChartContainer], [data-cds=FileDiff], [data-cds=UserMessage] ) { --cds-assistant-message-text-inset: 0px; --cds-assistant-message-text-stop: 0px; } ``` * **微缩进律**:文字正文保持 `4px` 左侧极轻微呼吸缩进,与顶部的 Claude ✦ 徽标保持光学对齐。 * **卡片重置律**:一旦内容流中出现结构化卡片(如代码块、Artifact 预览、MCP 授权面板),立即将 Inset 与 Stop 归零为 `0px`,确保卡片充满版心容器。 ##### 2. 纵向排版律动 (Vertical Rhythm) [#2-纵向排版律动-vertical-rhythm] 取证自 `shared-styles-Bl9zqrv-.css`: $$\text{chat-turn-gap} = \text{chat-body} \times \text{chat-leading} \times 0.75$$ $$\text{chat-item-gap} = \text{chat-body} \times \text{chat-leading} \times 0.50$$ 在 `md` 字号(`chat-body: 14px`, `chat-leading: 1.42857`)下,消息轮次间距精确为 `15px`,块间距精确为 `10px`。 --- ### 3.2 思考过程折叠与时间状态机 [#32-思考过程折叠与时间状态机] > **技术领域与英文指代**:`Thinking Accordion & Timeline Status Machine` Claude 在流式呈现 Thinking(扩展思考过程)时,在 CSS 与 JS 运行时构建了四阶微交互体系(源码取证自 `cc1aae219-DtZTxCKj.css` 与 `shared-2-Cb74JByF.js`)。 ```mermaid stateDiagram-v2 [*] --> Generating: 模型开始输出思考流 Generating --> Generating: 3点波浪跳跃 (1.9s infinite cubic-bezier(.4, 0, .2, 1)) Generating --> Generating: 展开互斥锁锁定 (isOpen=true, 禁止折叠防抖动) Generating --> Settled: 思考流终结 Settled --> Collapsed: 用户点击折叠 (Grid 1fr -> 0fr, .2s) Collapsed --> Expanded: 用户再次点击 (Grid 0fr -> 1fr) ``` #### 3.2.1 3点静默跳跃指示波浪 (`.timeline-quiet-dots`) [#321-3点静默跳跃指示波浪-timeline-quiet-dots] 在官方 `cc1aae219-DtZTxCKj.css` 中提取出其完全物理关键帧: ```css .timeline-quiet-dots { gap: 3.5px; display: inline-flex; position: relative; top: .26em; } .timeline-quiet-dots > span { background: var(--cds-clay, #d97757); opacity: 0; border-radius: 50%; width: 3px; height: 3px; animation: 1.9s cubic-bezier(.4, 0, .2, 1) infinite timeline-quiet-dot; } .timeline-quiet-dots > span:nth-child(2) { animation-delay: .15s; } .timeline-quiet-dots > span:nth-child(3) { animation-delay: .3s; } @keyframes timeline-quiet-dot { 0%, 8% { opacity: 0; transform: translateY(2px); } 22% { opacity: 1; transform: translateY(-2.5px); } 36%, 70% { opacity: 1; transform: translateY(0); } 90%, 100%{ opacity: 0; transform: translateY(0); } } ``` * **三阶位移物理**: 1. $0\% \sim 8\%$:下沉 $2\text{px}$ 准备弹起; 2. $22\%$:向上冲刺至最高点 $-2.5\text{px}$,透明度达到 $100\%$; 3. $36\% \sim 70\%$:自然落回基准点 $0\text{px}$ 稳定驻留; 4. $90\% \sim 100\%$:淡出归零,等待下一个 $1.9\text{s}$ 循环。 #### 3.2.2 状态条平滑升降物理 (`timeline-status-*`) [#322-状态条平滑升降物理-timeline-status-] 思考完成与状态切换时不使用生硬的显隐,而是通过升降动画平滑交接: * **入场**:`.timeline-status-enter-quiet`,`.24s cubic-bezier(.3, .7, .4, 1)` 从 `translateY(6px)` 抬升至基线; * **退场**:`.timeline-status-exit-quiet`,`.18s ease-out` 向下掉落 `translateY(-4px)` 并渐变透明。 #### 3.2.3 CSS Grid 伸缩展开防抖 (`.timeline-expand`) [#323-css-grid-伸缩展开防抖-timeline-expand] 为了消除常规 JavaScript 计算 `scrollHeight` 带来的性能开销与视口突变,CDS 全面采用现代 CSS Grid 尺寸过渡: ```css .timeline-expand { grid-template-rows: 1fr; display: grid; } .timeline-expand > * { align-self: start; min-width: 0; min-height: 0; } @keyframes timeline-expand { 0% { opacity: 0; grid-template-rows: 0fr; } 100% { opacity: 1; grid-template-rows: 1fr; } } .timeline-expand-enter { animation: .2s cubic-bezier(.19, 1, .22, 1) timeline-expand; } ``` --- ### 3.3 新一代富文本输入框终端与指令交互引擎 [#33-新一代富文本输入框终端与指令交互引擎] > **技术领域与英文指代**:`Chat Composer & Next-Gen Engine` 在 Claude Desktop 生产端中,输入框已由传统简单的 `