Close Menu

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    How to make Happy birthday cake Animation using HTML & CSS

    29 May 2025

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025
    Facebook X (Twitter) Instagram YouTube Telegram Threads
    Coding StellaCoding Stella
    • Home
    • Blog
    • HTML & CSS
      • Login Form
    • JavaScript
    • Hire us!
    Coding StellaCoding Stella
    Home - JavaScript - How to make Neumorphism Calculator with Dark Light Theme in HTML CSS & JavaScript
    JavaScript

    How to make Neumorphism Calculator with Dark Light Theme in HTML CSS & JavaScript

    Coding StellaBy Coding Stella20 March 2025No Comments6 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Email WhatsApp Copy Link

    Hello folks! Today, let’s build something practical and cool – a Neumorphism Calculator with Dark and Light themes using HTML, CSS, and JavaScript.

    In this tutorial, we’re not just creating a calculator; we’re diving into the world of Neumorphism design, giving our project a sleek and modern look. With the help of JavaScript, we’ll add the flexibility to switch between Dark and Light themes. Whether you’re a seasoned coder or just starting out, this is a great way to boost your skills and add a touch of style to your web creations.

    We’ll use HTML to structure the calculator, CSS for neumorphism styling and theme switching, and JavaScript to handle the calculator’s functionality and theme toggle.

    HTML :

    This HTML code defines a simple calculator webpage with a neumorphic design. It includes buttons for digits, basic arithmetic operations, and a clear button. The JavaScript file “script.js” likely handles the calculator’s functionality. The design uses the Montserrat font and includes a dark/light mode toggle.

    <!DOCTYPE html>
    <html lang="en" >
    <head>
      <meta charset="UTF-8">
      <title>Neumorphism Calculator Dark/Light | CodingStella</title>
      <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500&amp;display=swap'><link rel="stylesheet" href="./style.css">
    
    </head>
    <body>
    <!-- partial:index.partial.html -->
    <div class="toggleBtn"></div>
    <div class="calculator">
      <div class="buttons">
        <h2 id="value"></h2>
        <span id="clear">Clear</span>
        <span>/</span>
        <span>*</span>
        <span>7</span>
        <span>8</span>
        <span>9</span>
        <span>-</span>
        <span>4</span>
        <span>5</span>
        <span>6</span>
        <span id="plus">+</span>
        <span>1</span>
        <span>2</span>
        <span>3</span>
        <span>0</span>
        <span>00</span>
        <span>.</span>
        <span id="equal">=</span>
      </div>
    </div>
    <!-- partial -->
      <script  src="./script.js"></script>
    
    </body>
    </html>

    CSS :

    The provided code code defines the styles for a neumorphic calculator webpage. It includes general styles such as font, body layout, and background color. The calculator has neumorphic buttons with shadows and a distinctive design for clear, plus, and equal buttons. Additionally, there’s a dark mode with adjusted colors, and a toggle button at the top right switches between dark and light modes.

    /* General Styles */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: "Montserrat", sans-serif;
    }
    
    body {
      display: flex;
      justify-content: center;
      align-items: center;
      min-height: 100vh;
      background: #edf1f4;
    }
    
    .calculator {
      position: relative;
      width: 340px;
      padding: 20px;
      border-radius: 20px;
      box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.1), -15px -15px 20px #fffb;
    }
    
    .calculator .buttons {
      position: relative;
      display: grid;
    }
    
    .calculator .buttons #value {
      position: relative;
      grid-column: span 4;
      user-select: none;
      overflow: none;
      width: 100%;
      text-align: end;
      color: #5166d6;
      height: 100px;
      line-height: 100px;
      box-shadow: inset 5px 5px 10px rgba(0, 0, 0, 0.1), inset -5px -5px 20px #fff;
      border-radius: 10px;
      margin-bottom: 12px;
      padding: 0 20px;
      font-size: 2em;
      font-weight: 500;
    }
    
    .calculator .buttons span {
      position: relative;
      padding: 10px;
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1), -5px -5px 20px #fff;
      margin: 10px;
      border-radius: 10px;
      cursor: pointer;
      user-select: none;
      min-width: 40px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 1.2em;
      color: #666;
      border: 2px solid #edf1f4;
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1), -5px -5px 10px #fff;
    }
    
    .calculator .buttons span:active {
      box-shadow: inset 5px 5px 10px rgba(0, 0, 0, 0.1), inset -5px -5px 10px #fff;
      color: #f44336;
    }
    
    .calculator .buttons span#clear {
      grid-column: span 2;
      background-color: #f44336;
      color: #fff;
      border: 2px solid #edf1f4;
    }
    
    .calculator .buttons span#plus {
      grid-row: span 2;
      background-color: #31a935;
      color: #fff;
      border: 2px solid #edf1f4;
    }
    
    .calculator .buttons span#equal {
      grid-row: span 2;
      background-color: #2196f3;
      color: #fff;
      border: 2px solid #edf1f4;
    }
    
    .calculator .buttons span#clear:active,
    .calculator .buttons span#plus:active,
    .calculator .buttons span#equal:active {
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1), -5px -5px 10px #fff,
        inset 5px 5px 10px rgba(0, 0, 0, 0.1);
    }
    
    .toggleBtn {
      position: fixed;
      top: 20px;
      right: 20px;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background: #555;
      cursor: pointer;
      border: 2px solid #edf1f4;
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1), -5px -5px 10px #fff;
    }
    
    .dark {
      background: #282c2f;
    }
    
    .dark .calculator {
      background: #33393e;
      box-shadow: 15px 15px 20px rgba(0, 0, 0, 0.25),
        -15px -15px 20px rgba(255, 255, 255, 0.1);
    }
    
    .dark .calculator .buttons #value {
      background: #33393e;
      color: #eee;
      box-shadow: inset 15px 15px 20px rgba(0, 0, 0, 0.5),
        inset -15px -15px 20px rgba(255, 255, 255, 0.1);
    }
    
    .dark .calculator .buttons span {
      color: #eee;
      border: 2px solid #333;
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.25),
        -5px -5px 10px rgba(255, 255, 255, 0.1);
    }
    
    .dark .calculator .buttons span:active {
      box-shadow: inset 5px 5px 10px rgba(0, 0, 0, 0.25),
        inset -5px -5px 10px rgba(255, 255, 255, 0.1);
    }
    
    .dark .calculator .buttons span#clear,
    .dark .calculator .buttons span#plus,
    .dark .calculator .buttons span#equal {
      border: solid 2px #333;
    }
    
    .dark .calculator .buttons span#clear:active,
    .dark .calculator .buttons span#plus:active,
    .dark .calculator .buttons span#equal:active {
      box-shadow: inset 5px 5px 10px rgba(0, 0, 0, 0.1);
    }
    
    .dark .toggleBtn {
      background: #edf1f4;
      border: 2px solid #333;
      box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.25),
        -5px -5px 10px rgba(255, 255, 255, 0.25);
    }

    JavaScript:

    This JavaScript code adds functionality to the neumorphic calculator. It selects the calculator buttons, individual button elements, the display value, and the dark mode toggle button. It then adds click event listeners to the buttons. If the button pressed is “=”, it evaluates the mathematical expression displayed; if it’s “Clear,” it clears the display; otherwise, it appends the button’s value to the display.

    The code also toggles the “dark” class on the body element when the dark mode toggle button is clicked.

    let buttons = document.querySelector(".buttons");
    let btn = document.querySelectorAll("span");
    let value = document.getElementById("value");
    let toggleBtn = document.querySelector(".toggleBtn");
    let body = document.querySelector("body");
    
    for (let i = 0; i < btn.length; i++) {
      btn[i].addEventListener("click", function () {
        if (this.innerHTML == "=") {
          value.innerHTML = eval(value.innerHTML);
        } else {
          if (this.innerHTML == "Clear") {
            value.innerHTML = "";
          } else {
            value.innerHTML += this.innerHTML;
          }
        }
      });
    }
    
    toggleBtn.onclick = function () {
      body.classList.toggle("dark");
    };

    We’ve successfully built a Neumorphism Calculator with Dark and Light theme using HTML, CSS, and JavaScript. This sleek and modern project combines practicality with style. Whether you’re a seasoned coder or a beginner, you now have a cool addition to your portfolio. Keep coding and exploring the world of web development – great job, everyone!

    If you run into any hiccups with your project, worry not. You can easily grab the source code for this project. Just hit the Download button to get started on your coding adventure. Happy coding!

    Calculator Neumorphism
    Share. Copy Link Twitter Facebook LinkedIn Email WhatsApp
    Previous ArticleHow to make Simple Toggle with led indicator using HTML & CSS
    Next Article How to make Animated Bouncy Clock in HTML CSS & JavaScript
    Coding Stella
    • Website

    Related Posts

    JavaScript

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025
    JavaScript

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025
    JavaScript

    How to create Cross Road Game using HTML CSS and JS

    2 May 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Trending Post

    Master Frontend in 100 Days Ebook

    2 March 202419K Views

    How to make Modern Login Form using HTML & CSS | Glassmorphism

    11 January 202416K Views

    How to make I love you Animation in HTML CSS & JavaScript

    14 February 202414K Views

    How to make Valentine’s Day Card using HTML & CSS

    13 February 202412K Views
    Follow Us
    • Instagram
    • Facebook
    • YouTube
    • Twitter
    ads
    Featured Post

    JavaScript Mastery Roadmap: From Fundamentals to Expert Level

    26 January 2024

    How to make Squid Game Prize Counter using HTML CSS & JavaScript

    2 April 2024

    How to make QR Code Generator using HTML CSS & JavaScript

    14 January 2024

    15 Advanced Web Development Techniques Without JavaScript

    27 January 2024
    Latest Post

    How to make Happy birthday cake Animation using HTML & CSS

    29 May 2025

    How to create Toast Catcher Game using HTML CSS and JS

    26 May 2025

    How to create Animated No Chill Login form using HTML CSS and JS

    22 May 2025

    How to make Social media icons hover effect using HTML & CSS

    14 May 2025
    Facebook X (Twitter) Instagram YouTube
    • About Us
    • Privacy Policy
    • Return and Refund Policy
    • Terms and Conditions
    • Contact Us
    • Buy me a coffee
    © 2025 Coding Stella. Made with 💙 by @coding.stella

    Type above and press Enter to search. Press Esc to cancel.

    Ad Blocker Enabled!
    Ad Blocker Enabled!
    Looks like you're using an ad blocker. We rely on advertising to help fund our site.
    Okay! I understood