Skip to content

[FEATURE]: Add Dark/Light Theme Toggle #323

@Yogender-verma

Description

@Yogender-verma

Feature description

Introduce a dark/light theme switching capability that allows users to customize the application's appearance. The selected theme will be applied across the entire application and saved locally so user preferences persist between sessions. The feature will improve accessibility, reduce eye strain in low-light environments, and enhance the overall user experience.

Why this feature?

Users often prefer different visual themes depending on their environment and personal comfort. A dark mode option can reduce eye strain in low-light conditions, while light mode remains preferable for many users during daytime use. Providing a theme toggle improves accessibility, personalization, and overall user experience. Since dark mode has become a standard feature in many modern web applications, adding it helps keep the platform aligned with current user expectations and UI trends.

Implementation ideas

Implementation Ideas

This feature can be implemented on the frontend using React and Tailwind CSS without requiring backend changes.

Approach

  • Enable Tailwind CSS dark mode using class strategy in tailwind.config.js.
  • Create a global theme state using React Context API or a simple custom hook.
  • Store the user’s selected theme in localStorage to persist preferences across sessions.
  • Apply or remove the dark class on the root <html> element (document.documentElement) based on the selected theme.
  • Add a toggle button in the navbar/header to switch between light and dark modes.
  • Ensure all existing components use Tailwind dark: utility classes for consistent styling.

Suggested Libraries / Tools

  • React Context API (or Zustand/Redux if already used in project)
  • Tailwind CSS (darkMode: "class")
  • Optional: useEffect + useState for theme syncing
  • Optional: window.matchMedia("(prefers-color-scheme: dark)") for system theme detection

Rough Flow

  1. User clicks theme toggle button.
  2. Theme state updates (light ↔ dark).
  3. dark class is added/removed from <html>.
  4. Theme is saved in localStorage.
  5. On page load, theme is initialized from localStorage or system preference.

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions