Overview
GitScope includes a full-featured dark mode that adapts the entire interface for comfortable viewing in any lighting condition. Theme preferences are automatically saved and persist across sessions.Your theme choice is saved to localStorage and restored automatically when you return to GitScope.
Quick Toggle
Switch themes instantly using the theme button in the header:Header.jsx
Light Mode
Shows a Moon icon—click to switch to dark mode
Dark Mode
Shows a Sun icon—click to switch to light mode
Implementation
The theme system uses React state and HTML data attributes:State Management
App.jsx
DOM Synchronization
App.jsx
CSS Architecture
Themes use CSS custom properties for instant switching:Key Color Variables
Background Colors
Background Colors
--bg- Main page background--card-bg- Card and panel backgrounds--card-hover- Hover state for interactive elements
Text Colors
Text Colors
--text- Primary text color--text-dim- Secondary/muted text--text-on-accent- Text displayed on accent backgrounds
Border & UI Colors
Border & UI Colors
--border- Default border color--input-bg- Input field backgrounds--shadow- Box shadow colors
Semantic Colors
Semantic Colors
--accent- Primary brand/action color--green,--yellow,--red- Status indicators--gradient-*- Gradient overlays and effects
Component Integration
All components automatically respond to theme changes:Header Component
Header.jsx
The theme prop is passed from App.jsx to control the icon display, while CSS variables handle visual changes.
Accessibility Features
ARIA Label
Button includes
aria-label="Toggle theme" for screen readersVisual Feedback
Icon changes immediately to reflect current theme state
No Flash
Theme loads from localStorage before render to prevent white flash
High Contrast
Dark mode uses carefully chosen colors for WCAG compliance
Persistent Storage
Theme preferences survive page reloads and browser sessions:Smooth Transitions
CSS transitions provide smooth color changes:Dark Mode Best Practices
Color Palette
Light Mode
Dark Mode
Icon Usage
Theme toggle uses Lucide React icons:Moon Icon
Displayed in light mode to suggest switching to dark
Sun Icon
Displayed in dark mode to suggest switching to light
User Experience Flow
Testing Different Themes
Easily test both themes during development:System Preference Detection
Current implementation defaults to light mode. To detect system preference, you could enhance the initial state:
Performance Considerations
No Repaints
CSS variables change colors without triggering layout recalculation
Instant Toggle
Theme switches happen in under 50ms for responsive UX
Minimal Storage
Only stores 5-10 bytes (‘light’ or ‘dark’) in localStorage
No Network Calls
Theme changes are purely client-side
Common Issues
White Flash on Load
White Flash on Load
If you see a white flash in dark mode, ensure localStorage is read before React renders:The function form of useState ensures synchronous localStorage read before first render.
Theme Not Persisting
Theme Not Persisting
Check that localStorage is enabled in your browser. Some privacy modes block localStorage.
Colors Not Updating
Colors Not Updating
Verify the
data-theme attribute is set on <html> and CSS custom properties are defined in :root.Related Features
User Search
Search interface adapts to dark mode automatically
Repository Explorer
Repository cards use theme-aware colors