如何单独更改侧边栏主题?能否为侧边栏配置Dark主题且为编辑器配置Light主题?
Hey there! Let me walk you through exactly how to pull this off—this is a super common customization request, especially for folks who prefer a dark navigation area but a light editing space.
Can I Set a Dark Sidebar + Light Editor?
Absolutely! Most modern code editors (like VS Code, which I’ll focus on since it’s the most widely used) let you mix and match theme components with granular settings or custom tweaks.
Step-by-Step Guide for VS Code
Method 1: Use Built-in Settings (No CSS Needed)
This is the easiest way, using VS Code’s native color customization options:
- Open your settings: Press
Ctrl+,(Windows/Linux) orCmd+,(Mac). - First, set your editor to Light theme:
- Search for
editor.colorThemeand select a light theme (e.g.,Light+ (Default Light)).
- Search for
- Now, customize the sidebar to use Dark theme colors:
- Search for
workbench.colorCustomizationsand clickEdit in settings.json. - Paste the following code snippet into the JSON file—this replicates the core Dark+ theme styles for the sidebar and related UI elements:
"workbench.colorCustomizations": { // Activity Bar & Sidebar Base Styles "activityBar.background": "#1e1e1e", "activityBar.foreground": "#cccccc", "sidebar.background": "#252526", "sidebar.foreground": "#cccccc", "sidebar.border": "#1e1e1e", // Sidebar Headers "sidebarSectionHeader.background": "#2d2d30", "sidebarSectionHeader.foreground": "#cccccc", // Explorer List Styles "list.activeSelectionBackground": "#0e639c", "list.activeSelectionForeground": "#ffffff", "list.hoverBackground": "#2a2d2e", "list.hoverForeground": "#ffffff" }
- Search for
- Save the settings.json file, and you’ll see the sidebar switch to Dark while your editor stays Light instantly!
Method 2: Use Custom CSS (For Full Control)
If you want to tweak every tiny UI detail, you can use VS Code’s custom CSS support (note: this requires an extension):
- Install the
Custom CSS and JS Loaderextension from the marketplace. - Create a new CSS file (e.g.,
sidebar-dark.css) with these styles:/* Activity Bar */ .activitybar { background-color: #1e1e1e !important; color: #cccccc !important; } /* Sidebar Container */ .sidebar { background-color: #252526 !important; color: #cccccc !important; } /* Sidebar Section Headers */ .sidebar-section-header { background-color: #2d2d30 !important; color: #cccccc !important; } /* Selected/Hovered Explorer Items */ .monaco-list-row.selected { background-color: #0e639c !important; color: #ffffff !important; } .monaco-list-row:hover { background-color: #2a2d2e !important; color: #ffffff !important; } - In VS Code settings, add the path to your CSS file under
vscode_custom_css.imports:"vscode_custom_css.imports": [ "file:///path/to/your/sidebar-dark.css" ] - Reload VS Code using the command
Reload Custom CSS and JS(open the command palette withCtrl+Shift+PorCmd+Shift+Pto run this).
Quick Notes for Other Editors
If you’re using a different editor, the approach is intuitive too:
- Sublime Text: Use Package Control to install a theme that supports split UI/editor themes, or edit the
.tmThemefile to override sidebar colors manually. - Atom: Head to
Settings > Themes—Atom natively separates UI and syntax themes, so just set your UI theme to Dark and Syntax theme to Light!
内容的提问来源于stack exchange,提问作者free2idol1
相关产品推荐
相关产品推荐

