Skip to content

[Feature]: Add light/dark theme toggle #4

Closed

Description

@Nivyasudeesh

Feature Description

Add a theme toggle button so visitors can switch the site between light and dark mode. The choice should be remembered across visits.

Proposed Implementation

  1. Move the colours in style.css into CSS variables (e.g. --bg, --text, --accent) defined on :root, with an overriding set under [data-theme="dark"] or [data-theme="light"].
  2. Add a toggle button (sun/moon icon) in the header or navbar in index.html.
  3. In script.js, switch the data-theme attribute on when the button is clicked.
  4. Save the choice in localStorage and apply it on page load.
  5. On first visit, default to the user’s system setting using prefers-color-scheme.
  6. Set the toggle’s aria-label, and make it keyboard accessible.

Additional Context

No response

Checklist

  • I confirm that I want to work on this feature.
  • I have searched the existing issues for similar feature requests.
  • I have read the CONTRIBUTING.md guidelines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions