Skip to content

fix(theme): use modern sidebar CSS to respect system scrollbar settings #2973

Merged
SoonIter merged 4 commits intomainfrom
vk/8755-
Jan 8, 2026
Merged

fix(theme): use modern sidebar CSS to respect system scrollbar settings #2973
SoonIter merged 4 commits intomainfrom
vk/8755-

Conversation

@SoonIter
Copy link
Copy Markdown
Member

@SoonIter SoonIter commented Jan 7, 2026

Summary

Fix the sidebar and other vertical scrollbars to respect macOS system scrollbar settings. Previously, vertical scrollbars were always visible even when the system was configured to show scrollbars only "When scrolling".

image

Impact

  • Sidebar: Vertical scrollbar respects system settings (auto-hide when configured)
  • Outline (right TOC): Same auto-hide behavior
  • Code blocks: Horizontal scrollbar unchanged, vertical now auto-hides
  • Tables: No change (uses independent styling)

Browser Compatibility

  • Chrome/Edge: Full support for webkit and modern scrollbar properties
  • Safari: webkit scrollbar pseudo-elements
  • Firefox: Modern scrollbar-width and scrollbar-color properties

This PR was written using Vibe Kanban

## 修复完成

我已经成功修复了 Sidebar 滚动条的行为问题。修改文件:`packages/core/src/theme/styles/scrollbar.scss`

### 关键更改

1. **移除了 `width: 4px`**(第 6 行)
   - 这允许竖向滚动条使用 overlay 样式,遵循 macOS 系统设置

2. **保留了 `height: 4px`**(第 11 行)
   - 横向滚动条保持当前行为

3. **添加了现代 CSS 属性**(第 5-6 行)
   - `scrollbar-width: thin` - 适用于 Firefox 和 Chrome 121+
   - `scrollbar-color: transparent transparent` - 默认透明

4. **更新了滚动条颜色逻辑**
   - 默认状态:完全透明(不可见)
   - 悬停状态:显示自定义颜色(浅色模式灰色,深色模式白色)
   - 添加了对现代 `scrollbar-color` 属性的支持

### 效果

现在当你在 macOS 系统设置中选择"滚动时"显示滚动条时:
- **Sidebar** 的竖向滚动条会自动隐藏,只在滚动时显示
- **Outline**(右侧目录)同样遵循系统设置
- **代码块**的横向滚动条保持 4px 高度,竖向滚动条也会自动隐藏
- **表格**不受影响(有独立样式)

所有滚动条在鼠标悬停容器时会显示自定义颜色,提供视觉反馈。
Copilot AI review requested due to automatic review settings January 7, 2026 09:44
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 7, 2026

Deploy Preview for rspress-v2 ready!

Name Link
🔨 Latest commit b6e686b
🔍 Latest deploy log https://app.netlify.com/projects/rspress-v2/deploys/695f7064e7db6b00080b63b5
😎 Deploy Preview https://deploy-preview-2973--rspress-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 7, 2026

Rsdoctor Bundle Diff Analysis

Found 3 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
node 9.6 MB +23.6 KB (0.2%)
node_md 1.2 MB 0
web 15.5 MB +219.0 B (0.0%)
📋 Detailed Reports (Click to expand)

📁 node

Path: website/doc_build/diff-rsdoctor/node/rsdoctor-data.json

📌 Baseline Commit: 325b1ca7cc | PR: #2976

Metric Current Baseline Change
📊 Total Size 9.6 MB 9.6 MB +23.6 KB (0.2%)
📄 JavaScript 0 B 0 B 0
🎨 CSS 0 B 0 B 0
🌐 HTML 9.6 MB 9.6 MB +23.6 KB (0.2%)
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: node Bundle Diff

📁 web

Path: website/doc_build/diff-rsdoctor/web/rsdoctor-data.json

📌 Baseline Commit: 325b1ca7cc | PR: #2976

Metric Current Baseline Change
📊 Total Size 15.5 MB 15.5 MB +219.0 B (0.0%)
📄 JavaScript 14.8 MB 14.8 MB +21.0 B (0.0%)
🎨 CSS 130.2 KB 130.0 KB +198.0 B (0.1%)
🌐 HTML 0 B 0 B 0
📁 Other Assets 556.0 KB 556.0 KB 0

📦 Download Diff Report: web Bundle Diff

Generated by Rsdoctor GitHub Action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to implement "show on hover" behavior for scrollbars to respect system preferences where scrollbars should only appear when scrolling. The changes modify the scrollbar styling to make scrollbars transparent by default and visible on hover, adapting an approach from Next.js.

Key changes:

  • Added modern scrollbar properties (scrollbar-width, scrollbar-color) for Firefox and Chrome 121+
  • Changed default scrollbar thumb from semi-visible to transparent
  • Implemented hover-based visibility where scrollbars only appear when hovering the scrollable container

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/core/src/theme/styles/scrollbar.scss Outdated
Comment thread packages/core/src/theme/styles/scrollbar.scss Outdated
Comment thread packages/core/src/theme/styles/scrollbar.scss
Comment thread packages/core/src/theme/styles/scrollbar.scss Outdated
@SoonIter SoonIter changed the title 修正滚动条行为 (vibe-kanban) fix(theme): respect system scrollbar settings for vertical scrollbars (Vibe Kanban) Jan 7, 2026
## 重构完成

我已成功重构了滚动条样式系统,采用基类 + 修饰符模式:

### 修改的文件

1. **`packages/core/src/theme/styles/scrollbar.scss`**
   - 重构为两个独立的类
   - 修复了 Copilot 指出的颜色值不匹配问题

2. **`packages/core/src/theme/components/CodeBlock/index.tsx`** (line 95)
   - 添加了 `rp-scrollbar--hover` 类名

### 关键改进

**`.rp-scrollbar` (基类)**
- 仅包含基础滚动条样式
- 移除了 `width: 4px`,允许竖向滚动条使用 overlay 模式
- 保留了 `height: 4px` 用于横向滚动条
- 修复颜色值:`scrollbar-color: rgba(0, 0, 0, 0.05) transparent` 现在与 webkit 的 `background: rgba(0, 0, 0, 0.05)` 匹配
- 滚动条根据 macOS 系统设置显示/隐藏

**`.rp-scrollbar--hover` (修饰符类)**
- 专门用于 CodeBlock 的"hover 显示"行为
- 默认完全透明(隐藏)
- 鼠标悬停容器时才显示
- 颜色值与基类保持一致

### 行为变化

**Sidebar、Outline、Search Panel**(仅使用 `.rp-scrollbar`)
- ✅ 遵循 macOS 系统设置
- ✅ "滚动时显示"模式下自动隐藏
- ✅ "始终显示"模式下保持可见

**CodeBlock**(使用 `.rp-scrollbar` + `.rp-scrollbar--hover`)
- ✅ 默认完全隐藏滚动条
- ✅ 鼠标悬停时显示
- ✅ 覆盖系统设置,强制使用 hover 行为

### 关于 Copilot 的反馈

✅ **修复了颜色不匹配** - 所有颜色值现在在 `scrollbar-color` 和 webkit 样式之间保持一致
✅ **分离了关注点** - hover 行为现在独立于基类
⚠️ **保持 width 移除** - 这是有意为之,允许 overlay 滚动条行为(基于研究,Copilot 的担忧是不正确的)
@SoonIter SoonIter requested a review from Timeless0911 January 8, 2026 08:57
@SoonIter SoonIter changed the title fix(theme): respect system scrollbar settings for vertical scrollbars (Vibe Kanban) fix(theme): use modern sidebar CSS to respect system scrollbar settings Jan 8, 2026
@SoonIter SoonIter enabled auto-merge (squash) January 8, 2026 08:58
@SoonIter SoonIter merged commit 7f2f966 into main Jan 8, 2026
10 checks passed
@SoonIter SoonIter deleted the vk/8755- branch January 8, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants