Skip to content

itisrajeevsingh/counter-theme-toggle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔢 Counter + Theme Toggle

A simple and interactive counter application with light/dark theme switching built using HTML, CSS, and Vanilla JavaScript.


📌 Project Overview

This project demonstrates fundamental frontend concepts including:

  • State management
  • DOM manipulation
  • Event handling
  • Conditional logic
  • Theme switching using CSS variables

It focuses on clean structure and modular logic rather than visual complexity.


🚀 Features

Feature Description
➕ Increment Increase counter value
➖ Decrement Decrease counter value (no negative values)
🔄 Reset Reset counter to zero
🌗 Theme Toggle Switch between light and dark mode
🎨 CSS Variables Theme handled using custom properties
📱 Responsive Layout Centered layout across devices

🛠 Tech Stack

Technology Usage
HTML5 Structure
CSS3 Styling & theme variables
JavaScript Logic & state management

📸 Screenshots

☀️ Light Mode

Light Mode


🌙 Dark Mode

Dark Mode


🧠 Key Concepts Demonstrated

  • Managing application state using a JavaScript variable
  • Updating UI using a dedicated render function
  • Preventing invalid state (no negative counter)
  • Toggling CSS classes for theme switching
  • Using CSS variables for scalable theming

counter-theme-toggle/ │ ├── index.html ├── style.css ├── script.js └── output/ ├── light-mode.png └── dark-mode.png


🎤 Interview Talking Points

How is state managed?

The counter value is stored in a count variable and updated through event listeners.

How did you prevent invalid submissions?

The decrement function checks if the counter is greater than zero before decreasing.

How does theme switching work?

A dark class is toggled on the <body> element, and CSS variables update colors dynamically.

Why use CSS variables?

They allow centralized theme control and scalable design adjustments.


🔮 Possible Improvements

  • Store theme preference in localStorage
  • Add animated counter transitions
  • Add input-based counter mode
  • Convert into reusable component (React)

👨‍💻 Author

Rajeev Ranjan Singh
Frontend Developer


⭐ If you found this project useful, consider giving it a star.

🏗 Project Structure

About

Responsive counter UI featuring increment, decrement, reset logic, and dynamic theme switching.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors