-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Closed
Copy link
Labels
area:uiUI components, layouts, styling, accessibility.UI components, layouts, styling, accessibility.type:refactorInternal code improvements without behavior change.Internal code improvements without behavior change.
Description
Problem
The codebase currently uses runtime isDark conditional logic throughout components for dark mode theming, which creates several issues:
- Performance overhead: Every component using
useTheme()hook adds runtime checks - Bundle size impact: Dynamic class generation prevents Tailwind's tree-shaking optimization
- Maintenance complexity: Conditional logic makes components harder to read and debug
- Framework compliance: Not following Tailwind CSS official best practices for dark mode
Current Pattern (Problematic)
const { isDark } = useTheme();
className={isDark ? 'bg-stone-800 text-stone-100' : 'bg-white text-stone-900'}Desired Pattern (Best Practice)
className="bg-white text-stone-900 dark:bg-stone-800 dark:text-stone-100"Root Cause
The issue was that Tailwind CSS v4 requires explicit dark mode configuration. The fix is already implemented in globals.css:
@variant dark (&:where(.dark, .dark *));Scope
This affects numerous components across the codebase that use:
useTheme()hook withisDarkproperty- Conditional className generation based on theme
- Runtime theme switching logic
Benefits of Refactoring
- Zero runtime overhead: Pure CSS theme switching
- Better tree-shaking: Tailwind can properly analyze static classes
- Improved maintainability: Static class names are easier to debug
- Standards compliance: Follows official Tailwind dark mode patterns
- Type safety: Reduces complex conditional logic
Implementation Status
- Core fix: Added Tailwind v4 dark mode configuration
- Settings components refactored (in progress branch)
- Chat components
- Admin components
- Navigation components
- UI components
- Auth components
The refactoring should be done systematically, component by component, with proper testing to ensure theme switching continues to work correctly.
Reactions are currently unavailable
Metadata
Metadata
Labels
area:uiUI components, layouts, styling, accessibility.UI components, layouts, styling, accessibility.type:refactorInternal code improvements without behavior change.Internal code improvements without behavior change.