<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by CodingNepal on Medium]]></title>
        <description><![CDATA[Stories by CodingNepal on Medium]]></description>
        <link>https://medium.com/@codingnepal?source=rss-95c702a58378------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_UXuNiq1mlPb-4L8LyXNyw.png</url>
            <title>Stories by CodingNepal on Medium</title>
            <link>https://medium.com/@codingnepal?source=rss-95c702a58378------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:21:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@codingnepal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Best 5+ React JS Projects for Beginners (With Source Code)]]></title>
            <link>https://codingnepal.medium.com/best-5-react-js-projects-for-beginners-with-source-code-26163457a8af?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/26163457a8af</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs-project]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Thu, 09 Jan 2025 13:35:18 GMT</pubDate>
            <atom:updated>2025-01-09T17:35:51.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Best 5+ React JS Projects for Beginners (With Source Code)" src="https://cdn-images-1.medium.com/max/1024/0*6HoeGH5vIDWbi1YH.jpg" /><figcaption>Best 5+ React JS Projects for Beginners (With Source Code)</figcaption></figure><p>Starting your React JS journey can be both exciting and overwhelming. With so many concepts to grasp, it’s easy to get lost in endless tutorials. But here’s the good news: a better way to master React is by building real-world projects. Hands-on experience lets you apply what you’ve learned, spot knowledge gaps, and see results. Plus, it’s fun!</p><p>Projects are more than just learning tools; they’re a great way to boost your confidence and showcase your skills to potential employers. Whether you’re crafting a sleek UI or integrating powerful APIs, each project brings you closer to becoming a React pro. And each one adds something unique to your portfolio, helping you stand out in the job market.</p><p>To get you started, I’ve put together a list of 5+ beginner-friendly <a href="https://www.codingnepalweb.com/category/reactjs/">React JS</a> projects. These include practical tools like a currency converter and weather app, as well as fun ones like a hangman game and an AI chatbot. So, let’s jump in!</p><h3>1. Simple Login Form</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qkMMxho_rFfu4TsyinN-QQ.png" /></figure><p>A login form may seem basic, but it’s an excellent starting point for learning how to manage forms and states in React. It’s also a foundational skill for building more complex applications.</p><h4>Key Features:</h4><ul><li>Input fields for email and password.</li><li>A toggle to show or hide the password.</li><li>Buttons for Google and Apple login (no actual authentication).</li></ul><h4>What You’ll Learn:</h4><ul><li>How to create controlled components to handle user input.</li><li>Managing state for form fields using React hooks.</li><li>Implementing a password visibility toggle.</li><li>Styling forms with clean and simple CSS.</li></ul><p><a href="https://www.youtube.com/watch?v=Cz-NebfESNM">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/create-login-form-reactjs-css/">Download Source Code</a></p><h3>2. Currency Converter</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F4_ETjDLEVYRsSMPDBK34w.png" /></figure><p>Building a currency converter is a great way to practice working with APIs and React hooks. Adding a sleek, modern design (like glassmorphism) makes the project visually appealing and a nice portfolio piece.</p><h4>Key Features:</h4><ul><li>Dropdowns to select currencies, complete with flags and codes.</li><li>Input field to enter the amount to convert.</li><li>Displays real-time converted values using an exchange rate API.</li></ul><h4>What You’ll Learn:</h4><ul><li>Fetching and using data from an API.</li><li>Managing component state with useState and useEffect.</li><li>Basic form handling and input validation.</li><li>Applying modern CSS design techniques.</li></ul><p><a href="https://www.youtube.com/watch?v=0_Lwi5ucGwM">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/build-currency-converter-project-reactjs/">Download Source Code</a></p><h3>3. Weather App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E-jKbqB6R_4-qG0AdqX-rQ.png" /></figure><p>A weather app is a practical project that teaches you how to work with external APIs and dynamic content. You’ll get to experiment with geolocation features and asynchronous operations while building something useful.</p><h4>Key Features:</h4><ul><li>Search functionality to find weather by city name.</li><li>Displays current temperature, weather conditions, and other details.</li><li>“Use My Location” button to detect and display local weather.</li><li>Hourly weather forecasts.</li></ul><h4>What You’ll Learn:</h4><ul><li>How to fetch data from APIs like WeatherAPI.</li><li>Handling asynchronous operations with async/await.</li><li>Using the browser’s geolocation API to detect the user’s location.</li><li>Styling dynamic layouts with CSS.</li></ul><p><a href="https://www.youtube.com/watch?v=8KfQL5J701s">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/build-weather-app-reactjs-css/">Download Source Code</a></p><h3>4. YouTube Homepage Clone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dCKsz5JbmrtHotWvQ6LXWw.png" /></figure><p>Recreating the YouTube homepage is a great way to learn how modern web apps are built. It helps you understand responsive design and how to create reusable components in React. Plus, it’s a fun challenge that brings your skills together in a practical project.</p><h4>Key Features:</h4><ul><li>A header with a search bar and navigation icons.</li><li>Sidebar navigation with menu items.</li><li>Grid layout displaying video thumbnails.</li></ul><h4>What You’ll Learn:</h4><ul><li>Breaking a UI into reusable, modular components.</li><li>Creating responsive designs using Flexbox and Grid CSS.</li><li>Mocking data with JSON or static arrays for dynamic rendering.</li><li>Styling with libraries like Tailwind CSS.</li></ul><p><a href="https://www.youtube.com/watch?v=ADhiSLUEQas">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/build-youtube-homepage-clone-html-css/">Download Source Code</a></p><h3>5. Hangman Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eQmzA9zkBRvFgQanJS2pA.jpeg" /></figure><p>This project is a fun mix of logic and creativity. Build an interactive hangman game where players guess letters to complete a word before running out of attempts. Each wrong guess updates the hangman graphic, adding to the challenge and excitement.</p><h4>Key Features:</h4><ul><li>Random word generation for the game.</li><li>Display of remaining attempts and guessed letters.</li><li>Dynamic hangman graphic that updates with incorrect guesses.</li><li>A game-over popup indicating if the player won or lost.</li></ul><h4>What You’ll Learn:</h4><ul><li>Managing game state (e.g., attempts, guessed letters, and word progress).</li><li>Conditional rendering for UI elements like hints and end-of-game messages.</li><li>Using JavaScript arrays for tracking guessed letters and logic.</li></ul><p><a href="https://www.youtube.com/watch?v=hX02ESrxGi0">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/create-hangman-game-reactjs-tailwind/">Download Source Code</a></p><h3>6. AI Chatbot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kIVWgC77CFjf13oZCNgP4w.jpeg" /></figure><p>Challenge yourself by building an AI chatbot! With an API like <a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/">Google Gemini</a>, you can create a chatbot that responds dynamically to user input in real-time. Plus, you can make it even more personalized by customizing it with your own data, so the chatbot responds exactly the way you want.</p><h4>Key Features:</h4><ul><li>Input box for sending messages to the chatbot.</li><li>Dynamic, AI-generated responses are displayed in real-time.</li><li>Loading indicators while waiting for responses.</li><li>Toggleable chatbot popup for easy access.</li></ul><h4>What You’ll Learn:</h4><ul><li>Integrating advanced APIs for AI responses.</li><li>Updating UI in real-time with React state.</li><li>Enhancing user experience with animations and toggles.</li></ul><p><a href="https://www.youtube.com/watch?v=5fiXEGdEK10">Watch Video Tutorial</a> | <a href="https://www.codingnepalweb.com/ai-chatbot-reactjs-css-guide/">Download Source Code</a></p><h3>Conclusion and final words</h3><p>Building these projects isn’t just about learning React - it’s about creating something you can be proud of. Start small with projects like the login form or currency converter to get comfortable, then challenge yourself with more complex ones like the AI chatbot. Each project is a step forward in your journey, helping you build confidence, sharpen your skills, and create a portfolio that stands out</p><p>And if you’d like to level up on your JavaScript skills, don’t miss my guide on <a href="https://www.codingnepalweb.com/best-30-javascript-projects-with-source-code/">Best 30+ JavaScript Projects for Practice (With Source Code)</a>. It’s filled with beginner-friendly to advanced project ideas that are perfect for mastering the fundamentals before diving deeper into React.</p><p>Happy coding, and good luck!</p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/best-reactjs-projects-with-source-code/"><em>https://www.codingnepalweb.com</em></a><em> on January 9, 2025.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26163457a8af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best 30+ JavaScript Projects for Practice (With Source Code)]]></title>
            <link>https://codingnepal.medium.com/best-30-javascript-projects-for-practice-with-source-code-dfeec486e4a0?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfeec486e4a0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript-projects]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Fri, 06 Dec 2024 12:12:31 GMT</pubDate>
            <atom:updated>2025-01-09T18:38:00.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Best 30+ JavaScript Projects for Practice (With Source Code)" src="https://cdn-images-1.medium.com/max/1024/0*SSRLaVY-eCStCpyI.jpg" /><figcaption>Best 30+ JavaScript Projects for Practice (With Source Code)</figcaption></figure><p>JavaScript is one of the most widely used programming languages and an essential skill for modern web developers. Its versatility allows you to create interactive and dynamic web applications and <a href="https://www.codingnepalweb.com/category/website-design/">websites</a>, making it a core technology in web development. Whether you’re just starting out or already have some experience, working on real-world projects is the best way to strengthen your skills and learn new concepts.</p><p>Projects help you practice and give you something tangible to showcase in your portfolio. They are excellent for mastering <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a> fundamentals like DOM manipulation, event handling, and working with APIs. Plus, the satisfaction of seeing your code come to life is a huge motivator!</p><p>In this blog, I’ve collected 30+ exciting JavaScript project ideas, starting with beginner-friendly projects and progressing to intermediate challenges. Many of these projects also include fun <a href="https://www.codingnepalweb.com/category/javascript-games/">games</a> to boost your coding experience while having fun.</p><p>Each project includes a brief description, source code links, and relevant YouTube video tutorials to guide you step-by-step. Whether you want to build a simple calculator or a full-fledged ChatGPT clone app, there’s something here for everyone. Let’s dive in!</p><h3>1. Palindrome Checker</h3><figure><img alt="1. Palindrome Checker" src="https://cdn-images-1.medium.com/max/1024/1*yGeSofmDWMnLFJT_EemFeg.png" /></figure><p>A palindrome checker determines if a word, phrase, or number reads the same forwards and backward, like “level” or “1234321”. This project teaches you to work with JavaScript arrays, strings, and methods like reverse().</p><p>It’s a beginner-friendly project to help you practice string manipulation and logical thinking.</p><ul><li><a href="https://www.youtube.com/watch?v=dLU2wN8P6yY">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/palindrome-checker-html-javascript/">Download Source Code</a></li></ul><h3>2. Rock Paper Scissor</h3><figure><img alt="2. Rock Paper Scissor" src="https://cdn-images-1.medium.com/max/1024/1*fvOFUSQKgijqYe9ptcH3iw.jpeg" /></figure><p>This is a simple game where users play rock, paper, and scissors against a bot. It teaches basic game logic, user input handling, and DOM manipulation. It’s a fun project that helps you practice simple conditional logic and interactive elements.</p><ul><li><a href="https://www.youtube.com/watch?v=RC7NbjwP3QA">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/rock-paper-scissors-game-javascript/">Download Source Code</a></li></ul><h3>3. Random Gradient Color Generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GN5urnG67N4-l1xiPoS4GA.png" /></figure><p>This tool generates random gradient backgrounds that users can refresh with a click. It also allows users to copy the CSS code for any gradient they like. This project will help you understand how to work with random number generation, arrays, and styling in JavaScript.</p><ul><li><a href="https://www.youtube.com/watch?v=H5bpLzBeLww">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/gradient-color-generator-html-javascript/">Download Source Code</a></li></ul><h3>4. Text Typing Animation</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxbYyd9xHpe1iMS_Yq6g_A.png" /></figure><p>Create a typing animation where each letter appears one after the other, simulating a typewriter effect. You’ll use JavaScript, HTML, and CSS to create this animation. It’s a great way to learn about animations, DOM updates, and visual effects.</p><ul><li><a href="https://www.youtube.com/watch?v=DLs1X9T1GcY">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/text-typing-effect-html-css-javascript/">Download Source Code</a></li></ul><h3>5. Analog Clock with Dark/Light Theme</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Itc75VWhl00yARvksPVW-w.jpeg" /></figure><p>Create an analog clock that toggles between dark and light themes. The project involves timekeeping with JavaScript’s Date object and managing CSS for the theme switch. You&#39;ll gain experience with time-based functions and implementing theme toggling.</p><ul><li><a href="https://www.youtube.com/watch?v=WdMeLpD3eTY">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-clock-html-css-javascript/">Download Source Code</a></li></ul><h3>6. Random Color Palette Generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6kwiNTKlJfUdCRQbHjbyng.jpeg" /></figure><p>This app generates random color palettes with one click and displays their hex codes, which users can easily copy. To make this work, you’ll use loops, DOM manipulation, and event handling. It’s a great project for learning how to handle user input and dynamically update the page.</p><ul><li><a href="https://www.youtube.com/watch?v=H-LvaBNLDSQ">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/color-palette-generator-html-css-javascript/">Download Source Code</a></li></ul><h3>7. Calculator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*WdWg-01JqOTfaMbCJjIQ4g.jpeg" /></figure><p>Create a basic calculator that performs addition, subtraction, multiplication, and division. You’ll learn how to handle user input, perform calculations, and manage events. It’s a perfect project for beginners to practice handling inputs and displaying results.</p><ul><li><a href="https://www.youtube.com/watch?v=cHkN82X3KNU">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/calculator-html-css-javascript/">Download Source Code</a></li></ul><h3>8. Random Password Generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZHxqvoCpq-1xyT2M893abQ.png" /></figure><p>A password generator that creates strong, random passwords based on user preferences like length and character types. It also includes a password strength meter. This project helps you practice logic implementation, DOM manipulation, and user input handling.</p><ul><li><a href="https://www.youtube.com/watch?v=fD8gm-DhjXk">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/random-password-generator-html-javascript/">Download Source Code</a></li></ul><h3>9. Random Quotes Generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DSukm-PzmCwWtWhwxiSi2Q.png" /></figure><p>Create an app that fetches random quotes from an API and allows users to generate new quotes, listen to them, and share them on social media. This project is ideal for learning API integration, text-to-speech, and DOM manipulation.</p><ul><li><a href="https://www.youtube.com/watch?v=I0v9ZOY3_0k">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/random-quote-generator-html-javascript/">Download Source Code</a></li></ul><h3>10. Sticky Note App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LNoUikLnKX0h3Do_JKwsyw.png" /></figure><p>A simple app where users can add, edit, and delete sticky notes. Notes are saved in the browser’s local storage, making them persistent across sessions. You’ll learn about CRUD operations and using local storage for data persistence in this project.</p><ul><li><a href="https://www.youtube.com/watch?v=AkIUtUWpyZs">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-a-notes-app-in-html-css-javascript/">Download Source Code</a></li></ul><h3>11. To-Do List App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eh3fA1T4-e1tXXpLsv7ZNQ.png" /></figure><p>Build a To-Do List app where users can add, edit, delete, and filter tasks. You’ll use local storage to save tasks so they persist across page reloads. This project will teach you about CRUD operations and working with data in JavaScript.</p><ul><li><a href="https://www.youtube.com/watch?v=2QIMUBilooc">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/create-todo-list-app-html-javascript/">Download Source Code</a></li></ul><h3>12. Word Scramble Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjyZZyXcD9xy5WJL74Njlw.png" /></figure><p>A word game where users unscramble letters to form a word within a time limit. The project involves using arrays, DOM manipulation, and timers. This project is a fun way to practice string manipulation and event handling.</p><ul><li><a href="https://www.youtube.com/watch?v=4-s3g_fU7Vg">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/word-scramble-game-html-javascript/">Download Source Code</a></li></ul><h3>13. Memory Card Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3D8387gN9IOyzE0hgINZGw.png" /></figure><p>A memory game where users match pairs of cards within a time limit. You’ll practice using arrays, event listeners, and timers while adding game mechanics like time challenges. This project helps you improve your logic and understanding of game functionality.</p><ul><li><a href="https://www.youtube.com/watch?v=DABkhfsBAWw">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-memory-card-game-html-javascript/">Download Source Code</a></li></ul><h3>14. Word Guessing Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*38ciKs0wPkEYaHmSVLDbeg.png" /></figure><p>In this game, users guess the letters of a word within a limited number of attempts. It involves string manipulation and logic to handle guesses and provide hints. This project helps you practice game mechanics, event handling, and string manipulation.</p><ul><li><a href="https://www.youtube.com/watch?v=pN5Bxjte22s">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/word-guessing-game-html-css-javascript/">Download Source Code</a></li></ul><h3>15. Alarm Clock</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2ZNjNnwQQ_rid8Gc70MhA.png" /></figure><p>A simple alarm clock where users can set alarms and see the current time on a digital clock. This project involves using JavaScript’s Date, setInterval, and setTimeout functions. It&#39;s a great way to get hands-on experience with time-based JavaScript functionality.</p><ul><li><a href="https://www.youtube.com/watch?v=GvG_iMXjeUg">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/simple-alarm-clock-html-javascript/">Download Source Code</a></li></ul><h3>16. Tic Tac Toe Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DADVy04q976QfM17MsTKLw.jpeg" /></figure><p>Build a Tic Tac Toe game where players try to get three in a row. You’ll implement game logic, and DOM manipulation, and work with arrays and conditional statements. This project teaches basic game development and logic implementation.</p><ul><li><a href="https://www.youtube.com/watch?v=sNO5awLw9h0">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/tic-tac-toe-game-javascript/">Download Source Code</a></li></ul><h3>17. Virtual Playable Piano</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1x9kDP2CEEvzQJ2sjWbJnw.png" /></figure><p>An interactive piano app where users can play keys by clicking on them or using their keyboard. This project involves DOM manipulation, event handling, and audio control. You’ll gain experience combining multimedia and user interaction to create a fun web app.</p><ul><li><a href="https://www.youtube.com/watch?v=Mv1ZYpo8q4g">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/playable-piano-html-css-javascript/">Download Source Code</a></li></ul><h3>18. Currency Converter App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7CZVtJB-9_bc7-F0quAa1w.png" /></figure><p>This app allows users to convert currency amounts between different currencies. You’ll learn to fetch real-time data using APIs and work with JavaScript objects and arrays. It’s a great way to explore API usage and data handling in JavaScript.</p><ul><li><a href="https://www.youtube.com/watch?v=UY7F37KHyI8">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/currency-converter-app-in-html-javascript/">Download Source Code</a></li></ul><h3>19. Typing Speed Test Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nzl8BbOHX6xaUOUkvh4Wg.png" /></figure><p>Create a game where users have 60 seconds to type as many characters as possible. You’ll track typing speed and accuracy. This project teaches event handling, DOM manipulation, and working with time-based events.</p><ul><li><a href="https://www.youtube.com/watch?v=Hg80AjDNnJk">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/typing-speed-test-game-html-javascript/">Download Source Code</a></li></ul><h3>20. Weather App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Eks_UasikoJk5vaHNrsJA.png" /></figure><p>An advanced weather app that displays real-time weather and 5-day forecasts for any city. You’ll use APIs to fetch data and handle geolocation for user convenience. This project improves your skills in working with APIs and creating dynamic, responsive interfaces.</p><ul><li><a href="https://www.youtube.com/watch?v=SeXg3AX82ig">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/weather-app-project-html-javascript/">Download Source Code</a></li></ul><h3>21. Hangman Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPSbL-Wfv6YxpKblvidVyA.png" /></figure><p>A classic Hangman game where players guess a random word within a limited number of attempts. It uses string manipulation, event handling, and DOM updates to provide a fun user experience. This project is a great way to practice game logic and string handling.</p><ul><li><a href="https://www.youtube.com/watch?v=hSSdc8vKP1I">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-hangman-game-html-javascript/">Download Source Code</a></li></ul><h3>22. Image Editor</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3_k-diMUVgEtcIUZI3Bx_Q.png" /></figure><p>An image editor that allows users to apply filters, adjust brightness, and rotate or flip images. This intermediate project uses HTML5 canvas and JavaScript. You’ll learn how to manipulate images and work with graphical elements in a web application.</p><ul><li><a href="https://www.youtube.com/watch?v=YqUUvBpCtfA">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-image-editor-html-javascript/">Download Source Code</a></li></ul><h3>23. Quiz App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVugrS1Qo3W6bba-qnSFjQ.png" /></figure><p>Create a quiz app where users answer multiple-choice questions within a time limit. You’ll work with arrays, functions, and DOM manipulation. This project is ideal for learning how to manage user input, time events, and quiz-based logic.</p><ul><li><a href="https://www.youtube.com/watch?v=pQr4O1OITJo">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/quiz-app-with-timer-javascript/">Download Source Code</a></li></ul><h3>24. Language Translator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*epMGQwRJjuIgcNfxd4ewXw.png" /></figure><p>A language translation app that converts text into multiple languages and includes text-to-speech and text-copying features. You’ll learn API integration, handling user input, and adding text-to-speech functionality in this project.</p><ul><li><a href="https://www.youtube.com/watch?v=LiLlsGUW4AQ">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/language-translator-app-html-css-javascript/">Download Source Code</a></li></ul><h3>25. Snake Game</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unud8sOGpr2zTo971mxuGA.png" /></figure><p>Build the classic Snake game where players control a snake to eat food while avoiding walls. This project teaches about loops, arrays, game mechanics, and user input handling.<br> It’s a fun way to learn about game development and interactive programming.</p><ul><li><a href="https://www.youtube.com/watch?v=K8Rh5x3c9Pw">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/create-snake-game-htm-css-javascript/">Download Source Code</a></li></ul><h3>26. Drawing App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ln31MGekiO280P8lNshPw.jpeg" /></figure><p>A drawing app where users can draw on a canvas, erase their drawings, and download the image. This project uses the HTML5 canvas and JavaScript to create interactive designs. It’s an excellent way to learn about graphics-based applications and event handling.</p><ul><li><a href="https://www.youtube.com/watch?v=y84tBZo8GFo">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/build-drawing-app-html-canvas-javascript/">Download Source Code</a></li></ul><h3>27. Chatbot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pCCB77UAfKQJipsxOczeQQ.png" /></figure><p>Build a chatbot where users can ask questions and get answers using the Google Gemini API. You’ll work with JavaScript, HTML, and CSS to create a functional and interactive chatbot. This project helps you learn API integration and build responsive user interfaces.</p><ul><li><a href="https://www.youtube.com/watch?v=Bv8FORu-ACA">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/create-chatbot-html-css-javascript/">Download Source Code</a></li></ul><h3>28. Google Gemini Chatbot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tkcOpa_9jn0IUEbwSpQS9g.png" /></figure><p>A more advanced chatbot that allows users to chat, toggle themes, and save chat history in local storage. This project is perfect for learning advanced API integration, local storage, and theme switching.</p><ul><li><a href="https://www.youtube.com/watch?v=31dmameWOR8">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/">Download Source Code</a></li></ul><h3>29. AI Image Generator</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gnh9o2-S0iSaTKEQiJUE0w.jpeg" /></figure><p>Build a website where users input prompts, and an AI generates images based on those prompts. Users can download the generated images. This project helps you understand API integration, AI functionalities, and creating user interfaces that interact with advanced technologies.</p><ul><li><a href="https://www.youtube.com/watch?v=fA_tWwPMapM">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/ai-image-generator-website-html-javascript/">Download Source Code</a></li></ul><h3>30. Image Search Engine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zwqa-EtUaINbNRci_FNX9Q.png" /></figure><p>Build an image search engine that fetches images from an API like Pexels. Users can search for images and view them in a visually appealing layout. This project will teach you about API requests, DOM manipulation, and creating visually rich designs.</p><ul><li><a href="https://www.youtube.com/watch?v=bnANtwr0fTU">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/functional-image-gallery-html-css-javascript/">Download Source Code</a></li></ul><h3>31. ChatGPT Clone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCVz9lt_T8A1bhkFiIZpJA.png" /></figure><p>Create your version of ChatGPT, where users can interact with a chatbot and save the chat history in local storage. This project involves dark/light theme toggling and API integration. It’s a great project for learning about conversational AI, managing chat data, and working with local storage.</p><ul><li><a href="https://www.youtube.com/watch?v=atKtG29iroY">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/create-chatgpt-clone-html-css-javascript/">Download Source Code</a></li></ul><h3>32. AI Chatbot</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4dw7yjomGVsPEliVB10KxQ.jpeg" /></figure><p>Create an AI-powered chatbot using the Google Gemini API, where users can upload images, use emojis, and get responses. It’s fully responsive and interactive. This project will improve your skills in integrating AI APIs, building responsive layouts, and handling media inputs.</p><ul><li><a href="https://www.youtube.com/watch?v=B21G6tUI4L0">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/ai-chatbot-html-css-javascript/">Download Source Code</a></li></ul><h3>33. Chrome Extension</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*phAIYtV2jzlQp8M8cvQZFA.png" /></figure><p>Create a Chrome extension like a color picker, where users can pick colors from a webpage and view a color history. This project is a great way to learn how Chrome extensions work using HTML, CSS, and JavaScript.</p><ul><li><a href="https://www.youtube.com/watch?v=coj-l7IrwGU">Watch Video Tutorial</a></li><li><a href="https://www.codingnepalweb.com/create-chrome-extension-html-css-javascript/">Download Source Code</a></li></ul><h3>Conclusion and final words</h3><p>In conclusion, these 30+ JavaScript projects offer a great opportunity for developers to sharpen their skills, from beginners to advanced programmers. Whether you’re just starting with basic concepts like arrays and DOM manipulation, or you’re diving into more complex tasks involving <a href="https://www.codingnepalweb.com/category/api-projects/">APIs</a>, AI integration, and responsive design, there’s something for everyone.</p><p>By building these projects, you not only gain hands-on experience but also develop a deeper understanding of <a href="https://www.codingnepalweb.com/category/javascript-projects/">JavaScript</a> and web development. So, pick a project that suits your current skill level and start building — it’s the best way to learn and grow as a developer!</p><p>Thank you for reading! If you found this project list helpful, please share it with others, and feel free to comment down below with your thoughts or any questions. I’d love to hear how these projects work out for you!</p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/best-30-javascript-projects-with-source-code/"><em>https://www.codingnepalweb.com</em></a><em> on December 6, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfeec486e4a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Card Slider in HTML CSS & JavaScript | Step-by-Step Guide]]></title>
            <link>https://codingnepal.medium.com/how-to-create-card-slider-in-html-css-javascript-step-by-step-guide-ad615e48d824?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad615e48d824</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 12:29:39 GMT</pubDate>
            <atom:updated>2024-09-05T17:45:51.417Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wWpSRY-d4ifDuIX_.jpg" /><figcaption>How to Create Card Slider in HTML CSS &amp; JavaScript | Step-by-Step Guide</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/create-card-slider-in-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Sliders are a great way to showcase products, testimonials, or important content on a website. They add a dynamic, engaging, and user-friendly look to a site. If you’re a beginner web developer, have you considered creating one and integrating it into your project?</p><p>In this blog post, I’ll guide you through creating a Responsive Card Slider using <a href="https://www.codingnepalweb.com/category/html-and-css/">HTML, CSS</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a>. This slider allows users to navigate the cards using buttons or pagination bullets. We’ll use SwiperJS, a popular and easy-to-use slider library that will make your slider modern, touch-friendly, and work seamlessly across all devices and browsers.</p><p>If you prefer to create a slider without using an external library like SwiperJS, check out my other blog post where I guide you through creating a <a href="https://www.codingnepalweb.com/category/image-slider/">custom slider</a> from scratch.</p><p>By the end of this guide, you’ll have a fully functional card slider that boosts your coding skills and adds a polished feature to your site. Whether you’re adding it to your portfolio or experimenting with slider functionality, this project is a valuable step in your web development journey.</p><h3>Video Tutorial of Responsive Card Slider in HTML CSS &amp; JavaScript</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVUtJ7FWCfZA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVUtJ7FWCfZA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVUtJ7FWCfZA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6bad31e73bab65e66b43c980b328a94/href">https://medium.com/media/e6bad31e73bab65e66b43c980b328a94/href</a></iframe><p>The YouTube video above is a great resource if you prefer video tutorials. It explains each line of code and provides comments, making it easy to follow along with your <a href="https://www.codingnepalweb.com/create-responsive-card-slider-html-javascript/">card slider</a> project. If you like reading or need a step-by-step guide, keep following this post.</p><h3>Steps to Create Card Slider HTML CSS &amp; JavaScript</h3><p>To create a responsive and interactive card slider using HTML, CSS, and JavaScript, follow these simple step-by-step instructions:</p><ul><li>Create a folder with any name you like, e.g., card-slider.</li><li>Inside it, create the necessary files: index.html, style.css, and script.js.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/card-slider-images-2024-08-24.zip">Images</a> folder and put it in your project directory. This folder contains images used on this card slider.</li></ul><p>In your index.html file: Add the essential HTML markup along with SwiperJS CDN links to set up the card slider layout.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;!-- Coding By CodingNepal - www.codingnepalweb.com --&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;Card Slider HTML &amp; CSS | CodingNepal&lt;/title&gt;<br>  &lt;!-- Linking Google fonts for icons --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0&quot; /&gt;<br>  &lt;!-- Linking SwiperJS CSS --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div class=&quot;container swiper&quot;&gt;<br>    &lt;div class=&quot;card-wrapper&quot;&gt;<br>      &lt;!-- Card slides container --&gt;<br>      &lt;ul class=&quot;card-list swiper-wrapper&quot;&gt;<br>        &lt;li class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;<br>            &lt;img src=&quot;images/designer.jpg&quot; alt=&quot;Card Image&quot; class=&quot;card-image&quot;&gt;<br>            &lt;p class=&quot;badge badge-designer&quot;&gt;Designer&lt;/p&gt;<br>            &lt;h2 class=&quot;card-title&quot;&gt;Lorem ipsum dolor sit explicabo adipisicing elit&lt;/h2&gt;<br>            &lt;button class=&quot;card-button material-symbols-rounded&quot;&gt;arrow_forward&lt;/button&gt;<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>        &lt;li class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;<br>            &lt;img src=&quot;images/developer.jpg&quot; alt=&quot;Card Image&quot; class=&quot;card-image&quot;&gt;<br>            &lt;p class=&quot;badge badge-developer&quot;&gt;Developer&lt;/p&gt;<br>            &lt;h2 class=&quot;card-title&quot;&gt;Lorem ipsum dolor sit explicabo adipisicing elit&lt;/h2&gt;<br>            &lt;button class=&quot;card-button material-symbols-rounded&quot;&gt;arrow_forward&lt;/button&gt;<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>        &lt;li class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;<br>            &lt;img src=&quot;images/marketer.jpg&quot; alt=&quot;Card Image&quot; class=&quot;card-image&quot;&gt;<br>            &lt;p class=&quot;badge badge-marketer&quot;&gt;Marketer&lt;/p&gt;<br>            &lt;h2 class=&quot;card-title&quot;&gt;Lorem ipsum dolor sit explicabo adipisicing elit&lt;/h2&gt;<br>            &lt;button class=&quot;card-button material-symbols-rounded&quot;&gt;arrow_forward&lt;/button&gt;<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>        &lt;li class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;<br>            &lt;img src=&quot;images/gamer.jpg&quot; alt=&quot;Card Image&quot; class=&quot;card-image&quot;&gt;<br>            &lt;p class=&quot;badge badge-gamer&quot;&gt;Gamer&lt;/p&gt;<br>            &lt;h2 class=&quot;card-title&quot;&gt;Lorem ipsum dolor sit explicabo adipisicing elit&lt;/h2&gt;<br>            &lt;button class=&quot;card-button material-symbols-rounded&quot;&gt;arrow_forward&lt;/button&gt;<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>        &lt;li class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;card-link&quot;&gt;<br>            &lt;img src=&quot;images/editor.jpg&quot; alt=&quot;Card Image&quot; class=&quot;card-image&quot;&gt;<br>            &lt;p class=&quot;badge badge-editor&quot;&gt;Editor&lt;/p&gt;<br>            &lt;h2 class=&quot;card-title&quot;&gt;Lorem ipsum dolor sit explicabo adipisicing elit&lt;/h2&gt;<br>            &lt;button class=&quot;card-button material-symbols-rounded&quot;&gt;arrow_forward&lt;/button&gt;<br>          &lt;/a&gt;<br>        &lt;/li&gt;<br>      &lt;/ul&gt;<br><br>       &lt;!-- Pagination --&gt;<br>      &lt;div class=&quot;swiper-pagination&quot;&gt;&lt;/div&gt;<br><br>      &lt;!-- Navigation Buttons --&gt;<br>      &lt;div class=&quot;swiper-slide-button swiper-button-prev&quot;&gt;&lt;/div&gt;<br>      &lt;div class=&quot;swiper-slide-button swiper-button-next&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br><br>  &lt;!-- Linking SwiperJS script --&gt;<br>  &lt;script src=&quot;https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js&quot;&gt;&lt;/script&gt;<br><br>  &lt;!-- Linking custom script --&gt;<br>  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In your style.css file: Style your card slider to make it responsive and visually appealing. Experiment with colors, fonts, and backgrounds to enhance the design.</p><pre>/* Importing Google fonts - Inter */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Inter&quot;, sans-serif;<br>}<br><br>body {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  min-height: 100vh;<br>  background: linear-gradient(#ECEFFE, #C5CFFC);<br>}<br><br>.card-wrapper {<br>  max-width: 1100px;<br>  margin: 0 60px 35px;<br>  padding: 20px 10px;<br>  overflow: hidden;<br>}<br><br>.card-list .card-item {<br>  list-style: none;<br>}<br><br>.card-list .card-item .card-link {<br>  display: block;<br>  background: #fff;<br>  padding: 18px;<br>  user-select: none;<br>  border-radius: 12px;<br>  text-decoration: none;<br>  border: 2px solid transparent;<br>  box-shadow: 0 10px 10px rgba(0, 0, 0, 0.05);<br>  transition: 0.2s ease;<br>}<br><br>.card-list .card-item .card-link:active {<br>  cursor: grabbing;<br>}<br><br>.card-list .card-item .card-link:hover {<br>  border-color: #5372F0;<br>}<br><br>.card-list .card-link .card-image {<br>  width: 100%;<br>  border-radius: 10px;<br>  aspect-ratio: 16 / 9;<br>  object-fit: cover;<br>}<br><br>.card-list .card-link .badge {<br>  color: #5372F0;<br>  width: fit-content;<br>  padding: 8px 16px;<br>  font-size: 0.95rem;<br>  border-radius: 50px;<br>  font-weight: 500;<br>  background: #DDE4FF;<br>  margin: 16px 0 18px;<br>}<br><br>.card-list .card-link .badge-designer {<br>  color: #B22485;<br>  background: #F7DFF5;<br>}<br><br>.card-list .card-link .badge-marketer {<br>  color: #B25A2B;<br>  background: #FFE3D2;<br>}<br><br>.card-list .card-link .badge-gamer {<br>  color: #205C20;<br>  background: #D6F8D6;<br>}<br><br>.card-list .card-link .badge-editor {<br>  color: #856404;<br>  background: #fff3cd;<br>}<br><br>.card-list .card-link .card-title {<br>  color: #000;<br>  font-size: 1.19rem;<br>  font-weight: 600;<br>}<br><br>.card-list .card-link .card-button {<br>  height: 35px;<br>  width: 35px;<br>  color: #5372F0;<br>  margin: 30px 0 5px;<br>  background: none;<br>  cursor: pointer;<br>  border-radius: 50%;<br>  border: 2px solid #5372F0;<br>  transform: rotate(-45deg);<br>  transition: 0.4s ease;<br>}<br><br>.card-list .card-link:hover .card-button {<br>  color: #fff;<br>  background: #5372F0;<br>}<br><br>.card-wrapper .swiper-pagination-bullet {<br>  height: 13px;<br>  width: 13px;<br>  opacity: 0.5;<br>  background: #5372F0;<br>}<br><br>.card-wrapper .swiper-pagination-bullet-active {<br>  opacity: 1;<br>}<br><br>.card-wrapper .swiper-slide-button {<br>  color: #5372F0;<br>  margin-top: -35px;<br>}<br><br>/* Responsive media query code for small screens */<br>@media (max-width: 768px) {<br>  .card-wrapper {<br>    margin: 0 10px 25px;<br>  }<br><br>  .card-wrapper .swiper-slide-button {<br>    display: none;<br>  }<br>}</pre><p>In your script.js file: Initialize SwiperJS with JavaScript code to make the card slider functional. Configure various Swiper methods to control the slider&#39;s behavior, including navigation, pagination, and autoplay.</p><pre>new Swiper(&#39;.card-wrapper&#39;, {<br>    loop: true,<br>    spaceBetween: 30,<br><br>    // Pagination bullets<br>    pagination: {<br>        el: &#39;.swiper-pagination&#39;,<br>        clickable: true,<br>        dynamicBullets: true<br>    },<br><br>    // Navigation arrows<br>    navigation: {<br>        nextEl: &#39;.swiper-button-next&#39;,<br>        prevEl: &#39;.swiper-button-prev&#39;,<br>    },<br><br>    // Responsive breakpoints<br>    breakpoints: {<br>        0: {<br>            slidesPerView: 1<br>        },<br>        768: {<br>            slidesPerView: 2<br>        },<br>        1024: {<br>            slidesPerView: 3<br>        }<br>    }<br>});</pre><p>That’s it! If you’ve added the code correctly, you’re ready to see your card slider. Open the index.html file in your preferred browser to view the project in action.</p><h3>Conclusion and final words</h3><p>By following this guide, you will successfully create a responsive and interactive card slider that enhances your <a href="https://www.codingnepalweb.com/category/website-design/">website</a> ‘s functionality and visual appeal. Whether you choose to use SwiperJS for its ease and advanced features or decide to build a custom slider from scratch, you will gain valuable skills and insight into slider development.</p><p>Feel free to customize the slider and experiment with different settings to make it your own. For more customization details, you can check out the <a href="https://swiperjs.com/get-started">SwiperJS</a> documentation.</p><p>If you encounter any problems while creating your slider, you can download the source code files for this project for free by clicking the “Download” button. You can also view a live demo of it by clicking the “View Live” button.</p><p><a href="https://www.codingnepalweb.com/demos/create-card-slider-in-html-css-javascript/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/create-card-slider-in-html-css-javascript/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/create-card-slider-in-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em> on September 3, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad615e48d824" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[⛅ Build A Weather App in HTML CSS and JavaScript]]></title>
            <link>https://codingnepal.medium.com/build-a-weather-app-in-html-css-and-javascript-a4cac8171a75?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4cac8171a75</guid>
            <category><![CDATA[weather-apps]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[weather-api]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 14:10:23 GMT</pubDate>
            <atom:updated>2024-09-03T12:34:09.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V2s6_A1Eu6q-VZEA.jpg" /><figcaption>Build A Weather App in HTML CSS and JavaScript</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/build-weather-app-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Building a <a href="https://www.codingnepalweb.com/weather-app-project-html-javascript/">weather app</a> is an excellent project for beginner web developers. It helps to strengthen your fundamental skills while introducing you to the practical use of APIs in JavaScript. You’ll gain hands-on experience in fetching and displaying data from external sources. These skills are essential for developing real-world applications.</p><p>In this blog post, I’ll guide you through building a beautiful and interactive weather app using <a href="https://www.codingnepalweb.com/category/html-and-css/">HTML, CSS</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a>. This app allows users to check the weather for any city or use their current location to get the weather forecast. The app will feature real-time weather updates and forecasts for 24 hours.</p><p>By the end of this guide, you’ll have a fully functional weather app that not only enhances your coding skills but also provides a practical tool you can use and showcase. Whether you’re adding it to your portfolio or just experimenting with new techniques, this project is a valuable step in your web development journey.</p><h3>Video Tutorial of Weather App in HTML &amp; JavaScript</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F5e090aVUKro%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D5e090aVUKro&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F5e090aVUKro%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7e27aeb1312de2f0e9610f584dd17895/href">https://medium.com/media/7e27aeb1312de2f0e9610f584dd17895/href</a></iframe><p>The YouTube video above is a great resource if you prefer video tutorials. It explains each line of code and provides comments, making it easy to follow along with your weather app project. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Steps to Build Weather App in HTML &amp; JavaScript</h3><p>To build a functional weather app using HTML, CSS, and JavaScript, follow these simple step-by-step instructions:</p><ul><li>Create a folder with any name you like, e.g., weather-app.</li><li>Inside it, create the necessary files: index.html, style.css, and script.js.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/weather-app-javascript-2024-08-10.zip">Icons</a> folder and put it in your project directory. This folder contains necessary icons for weather conditions.</li></ul><p>In your index.html file, add the essential HTML markup to structure your Weather app layout. This includes a search input for city names, a location button, and sections to display the current weather and hourly forecast, all structured with semantic tags.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;!-- Coding By CodingNepal - youtube.com/@codingnepal --&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;Weather App | CodingNepal&lt;/title&gt;<br>  &lt;!-- Linking Google fonts for icons --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0&quot; /&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;!-- Search section --&gt;<br>    &lt;div class=&quot;search-section&quot;&gt;<br>      &lt;div class=&quot;input-wrapper&quot;&gt;<br>        &lt;span class=&quot;material-symbols-rounded&quot;&gt;search&lt;/span&gt;<br>        &lt;input type=&quot;search&quot; placeholder=&quot;Enter a city name&quot; class=&quot;search-input&quot;&gt;<br>      &lt;/div&gt;<br>      &lt;button class=&quot;location-button&quot;&gt;<br>        &lt;span class=&quot;material-symbols-rounded&quot;&gt;my_location&lt;/span&gt;<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br><br>    &lt;!-- No results message --&gt;<br>    &lt;div class=&quot;no-results&quot;&gt;<br>      &lt;img src=&quot;icons/no-result.svg&quot; alt=&quot;No results found&quot; class=&quot;icon&quot;&gt;<br>      &lt;h3 class=&quot;title&quot;&gt;Something went wrong!&lt;/h3&gt;<br>      &lt;p class=&quot;message&quot;&gt;We&#39;re unable to retrieve the weather details. Enure you&#39;ve entered a valid city or try again later.&lt;/p&gt;<br>    &lt;/div&gt;<br><br>    &lt;!-- Container for displaying weather data --&gt;<br>    &lt;div class=&quot;weather-section&quot;&gt;<br>      &lt;div class=&quot;current-weather&quot;&gt;<br>        &lt;img src=&quot;icons/no-result.svg&quot; class=&quot;weather-icon&quot;&gt;<br>        &lt;h2 class=&quot;temperature&quot;&gt;00&lt;span&gt;°C&lt;/span&gt;&lt;/h2&gt;<br>        &lt;h5 class=&quot;description&quot;&gt;Weather description&lt;/h5&gt;<br>      &lt;/div&gt;<br><br>      &lt;!-- Hourly weather forecast list --&gt;<br>      &lt;div class=&quot;hourly-weather&quot;&gt;<br>        &lt;ul class=&quot;weather-list&quot;&gt;&lt;/ul&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br><br>  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In your style.css file, add CSS code to style your weather app, and give it a responsive and visually appealing design. Play with different colors, fonts, and backgrounds to make the interface user-friendly and attractive.</p><pre>/* Importing Google Fonts - Montserrat */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Montserrat&quot;, sans-serif;<br>}<br><br>body {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  min-height: 100vh;<br>  background: #5f41e4;<br>}<br><br>.container {<br>  flex-grow: 1;<br>  overflow: hidden;<br>  max-width: 425px;<br>  border-radius: 10px;<br>  position: relative;<br>  background: #fff;<br>  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);<br>}<br><br>.search-section {<br>  display: flex;<br>  gap: 10px;<br>  padding: 25px;<br>  align-items: center;<br>}<br><br>.search-section .input-wrapper {<br>  height: 54px;<br>  width: 100%;<br>  position: relative;<br>}<br><br>.search-section .input-wrapper span {<br>  position: absolute;<br>  top: 50%;<br>  left: 17px;<br>  pointer-events: none;<br>  transform: translateY(-50%);<br>}<br><br>.search-section .search-input {<br>  height: 100%;<br>  width: 100%;<br>  outline: none;<br>  font-size: 1rem;<br>  font-weight: 500;<br>  border-radius: 6px;<br>  text-transform: uppercase;<br>  padding: 0 20px 0 50px;<br>  border: 1px solid #beb0ff;<br>  background: #fff;<br>  transition: 0.1s ease;<br>}<br><br>.search-section .search-input:focus {<br>  border-color: #5f41e4;<br>  box-shadow: 0 0 5px rgba(0, 0, 0, 0.14);<br>}<br><br>.search-section .search-input::placeholder {<br>  text-transform: none;<br>}<br><br>.search-section .location-button {<br>  height: 54px;<br>  width: 56px;<br>  cursor: pointer;<br>  flex-shrink: 0;<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  border-radius: 5px;<br>  background: #fff;<br>  color: #5f41e4;<br>  border: 1px solid #beb0ff;<br>  transition: 0.3s ease;<br>}<br><br>.search-section .location-button:hover {<br>  color: #fff;<br>  background: #5f41e4;<br>  border-color: #5f41e4;<br>}<br><br>.search-section .location-button span {<br>  font-size: 1.3rem;<br>}<br><br>.no-results {<br>  position: absolute;<br>  left: 50%;<br>  top: 50%;<br>  width: 100%;<br>  display: none;<br>  padding: 40px;<br>  text-align: center;<br>  align-items: center;<br>  flex-direction: column;<br>  transform: translate(-50%, -50%);<br>  transition: 0.2s ease;<br>}<br><br>body.show-no-results .no-results {<br>  display: flex;<br>}<br><br>.no-results .title {<br>  font-weight: 700;<br>  margin: 25px 0 15px;<br>}<br><br>.no-results .message {<br>  font-weight: 500;<br>  line-height: 23px;<br>}<br><br>body.show-no-results .weather-section {<br>  visibility: hidden;<br>}<br><br>.weather-section .current-weather {<br>  display: flex;<br>  padding: 20px 0 50px;<br>  flex-direction: column;<br>  align-items: center;<br>}<br><br>.current-weather .weather-icon {<br>  width: 140px;<br>  aspect-ratio: 1;<br>}<br><br>.current-weather .temperature {<br>  font-size: 3.38rem;<br>  margin: 23px 0;<br>  display: flex;<br>}<br><br>.current-weather .temperature span {<br>  font-size: 1.56rem;<br>  font-weight: 500;<br>  margin: 5px 0 0 2px;<br>}<br><br>.current-weather .description {<br>  font-weight: 500;<br>  font-size: 1.25rem;<br>}<br><br>.hourly-weather {<br>  padding: 16px 25px;<br>  border-top: 1px solid #d5ccff;<br>}<br><br>.hourly-weather .weather-list {<br>  display: flex;<br>  gap: 41px;<br>  overflow-x: auto;<br>  padding-bottom: 16px;<br>  margin-bottom: -16px;<br>  scrollbar-width: thin;<br>  scrollbar-color: transparent transparent;<br>}<br><br>.hourly-weather:hover .weather-list {<br>  scrollbar-color: #bfbfbf transparent;<br>}<br><br>.hourly-weather .weather-list .weather-item {<br>  display: flex;<br>  gap: 7px;<br>  width: 60px;<br>  font-weight: 500;<br>  flex-direction: column;<br>  align-items: center;<br>}<br><br>.hourly-weather .weather-item .weather-icon {<br>  width: 28px;<br>  aspect-ratio: 1;<br>}<br><br>/* Responsive media query code for small screen */<br>@media (max-width: 624px) {<br>  body {<br>    padding: 15px;<br>  }<br><br>  .search-section {<br>    padding: 20px;<br>  }<br><br>  .no-results {<br>    padding: 30px;<br>  }<br><br>  .hourly-weather {<br>    padding: 16px 20px;<br>  }<br><br>  .hourly-weather .weather-list {<br>    gap: 32px;<br>  }<br>}</pre><p>In your script.js file, add JavaScript code to make your weather app interactive and functional. This code will fetch the current weather and hourly forecast from an external API, then dynamically update the DOM to display the data in real-time.</p><pre>const searchInput = document.querySelector(&quot;.search-input&quot;);<br>const locationButton = document.querySelector(&quot;.location-button&quot;);<br>const currentWeatherDiv = document.querySelector(&quot;.current-weather&quot;);<br>const hourlyWeather = document.querySelector(&quot;.hourly-weather .weather-list&quot;);<br><br>const API_KEY = &quot;YOUR-API-KEY-HERE&quot;; // API key<br><br>// Weather codes for mapping to custom icons<br>const weatherCodes = {<br>  clear: [1000],<br>  clouds: [1003, 1006, 1009],<br>  mist: [1030, 1135, 1147],<br>  rain: [1063, 1150, 1153, 1168, 1171, 1180, 1183, 1198, 1201, 1240, 1243, 1246, 1273, 1276],<br>  moderate_heavy_rain: [1186, 1189, 1192, 1195, 1243, 1246],<br>  snow: [1066, 1069, 1072, 1114, 1117, 1204, 1207, 1210, 1213, 1216, 1219, 1222, 1225, 1237, 1249, 1252, 1255, 1258, 1261, 1264, 1279, 1282],<br>  thunder: [1087, 1279, 1282],<br>  thunder_rain: [1273, 1276],<br>}<br><br>// Display the hourly forecast for the next 24 hours<br>const displayHourlyForecast = (hourlyData) =&gt; {<br>  const currentHour = new Date().setMinutes(0, 0, 0);<br>  const next24Hours = currentHour + 24 * 60 * 60 * 1000;<br><br>  // Filter the hourly data to only include the next 24 hours<br>  const next24HoursData = hourlyData.filter(({ time }) =&gt; {<br>    const forecastTime = new Date(time).getTime();<br>    return forecastTime &gt;= currentHour &amp;&amp; forecastTime &lt;= next24Hours;<br>  });<br><br>  // Generate HTML for each hourly forecast and display it<br>  hourlyWeather.innerHTML = next24HoursData.map((item) =&gt; {<br>    const temperature = Math.floor(item.temp_c);<br>    const time = item.time.split(&#39; &#39;)[1].substring(0, 5);<br>    const weatherIcon = Object.keys(weatherCodes).find(icon =&gt; weatherCodes[icon].includes(item.condition.code));<br><br>    return `&lt;li class=&quot;weather-item&quot;&gt;<br>            &lt;p class=&quot;time&quot;&gt;${time}&lt;/p&gt;<br>            &lt;img src=&quot;icons/${weatherIcon}.svg&quot; class=&quot;weather-icon&quot;&gt;<br>            &lt;p class=&quot;temperature&quot;&gt;${temperature}°&lt;/p&gt;<br>          &lt;/li&gt;`;<br>  }).join(&#39;&#39;);<br>};<br><br>// Fetch and display weather details<br>const getWeatherDetails = async (API_URL) =&gt; {<br>  window.innerWidth &lt;= 768 &amp;&amp; searchInput.blur();<br>  document.body.classList.remove(&quot;show-no-results&quot;);<br><br>  try {<br>    // Fetch weather data from the API and parse the response as JSON<br>    const response = await fetch(API_URL);<br>    const data = await response.json();<br><br>    // Extract current weather details<br>    const temperature = Math.floor(data.current.temp_c);<br>    const description = data.current.condition.text;<br>    const weatherIcon = Object.keys(weatherCodes).find(icon =&gt; weatherCodes[icon].includes(data.current.condition.code));<br><br>    // Update the current weather display<br>    currentWeatherDiv.querySelector(&quot;.weather-icon&quot;).src = `icons/${weatherIcon}.svg`;<br>    currentWeatherDiv.querySelector(&quot;.temperature&quot;).innerHTML = `${temperature}&lt;span&gt;°C&lt;/span&gt;`;<br>    currentWeatherDiv.querySelector(&quot;.description&quot;).innerText = description;<br><br>    // Combine hourly data from today and tomorrow<br>    const combinedHourlyData = [...data.forecast?.forecastday[0]?.hour, ...data.forecast?.forecastday[1]?.hour];<br><br>    searchInput.value = data.location.name;<br>    displayHourlyForecast(combinedHourlyData);<br>  } catch (error) {<br>    document.body.classList.add(&quot;show-no-results&quot;);<br>  }<br>}<br><br>// Set up the weather request for a specific city<br>const setupWeatherRequest = (cityName) =&gt; {<br>  const API_URL = `https://api.weatherapi.com/v1/forecast.json?key=${API_KEY}&amp;q=${cityName}&amp;days=2`;<br>  getWeatherDetails(API_URL);<br>}<br><br>// Handle user input in the search box<br>searchInput.addEventListener(&quot;keyup&quot;, (e) =&gt; {<br>  const cityName = searchInput.value.trim();<br><br>  if (e.key == &quot;Enter&quot; &amp;&amp; cityName) {<br>    setupWeatherRequest(cityName);<br>  }<br>});<br><br>// Get user&#39;s coordinates and fetch weather data for the current location<br>locationButton.addEventListener(&quot;click&quot;, () =&gt; {<br>  navigator.geolocation.getCurrentPosition(<br>    (position) =&gt; {<br>      const { latitude, longitude } = position.coords;<br>      const API_URL = `https://api.weatherapi.com/v1/forecast.json?key=${API_KEY}&amp;q=${latitude},${longitude}&amp;days=2`;<br>      getWeatherDetails(API_URL);<br>      window.innerWidth &gt;= 768 &amp;&amp; searchInput.focus();<br>    },<br>    () =&gt; {<br>      alert(&quot;Location access denied. Please enable permissions to use this feature.&quot;);<br>    }<br>  );<br>});<br><br>// Initial weather request for London as the default city<br>setupWeatherRequest(&quot;London&quot;);</pre><p><strong>Important:</strong> Your weather app won’t function until you connect it with a weather API. Sign up for a free API key from <a href="https://www.weatherapi.com/my/">WeatherAPI</a> and add it to the API_KEY variable in your script.js file. This key enables your app to retrieve real-time and hourly forecasts. The key will be something like this: <em>5f2b6b5a24044bcdbbc103609241008</em>.</p><p>Once the API key is added to the code, the weather app is ready to use. Open the index.html file in your browser and enter a city name or use your location to check the weather.</p><h3>Conclusion and final words</h3><p>In conclusion, building a <a href="https://www.codingnepalweb.com/build-weather-app-html-javascript/">weather app</a> with HTML, CSS, and JavaScript is a great way for beginners to enhance their core web development skills and gain valuable experience with APIs. By following this guide, you’ve created a functional and visually appealing weather app that’s a perfect addition to your portfolio.</p><p>To further improve your skills, you can check out other related JavaScript projects such as the <a href="https://www.codingnepalweb.com/currency-converter-app-in-html-javascript/">Currency Converter</a>, <a href="https://www.codingnepalweb.com/functional-image-gallery-html-css-javascript/">Image Search Engine</a>, <a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/">Gemini Chatbot</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">many more</a>. Each of these projects is created to enhance your understanding of HTML and CSS, while also giving you hands-on experience with better styling techniques and API integrations.</p><p>If you encounter any problems while building your weather app, you can download the source code files for this project by clicking the “Download” button.</p><p><a href="https://www.codingnepalweb.com/build-weather-app-html-css-javascript/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/build-weather-app-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em> on August 15, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4cac8171a75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build A Google Gemini Chatbot with HTML CSS and JavaScript]]></title>
            <link>https://codingnepal.medium.com/build-a-google-gemini-chatbot-with-html-css-and-javascript-855e03de8c27?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/855e03de8c27</guid>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Wed, 31 Jul 2024 08:07:21 GMT</pubDate>
            <atom:updated>2024-09-03T12:34:24.748Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*C_wyprfQIoHaZ32H.jpg" /><figcaption>Build A Google Gemini Chatbot with HTML CSS and JavaScript</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>AI chatbots like Google Gemini or <a href="https://www.codingnepalweb.com/create-chatgpt-clone-html-css-javascript/">ChatGPT</a> have changed how we interact with technology, making conversations with machines almost human. As a beginner web developer, have you ever thought about building your own AI chatbot? The good news is that it is possible to build a Google Gemini-like chatbot using HTML, CSS, and JavaScript.</p><p>For those who aren’t familiar, Gemini is an advanced <a href="https://www.codingnepalweb.com/create-chatbot-html-css-javascript/">chatbot</a> model developed by Google, similar to ChatGPT. It uses artificial intelligence to produce human-like responses and has become popular for its natural conversational abilities.</p><p>In this blog post, I’ll guide you through building a Google Gemini Chatbot in <a href="https://www.codingnepalweb.com/category/html-and-css/">HTML, CSS</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a>. With this chatbot, users will be able to chat, copy responses, and toggle between light and dark themes. Additionally, the themes and chat history will be saved in the browser’s local storage, ensuring they persist even after a page refresh.</p><h3>Video Tutorial to Build Gemini Chatbot in HTML CSS &amp; JavaScript</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F31dmameWOR8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D31dmameWOR8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F31dmameWOR8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a3a098a33b266982ef64049c1999281/href">https://medium.com/media/4a3a098a33b266982ef64049c1999281/href</a></iframe><p>The YouTube video above is a great resource if you prefer video tutorials. It explains each line of code and provides comments, making it easy to follow along with your Gemini chatbot clone project. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Steps to Build Gemini Chatbot in HTML &amp; JavaScript</h3><p>To build an interactive and functional Gemini chatbot using HTML, CSS, and JavaScript, follow these simple step-by-step instructions:</p><ul><li>Create a folder with any name you like, e.g., gemini-chatbot.</li><li>Inside it, create the necessary files: index.html, style.css, and script.js.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/gemini-clone-html-css-javascript-images.zip">Images</a> folder and put it in your project directory. This folder contains logos you’ll need for this chatbot project.</li></ul><p>In your index.html file, add the essential HTML markup to structure your Gemini chat layout. It features a greetings header, suggestion list, chat section, and typing form, all structured with semantic tags.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;!-- Coding By CodingNepal - www.codingnepalweb.com --&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;Gemini Chatbot | CodingNepal&lt;/title&gt;<br>  &lt;!-- Linking Google Fonts For Icons --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@24,400,0,0&quot; /&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;header class=&quot;header&quot;&gt;<br>    &lt;!-- Header Greetings --&gt;<br>    &lt;h1 class=&quot;title&quot;&gt;Hello, there&lt;/h1&gt;<br>    &lt;p class=&quot;subtitle&quot;&gt;How can I help you today?&lt;/p&gt;<br><br>    &lt;!-- Suggestion list --&gt;<br>    &lt;ul class=&quot;suggestion-list&quot;&gt;<br>      &lt;li class=&quot;suggestion&quot;&gt;<br>        &lt;h4 class=&quot;text&quot;&gt;Help me plan a game night with my 5 best friends for under $100.&lt;/h4&gt;<br>        &lt;span class=&quot;icon material-symbols-rounded&quot;&gt;draw&lt;/span&gt;<br>      &lt;/li&gt;<br>      &lt;li class=&quot;suggestion&quot;&gt;<br>        &lt;h4 class=&quot;text&quot;&gt;What are the best tips to improve my public speaking skills?&lt;/h4&gt;<br>        &lt;span class=&quot;icon material-symbols-rounded&quot;&gt;lightbulb&lt;/span&gt;<br>      &lt;/li&gt;<br>      &lt;li class=&quot;suggestion&quot;&gt;<br>        &lt;h4 class=&quot;text&quot;&gt;Can you help me find the latest news on web development?&lt;/h4&gt;<br>        &lt;span class=&quot;icon material-symbols-rounded&quot;&gt;explore&lt;/span&gt;<br>      &lt;/li&gt;<br>      &lt;li class=&quot;suggestion&quot;&gt;<br>        &lt;h4 class=&quot;text&quot;&gt;Write JavaScript code to sum all elements in an array.&lt;/h4&gt;<br>        &lt;span class=&quot;icon material-symbols-rounded&quot;&gt;code&lt;/span&gt;<br>      &lt;/li&gt;<br>    &lt;/ul&gt;<br>  &lt;/header&gt;<br><br>  &lt;!-- Chat List / Container --&gt;<br>  &lt;div class=&quot;chat-list&quot;&gt;&lt;/div&gt;<br><br>  &lt;!-- Typing Area --&gt;<br>  &lt;div class=&quot;typing-area&quot;&gt;<br>    &lt;form action=&quot;#&quot; class=&quot;typing-form&quot;&gt;<br>      &lt;div class=&quot;input-wrapper&quot;&gt;<br>        &lt;input type=&quot;text&quot; placeholder=&quot;Enter a prompt here&quot; class=&quot;typing-input&quot; required /&gt;<br>        &lt;button id=&quot;send-message-button&quot; class=&quot;icon material-symbols-rounded&quot;&gt;send&lt;/button&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;action-buttons&quot;&gt;<br>        &lt;span id=&quot;theme-toggle-button&quot; class=&quot;icon material-symbols-rounded&quot;&gt;light_mode&lt;/span&gt;<br>        &lt;span id=&quot;delete-chat-button&quot; class=&quot;icon material-symbols-rounded&quot;&gt;delete&lt;/span&gt;<br>      &lt;/div&gt;<br>    &lt;/form&gt;<br>    &lt;p class=&quot;disclaimer-text&quot;&gt;<br>      Gemini may display inaccurate info, including about people, so double-check its responses.<br>    &lt;/p&gt;<br>  &lt;/div&gt;<br><br>  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In your style.css file, add CSS code to style your chatbot, and give it a responsive and Gemini-like design. Experiment with different CSS properties such as colors, fonts, and backgrounds to make your clone more attractive.</p><pre>/* Import Google Font - Poppins */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Poppins&quot;, sans-serif;<br>}<br><br>:root {<br>  /* Dark mode colors */<br>  --text-color: #E3E3E3;<br>  --subheading-color: #828282;<br>  --placeholder-color: #A6A6A6;<br>  --primary-color: #242424;<br>  --secondary-color: #383838;<br>  --secondary-hover-color: #444;<br>}<br><br>.light_mode {<br>  /* Light mode colors */<br>  --text-color: #222;<br>  --subheading-color: #A0A0A0;<br>  --placeholder-color: #6C6C6C;<br>  --primary-color: #FFF;<br>  --secondary-color: #E9EEF6;<br>  --secondary-hover-color: #DBE1EA;<br>}<br><br>body {<br>  background: var(--primary-color);<br>}<br><br>.header, .chat-list .message, .typing-form {<br>  margin: 0 auto;<br>  max-width: 980px;<br>}<br><br>.header {<br>  margin-top: 6vh;<br>  padding: 1rem;<br>  overflow-x: hidden;<br>}<br><br>body.hide-header .header {<br>  margin: 0;<br>  display: none;<br>}<br><br>.header :where(.title, .subtitle) {<br>  color: var(--text-color);<br>  font-weight: 500;<br>  line-height: 4rem;<br>}<br><br>.header .title {<br>  width: fit-content;<br>  font-size: 3rem;<br>  background-clip: text;<br>  background: linear-gradient(to right, #4285f4, #d96570);<br>  -webkit-background-clip: text;<br>  -webkit-text-fill-color: transparent;<br>}<br><br>.header .subtitle {<br>  font-size: 2.6rem;<br>  color: var(--subheading-color);<br>}<br><br>.suggestion-list {<br>  width: 100%;<br>  list-style: none;<br>  display: flex;<br>  gap: 1.25rem;<br>  margin-top: 9.5vh;<br>  overflow: hidden;<br>  overflow-x: auto;<br>  scroll-snap-type: x mandatory;<br>  scrollbar-width: none;<br>}<br><br>.suggestion-list .suggestion {<br>  cursor: pointer;<br>  padding: 1.25rem;<br>  width: 222px;<br>  flex-shrink: 0;<br>  display: flex;<br>  flex-direction: column;<br>  align-items: flex-end;<br>  border-radius: 0.75rem;<br>  justify-content: space-between;<br>  background: var(--secondary-color);<br>  transition: 0.2s ease;<br>}<br><br>.suggestion-list .suggestion:hover {<br>  background: var(--secondary-hover-color);<br>}<br><br>.suggestion-list .suggestion :where(.text, .icon) {<br>  font-weight: 400;<br>  color: var(--text-color);<br>}<br><br>.suggestion-list .suggestion .icon {<br>  width: 42px;<br>  height: 42px;<br>  display: flex;<br>  font-size: 1.3rem;<br>  margin-top: 2.5rem;<br>  align-self: flex-end;<br>  align-items: center;<br>  border-radius: 50%;<br>  justify-content: center;<br>  color: var(--text-color);<br>  background: var(--primary-color);<br>}<br><br>.chat-list {<br>  padding: 2rem 1rem 12rem;<br>  max-height: 100vh;<br>  overflow-y: auto;<br>  scrollbar-color: #999 transparent;<br>}<br><br>.chat-list .message.incoming {<br>  margin-top: 1.5rem;<br>}<br><br>.chat-list .message .message-content {<br>  display: flex;<br>  gap: 1.5rem;<br>  width: 100%;<br>  align-items: center;<br>}<br><br>.chat-list .message .text {<br>  color: var(--text-color);<br>  white-space: pre-wrap;<br>}<br><br>.chat-list .message.error .text {<br>  color: #e55865;<br>}<br><br>.chat-list .message.loading .text {<br>  display: none;<br>}<br><br>.chat-list .message .avatar {<br>  width: 40px;<br>  height: 40px;<br>  object-fit: cover;<br>  border-radius: 50%;<br>  align-self: flex-start;<br>}<br><br>.chat-list .message.loading .avatar {<br>  animation: rotate 3s linear infinite;<br>}<br><br>@keyframes rotate {<br>  100% {<br>    transform: rotate(360deg);<br>  }<br>}<br><br>.chat-list .message .icon {<br>  color: var(--text-color);<br>  cursor: pointer;<br>  height: 35px;<br>  width: 35px;<br>  border-radius: 50%;<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  background: none;<br>  font-size: 1.25rem;<br>  margin-left: 3.5rem;<br>  visibility: hidden;<br>}<br><br>.chat-list .message .icon.hide {<br>  visibility: hidden;<br>}<br><br>.chat-list .message:not(.loading, .error):hover .icon:not(.hide){<br>  visibility: visible;<br>}<br><br>.chat-list .message .icon:hover {<br>  background: var(--secondary-hover-color);<br>}<br><br>.chat-list .message .loading-indicator {<br>  display: none;<br>  gap: 0.8rem;<br>  width: 100%;<br>  flex-direction: column;<br>}<br><br>.chat-list .message.loading .loading-indicator {<br>  display: flex;<br>}<br><br>.chat-list .message .loading-indicator .loading-bar {<br>  height: 11px;<br>  width: 100%;<br>  border-radius: 0.135rem;<br>  background-position: -800px 0;<br>  background: linear-gradient(to right, #4285f4, var(--primary-color), #4285f4);<br>  animation: loading 3s linear infinite;<br>}<br><br>.chat-list .message .loading-indicator .loading-bar:last-child {<br>  width: 70%;<br>}<br><br>@keyframes loading {<br>  0% {<br>    background-position: -800px 0;<br>  }<br><br>  100% {<br>    background-position: 800px 0;<br>  }<br>}<br><br>.typing-area {<br>  position: fixed;<br>  width: 100%;<br>  left: 0;<br>  bottom: 0;<br>  padding: 1rem;<br>  background: var(--primary-color);<br>}<br><br>.typing-area :where(.typing-form, .action-buttons) {<br>  display: flex;<br>  gap: 0.75rem;<br>}<br><br>.typing-form .input-wrapper {<br>  width: 100%;<br>  height: 56px;<br>  display: flex;<br>  position: relative;<br>}<br><br>.typing-form .typing-input {<br>  height: 100%;<br>  width: 100%;<br>  border: none;<br>  outline: none;<br>  resize: none;<br>  font-size: 1rem;<br>  color: var(--text-color);<br>  padding: 1.1rem 4rem 1.1rem 1.5rem;<br>  border-radius: 100px;<br>  background: var(--secondary-color);<br>}<br><br>.typing-form .typing-input:focus {<br>  background: var(--secondary-hover-color);<br>}<br><br>.typing-form .typing-input::placeholder {<br>  color: var(--placeholder-color);<br>}<br><br>.typing-area .icon {<br>  width: 56px;<br>  height: 56px;<br>  flex-shrink: 0;<br>  cursor: pointer;<br>  border-radius: 50%;<br>  display: flex;<br>  font-size: 1.4rem;<br>  color: var(--text-color);<br>  align-items: center;<br>  justify-content: center;<br>  background: var(--secondary-color);<br>  transition: 0.2s ease;<br>}<br><br>.typing-area .icon:hover {<br>  background: var(--secondary-hover-color);<br>}<br><br>.typing-form #send-message-button {<br>  position: absolute;<br>  right: 0;<br>  outline: none;<br>  border: none;<br>  transform: scale(0);<br>  background: transparent;<br>  transition: transform 0.2s ease;<br>}<br><br>.typing-form .typing-input:valid ~ #send-message-button {<br>  transform: scale(1);<br>}<br><br>.typing-area .disclaimer-text {<br>  text-align: center;<br>  font-size: 0.85rem;<br>  margin-top: 1rem;<br>  color: var(--placeholder-color);<br>}<br><br>/* Responsive media query code for small screen */<br>@media (max-width: 768px) {<br>  .header :is(.title, .subtitle) {<br>    font-size: 2rem;<br>    line-height: 2.6rem;<br>  }<br><br>  .header .subtitle {<br>    font-size: 1.7rem;<br>  }<br><br>  .typing-area :where(.typing-form, .action-buttons) {<br>    gap: 0.4rem;<br>  }<br><br>  .typing-form .input-wrapper {<br>    height: 50px;<br>  }<br><br>  .typing-form .typing-input {<br>    padding: 1.1rem 3.5rem 1.1rem 1.2rem;<br>  }<br><br>  .typing-area .icon {<br>    height: 50px;<br>    width: 50px;<br>  }<br><br>  .typing-area .disclaimer-text {<br>    font-size: 0.75rem;<br>    margin-top: 0.5rem;<br>  }<br>}</pre><p>In your script.js file, add JavaScript code to make your chatbot interactive and functional. This includes enabling features such as sending and receiving messages, toggling between light and dark themes, and managing chat history.</p><pre>const typingForm = document.querySelector(&quot;.typing-form&quot;);<br>const chatContainer = document.querySelector(&quot;.chat-list&quot;);<br>const suggestions = document.querySelectorAll(&quot;.suggestion&quot;);<br>const toggleThemeButton = document.querySelector(&quot;#theme-toggle-button&quot;);<br>const deleteChatButton = document.querySelector(&quot;#delete-chat-button&quot;);<br><br>// State variables<br>let userMessage = null;<br>let isResponseGenerating = false;<br><br>// API configuration<br>const API_KEY = &quot;PASTE-YOUR-API-KEY&quot;; // Your API key here<br>const API_URL = `https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent?key=${API_KEY}`;<br><br>// Load theme and chat data from local storage on page load<br>const loadDataFromLocalstorage = () =&gt; {<br>  const savedChats = localStorage.getItem(&quot;saved-chats&quot;);<br>  const isLightMode = (localStorage.getItem(&quot;themeColor&quot;) === &quot;light_mode&quot;);<br><br>  // Apply the stored theme<br>  document.body.classList.toggle(&quot;light_mode&quot;, isLightMode);<br>  toggleThemeButton.innerText = isLightMode ? &quot;dark_mode&quot; : &quot;light_mode&quot;;<br><br>  // Restore saved chats or clear the chat container<br>  chatContainer.innerHTML = savedChats || &#39;&#39;;<br>  document.body.classList.toggle(&quot;hide-header&quot;, savedChats);<br><br>  chatContainer.scrollTo(0, chatContainer.scrollHeight); // Scroll to the bottom<br>}<br><br>// Create a new message element and return it<br>const createMessageElement = (content, ...classes) =&gt; {<br>  const div = document.createElement(&quot;div&quot;);<br>  div.classList.add(&quot;message&quot;, ...classes);<br>  div.innerHTML = content;<br>  return div;<br>}<br><br>// Show typing effect by displaying words one by one<br>const showTypingEffect = (text, textElement, incomingMessageDiv) =&gt; {<br>  const words = text.split(&#39; &#39;);<br>  let currentWordIndex = 0;<br><br>  const typingInterval = setInterval(() =&gt; {<br>    // Append each word to the text element with a space<br>    textElement.innerText += (currentWordIndex === 0 ? &#39;&#39; : &#39; &#39;) + words[currentWordIndex++];<br>    incomingMessageDiv.querySelector(&quot;.icon&quot;).classList.add(&quot;hide&quot;);<br><br>    // If all words are displayed<br>    if (currentWordIndex === words.length) {<br>      clearInterval(typingInterval);<br>      isResponseGenerating = false;<br>      incomingMessageDiv.querySelector(&quot;.icon&quot;).classList.remove(&quot;hide&quot;);<br>      localStorage.setItem(&quot;saved-chats&quot;, chatContainer.innerHTML); // Save chats to local storage<br>    }<br>    chatContainer.scrollTo(0, chatContainer.scrollHeight); // Scroll to the bottom<br>  }, 75);<br>}<br><br>// Fetch response from the API based on user message<br>const generateAPIResponse = async (incomingMessageDiv) =&gt; {<br>  const textElement = incomingMessageDiv.querySelector(&quot;.text&quot;); // Getting text element<br><br>  try {<br>    // Send a POST request to the API with the user&#39;s message<br>    const response = await fetch(API_URL, {<br>      method: &quot;POST&quot;,<br>      headers: { &quot;Content-Type&quot;: &quot;application/json&quot; },<br>      body: JSON.stringify({ <br>        contents: [{ <br>          role: &quot;user&quot;, <br>          parts: [{ text: userMessage }] <br>        }] <br>      }),<br>    });<br><br>    const data = await response.json();<br>    if (!response.ok) throw new Error(data.error.message);<br><br>    // Get the API response text and remove asterisks from it<br>    const apiResponse = data?.candidates[0].content.parts[0].text.replace(/\*\*(.*?)\*\*/g, &#39;$1&#39;);<br>    showTypingEffect(apiResponse, textElement, incomingMessageDiv); // Show typing effect<br>  } catch (error) { // Handle error<br>    isResponseGenerating = false;<br>    textElement.innerText = error.message;<br>    textElement.parentElement.closest(&quot;.message&quot;).classList.add(&quot;error&quot;);<br>  } finally {<br>    incomingMessageDiv.classList.remove(&quot;loading&quot;);<br>  }<br>}<br><br>// Show a loading animation while waiting for the API response<br>const showLoadingAnimation = () =&gt; {<br>  const html = `&lt;div class=&quot;message-content&quot;&gt;<br>                  &lt;img class=&quot;avatar&quot; src=&quot;images/gemini.svg&quot; alt=&quot;Gemini avatar&quot;&gt;<br>                  &lt;p class=&quot;text&quot;&gt;&lt;/p&gt;<br>                  &lt;div class=&quot;loading-indicator&quot;&gt;<br>                    &lt;div class=&quot;loading-bar&quot;&gt;&lt;/div&gt;<br>                    &lt;div class=&quot;loading-bar&quot;&gt;&lt;/div&gt;<br>                    &lt;div class=&quot;loading-bar&quot;&gt;&lt;/div&gt;<br>                  &lt;/div&gt;<br>                &lt;/div&gt;<br>                &lt;span onClick=&quot;copyMessage(this)&quot; class=&quot;icon material-symbols-rounded&quot;&gt;content_copy&lt;/span&gt;`;<br><br>  const incomingMessageDiv = createMessageElement(html, &quot;incoming&quot;, &quot;loading&quot;);<br>  chatContainer.appendChild(incomingMessageDiv);<br><br>  chatContainer.scrollTo(0, chatContainer.scrollHeight); // Scroll to the bottom<br>  generateAPIResponse(incomingMessageDiv);<br>}<br><br>// Copy message text to the clipboard<br>const copyMessage = (copyButton) =&gt; {<br>  const messageText = copyButton.parentElement.querySelector(&quot;.text&quot;).innerText;<br><br>  navigator.clipboard.writeText(messageText);<br>  copyButton.innerText = &quot;done&quot;; // Show confirmation icon<br>  setTimeout(() =&gt; copyButton.innerText = &quot;content_copy&quot;, 1000); // Revert icon after 1 second<br>}<br><br>// Handle sending outgoing chat messages<br>const handleOutgoingChat = () =&gt; {<br>  userMessage = typingForm.querySelector(&quot;.typing-input&quot;).value.trim() || userMessage;<br>  if(!userMessage || isResponseGenerating) return; // Exit if there is no message or response is generating<br><br>  isResponseGenerating = true;<br><br>  const html = `&lt;div class=&quot;message-content&quot;&gt;<br>                  &lt;img class=&quot;avatar&quot; src=&quot;images/user.jpg&quot; alt=&quot;User avatar&quot;&gt;<br>                  &lt;p class=&quot;text&quot;&gt;&lt;/p&gt;<br>                &lt;/div&gt;`;<br><br>  const outgoingMessageDiv = createMessageElement(html, &quot;outgoing&quot;);<br>  outgoingMessageDiv.querySelector(&quot;.text&quot;).innerText = userMessage;<br>  chatContainer.appendChild(outgoingMessageDiv);<br>  <br>  typingForm.reset(); // Clear input field<br>  document.body.classList.add(&quot;hide-header&quot;);<br>  chatContainer.scrollTo(0, chatContainer.scrollHeight); // Scroll to the bottom<br>  setTimeout(showLoadingAnimation, 500); // Show loading animation after a delay<br>}<br><br>// Toggle between light and dark themes<br>toggleThemeButton.addEventListener(&quot;click&quot;, () =&gt; {<br>  const isLightMode = document.body.classList.toggle(&quot;light_mode&quot;);<br>  localStorage.setItem(&quot;themeColor&quot;, isLightMode ? &quot;light_mode&quot; : &quot;dark_mode&quot;);<br>  toggleThemeButton.innerText = isLightMode ? &quot;dark_mode&quot; : &quot;light_mode&quot;;<br>});<br><br>// Delete all chats from local storage when button is clicked<br>deleteChatButton.addEventListener(&quot;click&quot;, () =&gt; {<br>  if (confirm(&quot;Are you sure you want to delete all the chats?&quot;)) {<br>    localStorage.removeItem(&quot;saved-chats&quot;);<br>    loadDataFromLocalstorage();<br>  }<br>});<br><br>// Set userMessage and handle outgoing chat when a suggestion is clicked<br>suggestions.forEach(suggestion =&gt; {<br>  suggestion.addEventListener(&quot;click&quot;, () =&gt; {<br>    userMessage = suggestion.querySelector(&quot;.text&quot;).innerText;<br>    handleOutgoingChat();<br>  });<br>});<br><br>// Prevent default form submission and handle outgoing chat<br>typingForm.addEventListener(&quot;submit&quot;, (e) =&gt; {<br>  e.preventDefault(); <br>  handleOutgoingChat();<br>});<br><br>loadDataFromLocalstorage();</pre><p><strong>Important:</strong> Your chatbot is not ready to generate responses until you configure it with a Gemini API key. To do this, add your API key to the API_KEY variable in the script.js file. You can get your free API key from <a href="https://aistudio.google.com/app/apikey">Google AI Studio</a>. It will look something like this: AIzaSyAtpnKGX14bTgmx0l_gQeatYvdWvY_wOTQ.</p><p>Once you have added your API key to the code, you’ll be ready to start chatting with your Gemini chatbot. Simply open the index.html file in your browser to see it in action!</p><h3>Conclusion and final words</h3><p>You have successfully built your own Google Gemini chatbot using HTML, CSS, and JavaScript. Following these steps, you have developed a functional chatbot capable of interacting with users, changing themes, and saving chat history using local storage.</p><p>This project not only improves your web development skills but also gives you practical experience in integrating <a href="https://www.codingnepalweb.com/category/api-projects/">APIs</a> and managing application states. With your chatbot operational, you can now explore adding extra features or improving its functionality to better meet your requirements.</p><p>If you encounter any problems while building your Gemini chatbot, you can download the source code files for this project by clicking the “Download” button.</p><p><a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/google-gemini-chatbot-html-css-javascript/"><em>https://www.codingnepalweb.com</em></a><em> on July 31, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=855e03de8c27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Hangman Game in ReactJS and Tailwind CSS]]></title>
            <link>https://codingnepal.medium.com/how-to-create-a-hangman-game-in-reactjs-and-tailwind-css-6f93e5b4d848?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f93e5b4d848</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[games]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Mon, 29 Jul 2024 10:02:55 GMT</pubDate>
            <atom:updated>2024-09-03T12:34:41.911Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DlbPw_mZv3TvYtg7.jpg" /><figcaption>How to Create a Hangman Game in ReactJS and Tailwind CSS</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/create-hangman-game-reactjs-tailwind/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Hangman is the classic word-guessing game you’ve likely enjoyed playing. But as a beginner ReactJS developer, have you ever thought about creating your version of the Hangman game? Creating a <a href="https://www.codingnepalweb.com/build-hangman-game-html-javascript/">Hangman</a> game helps you grasp the fundamentals of ReactJS and Tailwind CSS, while also improving your problem-solving and logical thinking skills.</p><p>In this blog post, I’ll guide you through creating a fully functional Hangman game using <a href="https://www.codingnepalweb.com/category/reactjs/">ReactJS</a> and <a href="https://www.codingnepalweb.com/tag/tailwind-css/">Tailwind CSS</a>. In this game, the player has to guess all the letters of a randomly generated word within a given number of tries. There is also a hangman graphic that will progressively appear on the gallows for each incorrect guess.</p><h3>Why Create a Hangman Game in ReactJS?</h3><p>By creating this Hangman game project using React JS and Tailwind CSS, you can gain the following skills:</p><ul><li><strong>ReactJS Fundamentals:</strong> Get hands-on experience with React components, state management, and hooks.</li><li><strong>Tailwind CSS Skills:</strong> Learn how to create a responsive and visually appealing UI using Tailwind.</li><li><strong>Practical Application:</strong> Create a project you can showcase in your portfolio or use in real-life scenarios.</li><li><strong>Problem-Solving:</strong> Enhance your problem-solving skills by implementing game logic and managing state.</li></ul><h3>Demo of Hangman Game in ReactJS &amp; Tailwind</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FhX02ESrxGi0%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DhX02ESrxGi0&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FhX02ESrxGi0%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/766781df398ab83f7acd44eba2fd81f0/href">https://medium.com/media/766781df398ab83f7acd44eba2fd81f0/href</a></iframe><h3>Setting Up the Project</h3><p>Before we start making the Hangman game with ReactJS and Tailwind CSS, make sure you have Node.js installed on your computer. If you don’t have it, you can download and install it from the official <a href="https://nodejs.org/en/download/prebuilt-installer">Node.js</a> website.</p><p><strong>Create a Project Folder:</strong></p><ul><li>Make a new folder, for instance, “hangman-game”.</li><li>Open this folder in your VS Code editor.</li></ul><p><strong>Initialize the Project:</strong></p><p>Open your terminal by pressing Ctrl + J and then use <a href="https://vitejs.dev/">Vite</a> to create a new React app with this command:</p><pre>npm create vite@latest ./ -- --template react</pre><p>Install Tailwind CSS:</p><pre>npm install -D tailwindcss postcss autoprefixer<br>npx tailwindcss init -p</pre><p>Replace the code in tailwind.config.js with the provided configuration.</p><pre>/** @type {import(&#39;tailwindcss&#39;).Config} */<br>export default {<br>  content: [&quot;./index.html&quot;, &quot;./src/**/*.{js,ts,jsx,tsx}&quot;],<br>  theme: {<br>    extend: {},<br>  },<br>  plugins: [],<br>};</pre><p>Start the Development Server:</p><pre>npm run dev</pre><p>If your project is up and running in your browser, congratulations! You’ve successfully set up your project. Now, let’s move on to the next step modifying folders and files.</p><p><strong>Modify folder and CSS Files:</strong></p><ul><li>Remove the default assets folder and App.css file.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/hangman-game-reactjs-tailwind-images.zip">Images</a> and place them directly into your public folder. Ensure you only include the images and not the images folder itself.</li><li>Replace the content of index.css with the provided code.</li></ul><pre>/* Importing Google Fonts - Open Sans */<br>@import url(https://medium.com/&quot;https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&amp;display=swap&quot;);<br><br>@tailwind base;<br>@tailwind components;<br>@tailwind utilities;<br><br>* {<br>  font-family: &quot;Open Sans&quot;, sans-serif;<br>}<br><br>body {<br>  height: 100vh;<br>  width: 100%;<br>  background: url(https://medium.com/&quot;hangman-bg.jpg&quot;);<br>  background-size: cover;<br>  background-position: center;<br>}</pre><h3>Creating the Components</h3><p>Within the <strong>src</strong> directory of your project, organize your files by creating three different folders: <em>“constants”</em>, <em>“components”</em>, and <em>“context”</em>. Inside these folders, create the following files:</p><ul><li>constants/index.js</li><li>components/GameBoard.jsx</li><li>components/GameKeyboard.jsx</li><li>components/HangmanIllustration.jsx</li><li>components/GameOverModal.jsx</li><li>context/GameContext.jsx</li></ul><h3>Adding the Codes</h3><p>Add the respective code to each newly created file. These files define the layout and functionality of the Hangman Game.</p><p>In constants/index.js, add the code. This file serves as a main location for defining and managing the word list used for the game.</p><pre>// List of words and their corresponding hints for the game<br>export const wordList = [<br>  {<br>    word: &quot;guitar&quot;,<br>    hint: &quot;A musical instrument with strings.&quot;,<br>  },<br>  {<br>    word: &quot;oxygen&quot;,<br>    hint: &quot;A colorless, odorless gas essential for life.&quot;,<br>  },<br>  {<br>    word: &quot;mountain&quot;,<br>    hint: &quot;A large natural elevation of the Earth&#39;s surface.&quot;,<br>  },<br>  {<br>    word: &quot;painting&quot;,<br>    hint: &quot;An art form using colors on a surface to create images or expression.&quot;,<br>  },<br>  {<br>    word: &quot;astronomy&quot;,<br>    hint: &quot;The scientific study of celestial objects and phenomena.&quot;,<br>  },<br>  {<br>    word: &quot;football&quot;,<br>    hint: &quot;A popular sport played with a spherical ball.&quot;,<br>  },<br>  {<br>    word: &quot;chocolate&quot;,<br>    hint: &quot;A sweet treat made from cocoa beans.&quot;,<br>  },<br>  {<br>    word: &quot;butterfly&quot;,<br>    hint: &quot;An insect with colorful wings and a slender body.&quot;,<br>  },<br>  {<br>    word: &quot;history&quot;,<br>    hint: &quot;The study of past events and human civilization.&quot;,<br>  },<br>  {<br>    word: &quot;pizza&quot;,<br>    hint: &quot;A savory dish consisting of a round, flattened base with toppings.&quot;,<br>  },<br>  {<br>    word: &quot;jazz&quot;,<br>    hint: &quot;A genre of music characterized by improvisation and syncopation.&quot;,<br>  },<br>  {<br>    word: &quot;camera&quot;,<br>    hint: &quot;A device used to capture and record images or videos.&quot;,<br>  },<br>  {<br>    word: &quot;diamond&quot;,<br>    hint: &quot;A precious gemstone known for its brilliance and hardness.&quot;,<br>  },<br>  {<br>    word: &quot;adventure&quot;,<br>    hint: &quot;An exciting or daring experience.&quot;,<br>  },<br>  {<br>    word: &quot;science&quot;,<br>    hint: &quot;The systematic study of the structure and behavior of the physical and natural world.&quot;,<br>  },<br>  {<br>    word: &quot;bicycle&quot;,<br>    hint: &quot;A human-powered vehicle with two wheels.&quot;,<br>  },<br>  {<br>    word: &quot;sunset&quot;,<br>    hint: &quot;The daily disappearance of the sun below the horizon.&quot;,<br>  },<br>  {<br>    word: &quot;coffee&quot;,<br>    hint: &quot;A popular caffeinated beverage made from roasted coffee beans.&quot;,<br>  },<br>  {<br>    word: &quot;dance&quot;,<br>    hint: &quot;A rhythmic movement of the body often performed to music.&quot;,<br>  },<br>  {<br>    word: &quot;galaxy&quot;,<br>    hint: &quot;A vast system of stars, gas, and dust held together by gravity.&quot;,<br>  },<br>  {<br>    word: &quot;orchestra&quot;,<br>    hint: &quot;A large ensemble of musicians playing various instruments.&quot;,<br>  },<br>  {<br>    word: &quot;volcano&quot;,<br>    hint: &quot;A mountain or hill with a vent through which lava, rock fragments, hot vapor, and gas are ejected.&quot;,<br>  },<br>  {<br>    word: &quot;novel&quot;,<br>    hint: &quot;A long work of fiction, typically with a complex plot and characters.&quot;,<br>  },<br>  {<br>    word: &quot;sculpture&quot;,<br>    hint: &quot;A three-dimensional art form created by shaping or combining materials.&quot;,<br>  },<br>  {<br>    word: &quot;symphony&quot;,<br>    hint: &quot;A long musical composition for a full orchestra, typically in multiple movements.&quot;,<br>  },<br>  {<br>    word: &quot;architecture&quot;,<br>    hint: &quot;The art and science of designing and constructing buildings.&quot;,<br>  },<br>  {<br>    word: &quot;ballet&quot;,<br>    hint: &quot;A classical dance form characterized by precise and graceful movements.&quot;,<br>  },<br>  {<br>    word: &quot;astronaut&quot;,<br>    hint: &quot;A person trained to travel and work in space.&quot;,<br>  },<br>  {<br>    word: &quot;waterfall&quot;,<br>    hint: &quot;A cascade of water falling from a height.&quot;,<br>  },<br>  {<br>    word: &quot;technology&quot;,<br>    hint: &quot;The application of scientific knowledge for practical purposes.&quot;,<br>  },<br>  {<br>    word: &quot;rainbow&quot;,<br>    hint: &quot;A meteorological phenomenon that is caused by reflection, refraction, and dispersion of light.&quot;,<br>  },<br>  {<br>    word: &quot;universe&quot;,<br>    hint: &quot;All existing matter, space, and time as a whole.&quot;,<br>  },<br>  {<br>    word: &quot;piano&quot;,<br>    hint: &quot;A musical instrument played by pressing keys that cause hammers to strike strings.&quot;,<br>  },<br>  {<br>    word: &quot;vacation&quot;,<br>    hint: &quot;A period of time devoted to pleasure, rest, or relaxation.&quot;,<br>  },<br>  {<br>    word: &quot;rainforest&quot;,<br>    hint: &quot;A dense forest characterized by high rainfall and biodiversity.&quot;,<br>  },<br>  {<br>    word: &quot;theater&quot;,<br>    hint: &quot;A building or outdoor area in which plays, movies, or other performances are staged.&quot;,<br>  },<br>  {<br>    word: &quot;telephone&quot;,<br>    hint: &quot;A device used to transmit sound over long distances.&quot;,<br>  },<br>  {<br>    word: &quot;language&quot;,<br>    hint: &quot;A system of communication consisting of words, gestures, and syntax.&quot;,<br>  },<br>  {<br>    word: &quot;desert&quot;,<br>    hint: &quot;A barren or arid land with little or no precipitation.&quot;,<br>  },<br>  {<br>    word: &quot;sunflower&quot;,<br>    hint: &quot;A tall plant with a large yellow flower head.&quot;,<br>  },<br>  {<br>    word: &quot;fantasy&quot;,<br>    hint: &quot;A genre of imaginative fiction involving magic and supernatural elements.&quot;,<br>  },<br>  {<br>    word: &quot;telescope&quot;,<br>    hint: &quot;An optical instrument used to view distant objects in space.&quot;,<br>  },<br>  {<br>    word: &quot;breeze&quot;,<br>    hint: &quot;A gentle wind.&quot;,<br>  },<br>  {<br>    word: &quot;oasis&quot;,<br>    hint: &quot;A fertile spot in a desert where water is found.&quot;,<br>  },<br>  {<br>    word: &quot;photography&quot;,<br>    hint: &quot;The art, process, or practice of creating images by recording light or other electromagnetic radiation.&quot;,<br>  },<br>  {<br>    word: &quot;safari&quot;,<br>    hint: &quot;An expedition or journey, typically to observe wildlife in their natural habitat.&quot;,<br>  },<br>  {<br>    word: &quot;planet&quot;,<br>    hint: &quot;A celestial body that orbits a star and does not produce light of its own.&quot;,<br>  },<br>  {<br>    word: &quot;river&quot;,<br>    hint: &quot;A large natural stream of water flowing in a channel to the sea, a lake, or another such stream.&quot;,<br>  },<br>  {<br>    word: &quot;tropical&quot;,<br>    hint: &quot;Relating to or situated in the region between the Tropic of Cancer and the Tropic of Capricorn.&quot;,<br>  },<br>  {<br>    word: &quot;mysterious&quot;,<br>    hint: &quot;Difficult or impossible to understand, explain, or identify.&quot;,<br>  },<br>  {<br>    word: &quot;enigma&quot;,<br>    hint: &quot;Something that is mysterious, puzzling, or difficult to understand.&quot;,<br>  },<br>  {<br>    word: &quot;paradox&quot;,<br>    hint: &quot;A statement or situation that contradicts itself or defies intuition.&quot;,<br>  },<br>  {<br>    word: &quot;puzzle&quot;,<br>    hint: &quot;A game, toy, or problem designed to test ingenuity or knowledge.&quot;,<br>  },<br>  {<br>    word: &quot;whisper&quot;,<br>    hint: &quot;To speak very softly or quietly, often in a secretive manner.&quot;,<br>  },<br>  {<br>    word: &quot;shadow&quot;,<br>    hint: &quot;A dark area or shape produced by an object blocking the light.&quot;,<br>  },<br>  {<br>    word: &quot;secret&quot;,<br>    hint: &quot;Something kept hidden or unknown to others.&quot;,<br>  },<br>  {<br>    word: &quot;curiosity&quot;,<br>    hint: &quot;A strong desire to know or learn something.&quot;,<br>  },<br>  {<br>    word: &quot;unpredictable&quot;,<br>    hint: &quot;Not able to be foreseen or known beforehand; uncertain.&quot;,<br>  },<br>  {<br>    word: &quot;obfuscate&quot;,<br>    hint: &quot;To confuse or bewilder someone; to make something unclear or difficult to understand.&quot;,<br>  },<br>  {<br>    word: &quot;unveil&quot;,<br>    hint: &quot;To make known or reveal something previously secret or unknown.&quot;,<br>  },<br>  {<br>    word: &quot;illusion&quot;,<br>    hint: &quot;A false perception or belief; a deceptive appearance or impression.&quot;,<br>  },<br>  {<br>    word: &quot;moonlight&quot;,<br>    hint: &quot;The light from the moon.&quot;,<br>  },<br>  {<br>    word: &quot;vibrant&quot;,<br>    hint: &quot;Full of energy, brightness, and life.&quot;,<br>  },<br>  {<br>    word: &quot;nostalgia&quot;,<br>    hint: &quot;A sentimental longing or wistful affection for the past.&quot;,<br>  },<br>  {<br>    word: &quot;brilliant&quot;,<br>    hint: &quot;Exceptionally clever, talented, or impressive.&quot;,<br>  },<br>];</pre><p>In components/GameBoard.jsx, add the code to render the main Hangman game interface, including the word display, guessed letters, and keyboard.</p><pre>import { useContext, useEffect, useRef } from &quot;react&quot;;<br>import GameContext from &quot;../context/GameContext&quot;;<br>import GameKeyboard from &quot;./GameKeyboard&quot;;<br>import { wordList } from &quot;../constants&quot;;<br><br>// GameBoard component<br>const GameBoard = () =&gt; {<br>  // Extract necessary values and functions from GameContext<br>  const { currentWord, setCurrentWord, correctLetters, setCorrectLetters, clickedKeys,  setClickedKeys, wrongGuesses, setWrongGuesses, setIsGameWon, setShowModal, isGameReset, setIsGameReset } = useContext(GameContext);<br><br>  // Reference for the hint element<br>  const hintRef = useRef();<br>  const maxGuesses = 6;<br><br>  // Effect to initialize the game board with a random word and hint<br>  useEffect(() =&gt; {<br>    const { word, hint } = wordList[Math.floor(Math.random() * wordList.length)];<br>    hintRef.current.innerText = hint;<br>    setCurrentWord(word);<br>    setCorrectLetters(new Array(word.length).fill(&quot;&quot;));<br>    setIsGameReset(false);<br>  }, [isGameReset, setCorrectLetters, setCurrentWord, setIsGameReset]);<br><br>  // Effect to check game status (win/lose) based on guesses and correct letters<br>  useEffect(() =&gt; {<br>    if (currentWord &amp;&amp; correctLetters.length) {<br>      if (wrongGuesses &gt;= maxGuesses) {<br>        setIsGameWon(false);<br>        setShowModal(true);<br>      } else if (correctLetters.join(&quot;&quot;) === currentWord) {<br>        setIsGameWon(true);<br>        setShowModal(true);<br>      }<br>    }<br>  }, [correctLetters, wrongGuesses, currentWord, setIsGameWon, setShowModal]);<br><br>   // Handle key clicks and update the game state accordingly<br>  const handleClickedKey = (clickedKey) =&gt; {<br>    if (currentWord.includes(clickedKey)) {<br>      const updatedCorrectLetters = correctLetters.map((letter, index) =&gt;<br>        currentWord[index] === clickedKey ? clickedKey : letter,<br>      );<br>      setCorrectLetters(updatedCorrectLetters);<br>    } else {<br>      setWrongGuesses((prevGuesses) =&gt; prevGuesses + 1);<br>    }<br><br>    setClickedKeys((prevKeys) =&gt; [...prevKeys, clickedKey]);<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      {/* Display the current word with guessed letters */}<br>      &lt;ul className=&quot;flex flex-wrap items-center justify-center gap-3&quot;&gt;<br>        {currentWord?.split(&quot;&quot;).map((_, index) =&gt; (<br>          &lt;li key={index} className={`-mt-10 mb-10 w-7 text-center text-3xl font-semibold uppercase ${ !correctLetters[index] &amp;&amp; &quot;mt-0 border border-b-2 border-black&quot;}`}&gt;<br>            {correctLetters[index]}<br>          &lt;/li&gt;<br>        ))}<br>      &lt;/ul&gt;<br><br>      {/* Display the hint */}<br>      &lt;h4 className=&quot;mb-4 text-center text-lg font-medium max-md:text-base&quot;&gt;<br>        Hint:{&quot; &quot;}<br>        &lt;b ref={hintRef} className=&quot;font-semibold text-neutral-700&quot;&gt;&lt;/b&gt;<br>      &lt;/h4&gt;<br><br>      {/* Display the number of incorrect guesses and max guesses */}<br>      &lt;h4 className=&quot;mb-4 text-center text-lg font-medium text-neutral-800 max-md:text-base&quot;&gt;<br>        Incorrect guesses:{&quot; &quot;}<br>        &lt;b className=&quot;font-bold text-red-500&quot;&gt;<br>          {wrongGuesses} / {maxGuesses}<br>        &lt;/b&gt;<br>      &lt;/h4&gt;<br><br>      {/* Display the game keyboard */}<br>      &lt;GameKeyboard handleClickedKey={handleClickedKey} clickedKeys={clickedKeys} /&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default GameBoard;</pre><p>In components/GameKeyboard.jsx, add the code to render the virtual keyboard used for guessing letters. It displays the alphabet and triggers the guessing function when a letter is clicked.</p><pre>// GameKeyboard component, receives handleClickedKey and clickedKeys as props<br>const GameKeyboard = ({ handleClickedKey, clickedKeys }) =&gt; {<br>  // Create an array of alphabet letters from &#39;a&#39; to &#39;z&#39;<br>  const alphabetArray = Array.from({ length: 26 }, (_, i) =&gt;<br>    String.fromCharCode(97 + i),<br>  );<br><br>  return (<br>    // Container for the keyboard buttons<br>    &lt;div className=&quot;mt-9 flex flex-wrap justify-center gap-1&quot;&gt;<br>      {alphabetArray.map((char) =&gt; (<br>        &lt;button<br>          onClick={() =&gt; handleClickedKey(char)}<br>          disabled={clickedKeys.includes(char)} // Disable button if key is already clicked<br>          key={char}<br>          className={`w-[calc(100%/9-5px)] rounded-md border bg-emerald-700 py-1.5 font-semibold text-white hover:bg-emerald-600 ${clickedKeys.includes(char) &amp;&amp; &quot;pointer-events-none opacity-60&quot;}`}<br>        &gt;<br>          {char.toUpperCase()}<br>        &lt;/button&gt;<br>      ))}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default GameKeyboard;</pre><p>In components/HangmanIllustration.jsx, add the code to render the Hangman graphic that updates based on the number of incorrect guesses.</p><pre>import { useContext } from &quot;react&quot;;<br>import GameContext from &quot;../context/GameContext&quot;;<br><br>// HangmanIllustration component<br>const HangmanIllustration = () =&gt; {<br>  // Extract wrongGuesses value from GameContext<br>  const { wrongGuesses } = useContext(GameContext);<br><br>  return (<br>    &lt;div&gt;<br>      {/* Display the hangman image based on the number of wrong guesses */}<br>      &lt;img<br>        className=&quot;pointer-events-none max-w-[270px] select-none max-md:max-w-[200px]&quot;<br>        src={`hangman-${wrongGuesses}.svg`}<br>        alt=&quot;Hangman Illustration&quot;<br>      /&gt;<br>      &lt;h2 className=&quot;mt-6 text-center text-2xl font-bold uppercase max-md:hidden&quot;&gt;Hangman Game&lt;/h2&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default HangmanIllustration;</pre><p>In components/GameOverModal.jsx, add the code to render a modal showing the game outcome (win or loss), the correct word, and a button to play again.</p><pre>import { useContext } from &quot;react&quot;;<br>import GameContext from &quot;../context/GameContext&quot;;<br><br>// GameOverModal component<br>const GameOverModal = () =&gt; {<br>  // Extract necessary values from GameContext<br>  const { currentWord, isGameWon, showModal, resetGameBoard } = useContext(GameContext);<br><br>  return (<br>    // Modal container with conditional visibility<br>    &lt;div className={`inset fixed z-10 flex h-full w-full items-center justify-center bg-[rgba(0,0,0,0.5)] px-3 backdrop-blur-lg ${showModal ? &quot;pointer-events-auto opacity-100&quot; : &quot;pointer-events-none opacity-0&quot;}  transition-opacity duration-300`}&gt;<br>      &lt;div className=&quot;flex max-w-[420px] flex-grow flex-col items-center rounded-lg border bg-white p-7 text-center shadow-2xl&quot;&gt;<br>        {/* Display appropriate gif based on game outcome */}<br>        &lt;img className=&quot;mb-5 max-w-32 max-md:w-28&quot; src={`${showModal &amp;&amp; (isGameWon ? &#39;won&#39; : &#39;lost&#39;)}.gif`} alt=&quot;Gif&quot; /&gt;<br><br>        {/* Display game outcome message */}<br>        &lt;h4 className=&quot;text-2xl font-bold&quot;&gt;<br>          {showModal &amp;&amp; (isGameWon ? &quot;Congratulations!&quot; : &quot;Better Luck Next Time!&quot;)}<br>        &lt;/h4&gt;<br><br>        {/* Display game result and the correct word */}<br>        &lt;p className=&quot;mb-8 mt-4 text-xl max-lg:text-lg&quot;&gt;<br>          {isGameWon ? &quot;You guessed the word&quot; : &quot;The correct word was&quot;}<br>          &lt;br /&gt;<br>          &lt;b className=&quot;font-bold uppercase text-emerald-700&quot;&gt;{&quot; &quot;} {showModal &amp;&amp; currentWord}&lt;/b&gt;<br>        &lt;/p&gt;<br><br>        {/* Display Play Again button */}<br>        &lt;button<br>          onClick={resetGameBoard}<br>          className=&quot;max-lg:2 rounded-md border bg-emerald-700 px-5 py-2.5 font-medium uppercase text-white hover:bg-emerald-600 max-lg:px-4&quot;<br>        &gt;<br>          Play Again<br>        &lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default GameOverModal;</pre><p>In context/GameContext.jsx, add the code to manage the game state, including the current word, guessed letters, and game outcome, and provide this state to child components through context.</p><pre>import { createContext, useState } from &quot;react&quot;;<br><br>// Create a new context for the game<br>const GameContext = createContext();<br><br>// Provider component to manage game state and provide it to children components<br>export const GameProvider = ({ children }) =&gt; {<br>  const [currentWord, setCurrentWord] = useState(&quot;&quot;);<br>  const [correctLetters, setCorrectLetters] = useState([]);<br>  const [clickedKeys, setClickedKeys] = useState([]);<br>  const [wrongGuesses, setWrongGuesses] = useState(0);<br>  const [isGameWon, setIsGameWon] = useState(false);<br>  const [showModal, setShowModal] = useState(false);<br>  const [isGameReset, setIsGameReset] = useState(false);<br><br>  // Function to reset the game board to its initial state<br>  const resetGameBoard = () =&gt; {<br>    setShowModal(false);<br>    setCurrentWord(&quot;&quot;);<br>    setCorrectLetters([]);<br>    setClickedKeys([]);<br>    setWrongGuesses(0);<br>    setIsGameWon(false);<br>    setIsGameReset(true);<br>  };<br><br>  return (<br>    // Provide the state and functions to the children components<br>    &lt;GameContext.Provider<br>      value={{ currentWord, setCurrentWord, correctLetters, setCorrectLetters, clickedKeys, setClickedKeys, wrongGuesses, setWrongGuesses, isGameWon, setIsGameWon, showModal, setShowModal, resetGameBoard, isGameReset, setIsGameReset }}<br>    &gt;<br>      {children}<br>    &lt;/GameContext.Provider&gt;<br>  );<br>};<br><br>export default GameContext;</pre><p>Finally, replace the content of src/App.jsx with the provided code. It imports and renders the main components (GameBoard, GameOverModal, HangmanIllustration) and wraps them with the GameProvider for state management.</p><pre>// Importing necessary components and context<br>import GameBoard from &quot;./components/GameBoard&quot;;<br>import GameOverModal from &quot;./components/GameOverModal&quot;;<br>import HangmanIllustration from &quot;./components/HangmanIllustration&quot;;<br>import { GameProvider } from &quot;./context/GameContext&quot;;<br><br>// Main application component<br>export default function App() {<br>  return (<br>    // Wrapping the app with GameProvider for state management<br>    &lt;GameProvider&gt;<br>      &lt;div className=&quot;flex h-screen items-center justify-center px-3&quot;&gt;<br>        &lt;div className=&quot;flex w-[850px] items-end justify-between gap-16 rounded-lg bg-white px-10 py-14 shadow-xl max-md:flex-col max-md:items-center max-md:px-2.5 max-md:py-8&quot;&gt;<br>          &lt;HangmanIllustration /&gt;<br>          &lt;GameBoard /&gt;<br>        &lt;/div&gt;<br>        &lt;GameOverModal /&gt;<br>      &lt;/div&gt;<br>    &lt;/GameProvider&gt;<br>  );<br>}</pre><p>That’s it! If you’ve completed all the steps, you should now see your Hangman game project in your browser. You can interact with it by guessing letters, tracking your progress, and seeing the Hangman illustration update based on your guesses.</p><h3>Conclusion and final words</h3><p>You’ve successfully created your very own Hangman game using ReactJS and Tailwind CSS. By now, you should have a fully functional <a href="https://www.codingnepalweb.com/category/javascript-games/">game</a> where players can guess letters, see their progress, and enjoy a dynamic Hangman illustration. You’ve learned how to manage game state with React Context, create interactive components, and style your application with Tailwind CSS.</p><p>If you’re curious to see how the Hangman game can be built with a different approach, be sure to check out my earlier blog post on <a href="https://www.codingnepalweb.com/build-hangman-game-html-javascript/">Building a Hangman Game with HTML, CSS, &amp; JavaScript</a>.</p><p>If you encounter any problems while creating your Hangman game, you can download the source code files for this game project by clicking the “Download” button. You can also view a live demo of it by clicking the “View Live” button.</p><p>Once you’ve downloaded the project, make sure to review the README.md file included in the zip for detailed instructions on how to set up and run the project.</p><p><a href="https://codingnepalweb.com/demos/create-hangman-game-reactjs-tailwind/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/create-hangman-game-reactjs-tailwind/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/create-hangman-game-reactjs-tailwind/"><em>https://www.codingnepalweb.com</em></a><em> on July 29, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f93e5b4d848" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create A Responsive Login Form in ReactJS and CSS]]></title>
            <link>https://codingnepal.medium.com/create-a-responsive-login-form-in-reactjs-and-css-bc34f1ba0bb2?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc34f1ba0bb2</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[form-login]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Mon, 22 Jul 2024 11:21:09 GMT</pubDate>
            <atom:updated>2024-07-25T06:13:44.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4q2W5o5_CTiPm-Tx.jpg" /><figcaption>Create A Responsive Login Form in ReactJS and CSS</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/create-login-form-reactjs-css/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Are you new to ReactJS and excited to create something simple and practical? Creating a <a href="https://www.codingnepalweb.com/category/login-form/">login form</a> is a great way to dive into ReactJS and CSS. This project will help you understand essential concepts like components, state management, and style while giving you a functional and stylish login interface.</p><p>In this blog post, I’ll guide you through creating a Responsive Login Form using <a href="https://www.codingnepalweb.com/category/reactjs/">ReactJS</a> and <a href="https://www.codingnepalweb.com/category/html-and-css/">CSS</a>. This form includes important features such as email and password fields, a password toggle for better usability, and social login options for Google and Apple.</p><p>With this guide, you’ll learn how to manage form states, implement user-friendly features, and style your components to create a clean and responsive login form. Ready to get started? Let’s create it!</p><h3>Video Tutorial to Create Login Form in ReactJS</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FCz-NebfESNM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCz-NebfESNM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FCz-NebfESNM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d78a9101393615ccd86f4aa33db3393d/href">https://medium.com/media/d78a9101393615ccd86f4aa33db3393d/href</a></iframe><p>If you prefer video tutorials, the YouTube video above is a great resource. It explains each line of code and provides comments to make the process of creating your ReactJS login form easy to follow. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Setting Up the Project</h3><p>Before we start making the responsive login form with ReactJS and CSS, make sure you have Node.js installed on your computer. If you don’t have it, you can download and install it from the official <a href="https://nodejs.org/en/download/prebuilt-installer">Node.js</a> website.</p><p><strong>Create a Project Folder:</strong></p><ul><li>Make a new folder, for instance, “login-form”.</li><li>Open this folder in your VS Code editor.</li></ul><p><strong>Initialize the Project:</strong></p><p>Open your terminal by pressing Ctrl + J and then use <a href="https://vitejs.dev/">Vite </a>to create a new React app with this command:</p><pre>npm create vite@latest ./ -- --template react</pre><p>Install necessary dependencies and start the development server:</p><pre>npm install<br>npm run dev</pre><p>If your project is up and running in your browser, congratulations! You’ve successfully set up your project. Now, let’s move on to the next step modifying folders and files.</p><p><strong>Modify folder and CSS Files:</strong></p><ul><li>Remove the default assets folder and App.css file.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/login-form-reactjs-logos-2024-07-16.zip">logos</a> and place them directly into your public folder. Ensure you only include the SVG logo files and not the logos folder itself.</li><li>Replace the content of index.css with the provided code.</li></ul><pre>/* Importing Google Fonts - Montserrat */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Montserrat&quot;, sans-serif;<br>}<br><br>body {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  min-height: 100vh;<br>  background: #5F41E4;<br>}<br><br>#root {<br>  width: 100%;<br>  padding: 0.6rem;<br>}<br><br>.login-container {<br>  margin: 0 auto;<br>  max-width: 410px;<br>  padding: 2rem 1.5rem;<br>  border-radius: 0.5rem;<br>  background: #fff;<br>  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);<br>}<br><br>.login-container .form-title {<br>  text-align: center;<br>  font-size: 1.37rem;<br>  font-weight: 600;<br>  margin-bottom: 1.87rem;<br>}<br><br>.login-container .social-login {<br>  display: flex;<br>  gap: 1.31rem;<br>}<br><br>.social-login .social-button {<br>  display: flex;<br>  gap: 0.81rem;<br>  width: 100%;<br>  font-size: 1rem;<br>  font-weight: 500;<br>  cursor: pointer;<br>  padding: 0.75rem 0;<br>  border-radius: 0.31rem;<br>  align-items: center;<br>  justify-content: center;<br>  background: #F9F8FF;<br>  border: 1px solid #D5CBFF;<br>  transition: 0.3s ease;<br>}<br><br>.social-login .social-button:hover {<br>  border-color: #5F41E4;<br>  background: #f1eff9;<br>}<br><br>.social-login .social-button .social-icon {<br>  width: 23px;<br>}<br><br>.login-container .separator {<br>  position: relative;<br>  margin: 1.5rem 0;<br>  text-align: center;<br>  background: #fff;<br>}<br><br>.login-container .separator span {<br>  z-index: 1;<br>  font-weight: 500;<br>  color: #6652BE;<br>  position: relative;<br>  background: #fff;<br>  font-size: 1.06rem;<br>  padding: 0 0.9rem;<br>}<br><br>.login-container .separator::after {<br>  content: &quot;&quot;;<br>  position: absolute;<br>  left: 0;<br>  top: 50%;<br>  height: 1px;<br>  width: 100%;<br>  background: #bfb3f2;<br>}<br><br>.login-form .input-wrapper {<br>  height: 54px;<br>  width: 100%;<br>  position: relative;<br>  margin-bottom: 1.5rem;<br>}<br><br>.login-form .input-field {<br>  width: 100%;<br>  height: 100%;<br>  outline: none;<br>  font-size: 1.06rem;<br>  border-radius: 0.31rem;<br>  border: 1px solid #bfb3f2;<br>  padding: 0px 1.25rem 0 3.12rem;<br>  transition: 0.2s ease;<br>}<br><br>.login-form .input-field:focus {<br>  border-color: #5F41E4;<br>}<br><br>.login-form .input-field::placeholder {<br>  color: #9284c8;<br>}<br><br>.login-form .input-wrapper i {<br>  position: absolute;<br>  top: 50%;<br>  height: 100%;<br>  display: flex;<br>  color: #a395e0;<br>  align-items: center;<br>  transform: translateY(-50%);<br>  transition: 0.2s ease;<br>}<br><br>.login-form .input-wrapper i:not(.eye-icon) {<br>  left: 0.93rem;<br>  pointer-events: none;<br>}<br><br>.login-form .input-field:focus ~ i:not(.eye-icon) {<br>  color: #5F41E4;<br>}<br><br>.login-form .input-wrapper i.eye-icon {<br>  display: none;<br>  right: 0.93rem;<br>  color: #917DE8;<br>  cursor: pointer;<br>  font-size: 1.25rem;<br>}<br><br>.login-form .input-wrapper .input-field:valid ~ .eye-icon {<br>  display: flex;<br>}<br><br>.login-form .forgot-password-link {<br>  display: block;<br>  width:fit-content;<br>  margin-top: -0.44rem;<br>}<br><br>.login-form .login-button {<br>  border: none;<br>  outline: none;<br>  width: 100%;<br>  height: 54px;<br>  color: #fff;<br>  font-size: 1.125rem;<br>  font-weight: 500;<br>  cursor: pointer;<br>  margin-top: 2.19rem;<br>  border-radius: 0.31rem;<br>  background: #5F41E4;<br>  transition: 0.3s ease;<br>}<br><br>.login-form .login-button:hover {<br>  background: #4320df;<br>}<br><br>.login-container .signup-prompt {<br>  text-align: center;<br>  font-size: 1.06rem;<br>  font-weight: 500;<br>  margin: 1.75rem 0 0.31rem;<br>}<br><br>.login-container a {<br>  color: #5F41E4;<br>  font-weight: 500;<br>  text-decoration: none;<br>}<br><br>.login-container a:hover {<br>  text-decoration: underline;<br>}</pre><h3>Creating the Components</h3><p>Within the <strong>src </strong>directory of your project, organize your files by creating a “components” folder. Inside the components folder, create the following files:</p><h3>Adding the Codes</h3><p>Add the respective code to each newly created file. These files define the layout and functionality of the Login Form.</p><p>In components/SocialLogin.jsx, add the code to render social login buttons for Google and Apple.</p><pre>const SocialLogin = () =&gt; {<br>  return (<br>    &lt;div className=&quot;social-login&quot;&gt;<br>      &lt;button className=&quot;social-button&quot;&gt;<br>        &lt;img src=&quot;google.svg&quot; alt=&quot;Google&quot; className=&quot;social-icon&quot; /&gt;<br>        Google<br>      &lt;/button&gt;<br>      &lt;button className=&quot;social-button&quot;&gt;<br>        &lt;img src=&quot;apple.svg&quot; alt=&quot;Apple&quot; className=&quot;social-icon&quot; /&gt;<br>        Apple<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default SocialLogin;</pre><p>In components/InputField.jsx, add the code for email and password fields, and the functionality to toggle password visibility.</p><pre>import { useState } from &quot;react&quot;;<br><br>const InputField = ({ type, placeholder, icon }) =&gt; {<br>  // State to toggle password visibility<br>  const [isPasswordShown, setIsPasswordShown] = useState(false);<br><br>  return (<br>    &lt;div className=&quot;input-wrapper&quot;&gt;<br>      &lt;input<br>        type={isPasswordShown ? &#39;text&#39; : type}<br>        placeholder={placeholder}<br>        className=&quot;input-field&quot;<br>        required<br>      /&gt;<br>      &lt;i className=&quot;material-symbols-rounded&quot;&gt;{icon}&lt;/i&gt;<br>      {type === &#39;password&#39; &amp;&amp; (<br>        &lt;i onClick={() =&gt; setIsPasswordShown(prevState =&gt; !prevState)} className=&quot;material-symbols-rounded eye-icon&quot;&gt;<br>          {isPasswordShown ? &#39;visibility&#39; : &#39;visibility_off&#39;}<br>        &lt;/i&gt;<br>      )}<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default InputField;</pre><p>Finally, update the content of src/App.jsx with the provided code. It imports and uses these components to complete your login form.</p><pre>import SocialLogin from &quot;./components/SocialLogin&quot;;<br>import InputField from &quot;./components/InputField&quot;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div className=&quot;login-container&quot;&gt;<br>      &lt;h2 className=&quot;form-title&quot;&gt;Log in with&lt;/h2&gt;<br>      &lt;SocialLogin /&gt;<br><br>      &lt;p className=&quot;separator&quot;&gt;&lt;span&gt;or&lt;/span&gt;&lt;/p&gt;<br><br>      &lt;form action=&quot;#&quot; className=&quot;login-form&quot;&gt;<br>        &lt;InputField type=&quot;email&quot; placeholder=&quot;Email address&quot; icon=&quot;mail&quot; /&gt;<br>        &lt;InputField type=&quot;password&quot; placeholder=&quot;Password&quot; icon=&quot;lock&quot; /&gt;<br><br>        &lt;a href=&quot;#&quot; className=&quot;forgot-password-link&quot;&gt;Forgot password?&lt;/a&gt;<br>        &lt;button type=&quot;submit&quot; className=&quot;login-button&quot;&gt;Log In&lt;/button&gt;<br>      &lt;/form&gt;<br><br>      &lt;p className=&quot;signup-prompt&quot;&gt;<br>        Don&amp;apos;t have an account? &lt;a href=&quot;#&quot; className=&quot;signup-link&quot;&gt;Sign up&lt;/a&gt;<br>      &lt;/p&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default App;</pre><p>That’s it! If you’ve completed all the steps, you should now see your Login Form project in your browser. You can test it by entering an email and password, toggling password visibility, and trying out the social login options.</p><h3>Conclusion and final words</h3><p>Congratulations! You’ve successfully created a functional and stylish login form using ReactJS and CSS. With this project, you’ve practiced managing form states, adding user-friendly features, and applying CSS to create a beautiful look.</p><p>This is just the beginning! Consider expanding your form with additional features or integrating it with a backend for real-world use. For more inspiration, there are many other <a href="https://www.codingnepalweb.com/category/login-form/">login form templates</a> available on this website.</p><p>If you encounter any problems while creating your ReactJS login form, you can download the source code files for this project for free by clicking the “Download” button. You can also view a live demo of it by clicking the “View Live” button.</p><p><a href="https://www.codingnepalweb.com/demos/create-login-form-reactjs-css/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/create-login-form-reactjs-css/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/create-login-form-reactjs-css/"><em>https://www.codingnepalweb.com</em></a><em> on July 22, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc34f1ba0bb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Build A YouTube Clone in HTML CSS and JavaScript]]></title>
            <link>https://codingnepal.medium.com/how-to-build-a-youtube-clone-in-html-css-and-javascript-1de0d243980a?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/1de0d243980a</guid>
            <category><![CDATA[website]]></category>
            <category><![CDATA[youtube]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Fri, 12 Jul 2024 10:12:58 GMT</pubDate>
            <atom:updated>2024-07-16T17:35:46.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="How to Build A YouTube Clone in HTML CSS and JavaScript" src="https://cdn-images-1.medium.com/max/1024/0*UxKoxf8oJjWTdK9s.jpg" /><figcaption>How to Build A YouTube Clone in HTML CSS and JavaScript</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/build-youtube-homepage-clone-html-css/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Building a <a href="https://www.codingnepalweb.com/create-youtube-homepage-tailwind-reactjs/">YouTube clone</a> is a fun and educational project that can greatly boost your front-end development skills. This project lets you work with a familiar design, giving you hands-on experience with essential web technologies like HTML, CSS, and JavaScript. By creating this clone, you’ll gain insights into how modern websites are structured and styled.</p><p>In this blog post, I’ll guide you through creating a responsive YouTube clone using <a href="https://www.codingnepalweb.com/category/html-and-css/">HTML, CSS</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a>. We’ll replicate key features of YouTube’s homepage design, including a navbar with search, a grid layout for videos, a collapsible sidebar, and options for dark or light themes.</p><p>As you work on this project, you’ll learn how to structure and style <a href="https://www.codingnepalweb.com/category/website-design/">websites</a> effectively to ensure they look great on all devices.</p><h3>Why Build a YouTube Clone in HTML CSS &amp; JavaScript?</h3><p>By building this YouTube clone project using HTML, CSS, and JavaScript, you can gain the following skills:</p><ul><li><strong>Master HTML and CSS:</strong> Get hands-on experience structuring and styling professional-looking webpages.</li><li><strong>Responsive Design:</strong> Learn how to use media queries and flexible layouts to make your site look great on any device.</li><li><strong>JavaScript Basics:</strong> Add interactive elements with JavaScript, such as a collapsible sidebar and theme toggling.</li><li><strong>Portfolio Piece:</strong> A recognizable project like a YouTube clone can impress potential employers and showcase your skills.</li></ul><h3>Video Tutorial to Build YouTube Clone in HTML CSS &amp; JavaScript</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FADhiSLUEQas%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DADhiSLUEQas&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FADhiSLUEQas%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/88a38aba3aa56782f70b04b39962bf6d/href">https://medium.com/media/88a38aba3aa56782f70b04b39962bf6d/href</a></iframe><p>The YouTube video above is a great resource if you prefer video tutorials. It explains each line of code and provides comments to make building your YouTube clone project easy to follow. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Steps to Build YouTube Clone in HTML &amp; JavaScript</h3><p>To build a responsive YouTube clone using HTML, CSS, and JavaScript, follow these simple step-by-step instructions:</p><ul><li>Create a folder with any name you like, e.g., youtube-clone.</li><li>Inside it, create the necessary files: index.html, style.css, and script.js.</li><li>Download the <a href="https://drive.google.com/drive/folders/10WhkK0tL4EknAY-0S3Jupe9V0uHQIXQY">Images</a> folder and put it in your project directory. This folder contains all the images you’ll need for this YouTube clone. Alternatively, you can also use your images.</li></ul><p>In your index.html file, add the essential HTML markup with different semantic tags and content to structure your YouTube homepage layout.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;!-- Coding By CodingNepal - www.codingnepalweb.com --&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;YouTube Homepage Clone | CodingNepal&lt;/title&gt;<br>  &lt;!-- Linking Unicons For Icons --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://unicons.iconscout.com/release/v4.0.8/css/line.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body class=&quot;sidebar-hidden&quot;&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;!-- Header / Navbar --&gt;<br>    &lt;header&gt;<br>      &lt;nav class=&quot;navbar&quot;&gt;<br>        &lt;div class=&quot;nav-section nav-left&quot;&gt;<br>          &lt;button class=&quot;nav-button menu-button&quot;&gt;<br>            &lt;i class=&quot;uil uil-bars&quot;&gt;&lt;/i&gt;<br>          &lt;/button&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;nav-logo&quot;&gt;<br>            &lt;img src=&quot;images/logo.png&quot; alt=&quot;Logo&quot; class=&quot;logo-image&quot;&gt;<br>            &lt;h2 class=&quot;logo-text&quot;&gt;CnTube&lt;/h2&gt;<br>          &lt;/a&gt;<br>        &lt;/div&gt;<br>        <br>        &lt;div class=&quot;nav-section nav-center&quot;&gt;<br>          &lt;form action=&quot;#&quot; class=&quot;search-form&quot;&gt;<br>            &lt;input type=&quot;search&quot; placeholder=&quot;Search&quot; class=&quot;search-input&quot; required&gt;<br>            &lt;button class=&quot;nav-button search-button&quot;&gt;<br>              &lt;i class=&quot;uil uil-search&quot;&gt;&lt;/i&gt;<br>            &lt;/button&gt;<br>          &lt;/form&gt;<br>          &lt;button class=&quot;nav-button mic-button&quot;&gt;<br>            &lt;i class=&quot;uil uil-microphone&quot;&gt;&lt;/i&gt;<br>          &lt;/button&gt;<br>        &lt;/div&gt;<br>        <br>        &lt;div class=&quot;nav-section nav-right&quot;&gt;<br>          &lt;button class=&quot;nav-button search-button&quot;&gt;<br>            &lt;i class=&quot;uil uil-search&quot;&gt;&lt;/i&gt;<br>          &lt;/button&gt;<br>          &lt;button class=&quot;nav-button theme-button&quot;&gt;<br>            &lt;i class=&quot;uil uil-moon&quot;&gt;&lt;/i&gt;<br>          &lt;/button&gt;<br>          &lt;img src=&quot;images/user.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>        &lt;/div&gt;<br>      &lt;/nav&gt;<br>    &lt;/header&gt;<br>    <br>    &lt;!-- Main Layout --&gt;<br>    &lt;main class=&quot;main-layout&quot;&gt;<br>      &lt;div class=&quot;screen-overlay&quot;&gt;&lt;/div&gt;<br><br>      &lt;!-- Sidebar --&gt;<br>      &lt;aside class=&quot;sidebar&quot;&gt;<br>        &lt;div class=&quot;nav-section nav-left&quot;&gt;<br>          &lt;button class=&quot;nav-button menu-button&quot;&gt;<br>            &lt;i class=&quot;uil uil-bars&quot;&gt;&lt;/i&gt;<br>          &lt;/button&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;nav-logo&quot;&gt;<br>            &lt;img src=&quot;images/logo.png&quot; alt=&quot;Logo&quot; class=&quot;logo-image&quot;&gt;<br>            &lt;h2 class=&quot;logo-text&quot;&gt;CnTube&lt;/h2&gt;<br>          &lt;/a&gt;<br>        &lt;/div&gt;<br>  <br>        &lt;div class=&quot;links-container&quot;&gt;<br>          &lt;div class=&quot;link-section&quot;&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-estate&quot;&gt;&lt;/i&gt; Home<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-video&quot;&gt;&lt;/i&gt; Shorts<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-tv-retro&quot;&gt;&lt;/i&gt; Subscriptions<br>            &lt;/a&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;section-separator&quot;&gt;&lt;/div&gt;<br>  <br>          &lt;div class=&quot;link-section&quot;&gt;<br>            &lt;h4 class=&quot;section-title&quot;&gt;You&lt;/h4&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-user-square&quot;&gt;&lt;/i&gt; Your channel<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-history&quot;&gt;&lt;/i&gt; History<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-clock&quot;&gt;&lt;/i&gt; Watch later<br>            &lt;/a&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;section-separator&quot;&gt;&lt;/div&gt;<br>          <br>          &lt;div class=&quot;link-section&quot;&gt;<br>            &lt;h4 class=&quot;section-title&quot;&gt;Explore&lt;/h4&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-fire&quot;&gt;&lt;/i&gt; Trending<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-music&quot;&gt;&lt;/i&gt; Music<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-basketball&quot;&gt;&lt;/i&gt; Gaming<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-trophy&quot;&gt;&lt;/i&gt; Sports<br>            &lt;/a&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;section-separator&quot;&gt;&lt;/div&gt;<br>  <br>          &lt;div class=&quot;link-section&quot;&gt;<br>            &lt;h4 class=&quot;section-title&quot;&gt;More from YouTube&lt;/h4&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-shield-plus&quot;&gt;&lt;/i&gt; YouTube Plus<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-headphones-alt&quot;&gt;&lt;/i&gt; YouTube Music<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-airplay&quot;&gt;&lt;/i&gt; YouTube Kids<br>            &lt;/a&gt;<br>          &lt;/div&gt;<br>          &lt;div class=&quot;section-separator&quot;&gt;&lt;/div&gt;<br>  <br>          &lt;div class=&quot;link-section&quot;&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-setting&quot;&gt;&lt;/i&gt; Settings<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-file-medical-alt&quot;&gt;&lt;/i&gt; Report<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-question-circle&quot;&gt;&lt;/i&gt; Help<br>            &lt;/a&gt;<br>            &lt;a href=&quot;#&quot; class=&quot;link-item&quot;&gt;<br>              &lt;i class=&quot;uil uil-exclamation-triangle&quot;&gt;&lt;/i&gt; Feedback<br>            &lt;/a&gt;<br>          &lt;/div&gt;<br>        &lt;/div&gt;<br>      &lt;/aside&gt;<br>  <br>      &lt;div class=&quot;content-wrapper&quot;&gt;<br>        &lt;!-- Category List --&gt;<br>        &lt;div class=&quot;category-list&quot;&gt;<br>          &lt;button class=&quot;category-button active&quot;&gt;All&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Website&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Music&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Gaming&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Node.js&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;JavaScript&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;React.js&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;TypeScript&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Coding&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Next.js&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Data analysis&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Web design&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;HTML&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Tailwind&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;CSS&lt;/button&gt;<br>          &lt;button class=&quot;category-button&quot;&gt;Express.js&lt;/button&gt;<br>        &lt;/div&gt;<br>        <br>        &lt;!-- Video List --&gt;<br>        &lt;div class=&quot;video-list&quot;&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/OORUHkgg4IM/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;10:03&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Top 10 Easy To Create JavaScript Games For Beginners&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;27K Views • 4 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/qOO6lVMhmGc/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;23:45&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/uITV5E7auiZMDD_BwhVRJMHXXY6qQc0GqBgVyP5LWYTmeRlUP2Dc945UlIbODvztd96ReOts=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;How to make Responsive Card Slider in HTML CSS &amp; JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingLab&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;42K Views • 1 year ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/YEloDYy3DTg/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;29:43&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Create A Responsive Website with Login &amp; Registration Form in HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;68K Views • 9 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/hSSdc8vKP1I/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;38:45&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Build Hangman Game in HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;57K Views • 11 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/coj-l7IrwGU/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;19:27&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;How to Make Chrome Extension in HTML CSS &amp; JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;24K Views • 1 year ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/6QE8dXq9SOE/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;16:24&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Create A Draggable Card Slider in HTML CSS and Vanilla JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;14.2K Views • 4 days ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/q4RgxiDM6v0/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;37:13&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/uITV5E7auiZMDD_BwhVRJMHXXY6qQc0GqBgVyP5LWYTmeRlUP2Dc945UlIbODvztd96ReOts=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;How to make Responsive Image Slider in HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingLab&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;1M Views • 1 year ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/DLs1X9T1GcY/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;9:27&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Create Text Typing Effect in HTML CSS &amp; Vanilla JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;17K Views • 10 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/PsNaoDhzQm0/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;25:27&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Create Responsive Image Slider in HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;157K Views • 9 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/20Qb7pNMv-4/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;12:24&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/uITV5E7auiZMDD_BwhVRJMHXXY6qQc0GqBgVyP5LWYTmeRlUP2Dc945UlIbODvztd96ReOts=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Make A Flipping Card UI Design in HTML &amp; CSS&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingLab&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;85K Views • 2 months ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/_RSaI2CxlXU/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;30:20&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Easy way to do Multiple File Uploading using HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;7.4K Views • 3 weeks ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/cHkN82X3KNU/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;11:13&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/uITV5E7auiZMDD_BwhVRJMHXXY6qQc0GqBgVyP5LWYTmeRlUP2Dc945UlIbODvztd96ReOts=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Build A Responsive Calculator in HTML CSS &amp; JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingLab&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;30K Views • 2 years ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/0_Lwi5ucGwM/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;39:43&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/DRtVBjk2Noax94hHqr8yCcEjhNUhHRvyzBE3qS9WWilnE1-uQQNVnQd8mdG9h_IvNZCRApZSQw=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Build A Currency Converter using ReactJS&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingNepal&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;7.2K • 2 weeks ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>          &lt;a href=&quot;#&quot; class=&quot;video-card&quot;&gt;<br>            &lt;div class=&quot;thumbnail-container&quot;&gt;<br>              &lt;img src=&quot;https://i.ytimg.com/vi/AyV954yKRSw/maxresdefault.jpg&quot; alt=&quot;Video Thumbnail&quot; class=&quot;thumbnail&quot;&gt;<br>              &lt;p class=&quot;duration&quot;&gt;1:37:13&lt;/p&gt;<br>            &lt;/div&gt;<br>            &lt;div class=&quot;video-info&quot;&gt;<br>              &lt;img src=&quot;https://yt3.googleusercontent.com/uITV5E7auiZMDD_BwhVRJMHXXY6qQc0GqBgVyP5LWYTmeRlUP2Dc945UlIbODvztd96ReOts=s176-c-k-c0x00ffffff-no-rj&quot; alt=&quot;Channel Logo&quot; class=&quot;icon&quot;&gt;<br>              &lt;div class=&quot;video-details&quot;&gt;<br>                &lt;h2 class=&quot;title&quot;&gt;Responsive Admin Dashboard Panel in HTML CSS and JavaScript&lt;/h2&gt;<br>                &lt;p class=&quot;channel-name&quot;&gt;CodingLab&lt;/p&gt;<br>                &lt;p class=&quot;views&quot;&gt;161K Views • 1 year ago&lt;/p&gt;<br>              &lt;/div&gt;<br>            &lt;/div&gt;<br>          &lt;/a&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/main&gt;<br>  &lt;/div&gt;<br><br>  &lt;!-- Linking custom script --&gt;<br>  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In your style.css file, add CSS code to style your YouTube homepage, and give it a responsive and YouTube-like design. Experiment with different CSS properties such as colors, fonts, and backgrounds to make your clone more attractive.</p><pre>/* Importing Google Font - Open Sans */<br>@import url(https://medium.com/&quot;https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&amp;display=swap&quot;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Open Sans&quot;, sans-serif;<br>}<br><br>/* Color variables for light theme */<br>:root {<br>  --white-color: #fff;<br>  --black-color: #000;<br>  --light-white-color: #f0f0f0;<br>  --light-gray-color: #e5e5e5;<br>  --border-color: #ccc;<br>  --primary-color: #3b82f6;<br>  --secondary-color: #404040;<br>  --overlay-dark-color: rgba(0, 0, 0, 0.6);<br>}<br><br>/* Color variables for dark theme */<br>.dark-mode {<br>  --white-color: #171717;<br>  --black-color: #d4d4d4;<br>  --light-white-color: #333;<br>  --light-gray-color: #404040;<br>  --border-color: #808080;<br>  --secondary-color: #d4d4d4;<br>}<br><br>body {<br>  background: var(--white-color);<br>}<br><br>.container {<br>  display: flex;<br>  overflow: hidden;<br>  max-height: 100vh;<br>  flex-direction: column;<br>}<br><br>header, .sidebar .nav-left, .category-list {<br>  position: sticky;<br>  top: 0;<br>  z-index: 10;<br>  background: var(--white-color);<br>}<br><br>.navbar {<br>  display: flex;<br>  gap: 2rem;<br>  align-items: center;<br>  padding: 0.5rem 1rem;<br>  justify-content: space-between;<br>}<br><br>:where(.navbar, .sidebar) .nav-section {<br>  gap: 1rem;<br>}<br><br>:where(.navbar, .sidebar) :where(.nav-section, .nav-logo, .search-form) {<br>  display: flex;<br>  align-items: center;<br>}<br><br>:where(.navbar, .sidebar) :where(.logo-image, .user-image) {<br>  width: 32px;<br>  cursor: pointer;<br>  border-radius: 50%;<br>}<br><br>:where(.navbar, .sidebar) .nav-section .nav-button {<br>  border: none;<br>  height: 40px;<br>  width: 40px;<br>  cursor: pointer;<br>  background: none;<br>  border-radius: 50%;<br>}<br><br>:where(.navbar, .sidebar) .nav-section .nav-button:hover {<br>  background: var(--light-gray-color) !important;<br>}<br><br>:where(.navbar, .sidebar) .nav-button i {<br>  font-size: 1.5rem;<br>  display: flex;<br>  color: var(--black-color);<br>  align-items: center;<br>  justify-content: center;<br>}<br><br>:where(.navbar, .sidebar) .nav-logo {<br>  display: flex;<br>  gap: 0.5rem;<br>  text-decoration: none;<br>}<br><br>:where(.navbar, .sidebar) .nav-logo .logo-text {<br>  color: var(--black-color);<br>  font-size: 1.25rem;<br>}<br><br>.navbar .nav-center {<br>  gap: 0.5rem;<br>  width: 100%;<br>  display: flex;<br>  justify-content: center;<br>}<br><br>.navbar .search-form {<br>  flex: 1;<br>  height: 40px;<br>  max-width: 550px;<br>}<br><br>.navbar .search-form .search-input {<br>  width: 100%;<br>  height: 100%;<br>  font-size: 1rem;<br>  padding: 0 1rem;<br>  outline: none;<br>  color: var(--black-color);<br>  background: var(--white-color);<br>  border-radius: 3.1rem 0 0 3.1rem;<br>  border: 1px solid var(--border-color);<br>}<br><br>.navbar .search-form .search-input:focus {<br>  border-color: var(--primary-color);<br>}<br><br>.navbar .search-form .search-button {<br>  height: 40px;<br>  width: auto;<br>  padding: 0 1.25rem;<br>  border-radius: 0 3.1rem 3.1rem 0;<br>  border: 1px solid var(--border-color);<br>  border-left: 0;<br>}<br><br>.navbar .nav-center .mic-button {<br>  background: var(--light-white-color);<br>}<br><br>.navbar .nav-right .search-button {<br>  display: none;<br>}<br><br>.main-layout {<br>  display: flex;<br>  overflow-y: auto;<br>  scrollbar-color: #a6a6a6 transparent;<br>}<br><br>.main-layout .sidebar {<br>  width: 280px;<br>  overflow: hidden;<br>  padding: 0 0.7rem 0;<br>  background: var(--white-color);<br>}<br><br>.main-layout .sidebar .nav-left {<br>  display: none;<br>  padding: 0.5rem 0.3rem;<br>}<br><br>body.sidebar-hidden .main-layout .sidebar {<br>  width: 0;<br>  padding: 0;<br>}<br><br>.sidebar .links-container {<br>  padding: 1rem 0 2rem;<br>  overflow-y: auto;<br>  height: calc(100vh - 60px);<br>  scrollbar-width: thin;<br>  scrollbar-color: transparent transparent;<br>}<br><br>.sidebar .links-container:hover {<br>  scrollbar-color: #a6a6a6 transparent;<br>}<br><br>.sidebar .link-section .link-item {<br>  display: flex;<br>  color: var(--black-color);<br>  white-space: nowrap;<br>  align-items: center;<br>  font-size: 0.938rem;<br>  padding: 0.37rem 0.75rem;<br>  margin-bottom: 0.25rem;<br>  border-radius: 0.5rem;<br>  text-decoration: none;<br>}<br><br>.sidebar .link-section .link-item:hover {<br>  background: var(--light-gray-color);<br>}<br><br>.sidebar .link-section .link-item i {<br>  font-size: 1.4rem;<br>  margin-right: 0.625rem;<br>}<br><br>.sidebar .link-section .section-title {<br>  color: var(--black-color);<br>  font-weight: 600;<br>  font-size: 0.938rem;<br>  margin: 1rem 0 0.5rem 0.5rem;<br>}<br><br>.sidebar .section-separator {<br>  height: 1px;<br>  margin: 0.64rem 0;<br>  /* background: var(--light-gray-color); */<br>  background-color: var(--border-color);<br>}<br><br>.main-layout .content-wrapper {<br>  padding: 0 1rem;<br>  overflow-x: hidden;<br>  width: 100%;<br>}<br><br>.content-wrapper .category-list {<br>  display: flex;<br>  overflow-x: auto;<br>  gap: 0.75rem;<br>  padding: 0.75rem 0 0.7rem;<br>  scrollbar-width: none;<br>}<br><br>.category-list .category-button {<br>  border: none;<br>  cursor: pointer;<br>  font-weight: 500;<br>  font-size: 0.94rem;<br>  border-radius: 0.5rem;<br>  white-space: nowrap;<br>  color: var(--black-color);<br>  padding: 0.4rem 0.75rem;<br>  background: var(--light-gray-color);<br>}<br><br>.category-list .category-button.active {<br>  color: var(--white-color);<br>  background: var(--black-color);<br>  pointer-events: none;<br>}<br><br>.dark-mode .category-list .category-button.active {<br>  filter: brightness(120%);<br>}<br><br>.category-list .category-button:not(.active):hover {<br>  background: var(--border-color);<br>}<br><br>.content-wrapper .video-list {<br>  display: grid; <br>  gap: 1rem;<br>  padding: 1.25rem 0 4rem;<br>  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));<br>}<br><br>.video-list .video-card {<br>  text-decoration: none;<br>}<br><br>.video-list .video-card .thumbnail-container {<br>  position: relative;<br>}<br><br>.video-list .video-card .thumbnail {<br>  width: 100%;<br>  object-fit: contain;<br>  border-radius: 0.5rem;<br>  aspect-ratio: 16 / 9;<br>  background: var(--light-white-color);<br>}<br><br>.video-list .video-card .duration {<br>  position: absolute;<br>  right: 0.65rem;<br>  bottom: 0.8rem;<br>  color: #fff;<br>  font-size: 0.875rem;<br>  padding: 0 0.3rem;<br>  border-radius: 0.3rem;<br>  background: var(--overlay-dark-color);<br>}<br><br>.video-list .video-card .video-info {<br>  display: flex;<br>  gap: 0.7rem;<br>  padding: 0.7rem 0.5rem;<br>}<br><br>.video-list .video-card .icon {<br>  width: 36px;<br>  height: 36px;<br>  border-radius: 50%;<br>}<br><br>.video-list .video-card .title {<br>  font-size: 1rem;<br>  color: var(--black-color);<br>  font-weight: 600;<br>  line-height: 1.375;<br>  overflow: hidden;<br>  display: -webkit-box;<br>  -webkit-box-orient: vertical;<br>  -webkit-line-clamp: 2;<br>}<br><br>.video-list .video-card:hover .title {<br>  color: var(--primary-color);<br>}<br><br>.video-list .video-card p {<br>  font-size: 0.875rem;<br>  color: var(--secondary-color);<br>}<br><br>.video-list .video-card .channel-name {<br>  margin: 0.25rem 0 0.15rem;<br>}<br><br>/* Responsive media code for small devices */<br>@media (max-width: 768px) {<br>  .navbar .nav-center {<br>    display: none;<br>  }<br><br>  .navbar .nav-right .search-button {<br>    display: block;<br>  }<br><br>  .main-layout .screen-overlay {<br>    position: absolute;<br>    left: 0;<br>    top: 0;<br>    z-index: 15;<br>    width: 100%;<br>    height: 100vh;<br>    background: var(--overlay-dark-color);<br>    transition: 0.2s ease;<br>  }<br><br>  body.sidebar-hidden .main-layout .screen-overlay {<br>    opacity: 0;<br>    pointer-events: none;<br>  }<br><br>  .main-layout .sidebar {<br>    position: absolute;<br>    left: 0;<br>    top: 0;<br>    z-index: 20;<br>    height: 100vh;<br>    transition: 0.2s ease;<br>  }<br><br>  body.sidebar-hidden .main-layout .sidebar {<br>    left: -280px;<br>  }<br><br>  .main-layout .sidebar .nav-left {<br>    display: flex;<br>  }<br>}</pre><p>In your script.js file, add JavaScript code to make your YouTube homepage interactive with features like a collapsible <a href="https://www.codingnepalweb.com/category/sidebar-menu/">sidebar</a> and theme toggling.</p><pre>const menuButtons = document.querySelectorAll(&quot;.menu-button&quot;);<br>const screenOverlay = document.querySelector(&quot;.main-layout .screen-overlay&quot;);<br>const themeButton = document.querySelector(&quot;.navbar .theme-button i&quot;);<br><br>// Toggle sidebar visibility when menu buttons are clicked<br>menuButtons.forEach(button =&gt; {<br>  button.addEventListener(&quot;click&quot;, () =&gt; {<br>    document.body.classList.toggle(&quot;sidebar-hidden&quot;);<br>  });<br>});<br><br>// Toggle sidebar visibility when screen overlay is clicked<br>screenOverlay.addEventListener(&quot;click&quot;, () =&gt; {<br>  document.body.classList.toggle(&quot;sidebar-hidden&quot;);<br>});<br><br>// Initialize dark mode based on localStorage<br>if (localStorage.getItem(&quot;darkMode&quot;) === &quot;enabled&quot;) {<br>  document.body.classList.add(&quot;dark-mode&quot;);<br>  themeButton.classList.replace(&quot;uil-moon&quot;, &quot;uil-sun&quot;);<br>} else {<br>  themeButton.classList.replace(&quot;uil-sun&quot;, &quot;uil-moon&quot;);<br>}<br><br>// Toggle dark mode when theme button is clicked<br>themeButton.addEventListener(&quot;click&quot;, () =&gt; {<br>  const isDarkMode = document.body.classList.toggle(&quot;dark-mode&quot;);<br>  localStorage.setItem(&quot;darkMode&quot;, isDarkMode ? &quot;enabled&quot; : &quot;disabled&quot;);<br>  themeButton.classList.toggle(&quot;uil-sun&quot;, isDarkMode);<br>  themeButton.classList.toggle(&quot;uil-moon&quot;, !isDarkMode);<br>});<br><br>// Show sidebar on large screens by default<br>if (window.innerWidth &gt;= 768) {<br>  document.body.classList.remove(&quot;sidebar-hidden&quot;);<br>}</pre><p>That’s it! If you’ve added the code correctly, you’re ready to see your YouTube clone project. Open the index.html file in your preferred browser to view the project in action.</p><h3>Conclusion and final words</h3><p>Building a YouTube clone using HTML, CSS, and JavaScript is a rewarding project that enhances your skills in web development. By completing this project, you learned responsive design principles and created an impressive piece for your portfolio.</p><p>For those interested in a similar project using React.js and Tailwind CSS, you can explore my previous blog post on <a href="https://www.codingnepalweb.com/create-youtube-homepage-tailwind-reactjs/">Create YouTube Clone in ReactJS and Tailwind</a>. Whether you follow this approach or stick with HTML, CSS, and JavaScript, building a YouTube clone is a valuable addition to your portfolio and solidifying your understanding of modern web development practices.</p><p>If you encounter any problems while building your YouTube clone, you can download the source code files for this clone project for free by clicking the “Download” button. You can also view a live demo of it by clicking the “View Live” button.</p><p><a href="https://www.codingnepalweb.com/demos/build-youtube-homepage-clone-html-css/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/build-youtube-homepage-clone-html-css/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/build-youtube-homepage-clone-html-css/"><em>https://www.codingnepalweb.com</em></a><em> on July 12, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1de0d243980a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create Responsive Card Slider in HTML CSS & JavaScript]]></title>
            <link>https://codingnepal.medium.com/how-to-create-responsive-card-slider-in-html-css-javascript-1da1f5ddb78e?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/1da1f5ddb78e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[card-slider]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Fri, 05 Jul 2024 09:26:15 GMT</pubDate>
            <atom:updated>2024-07-16T17:36:02.703Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GPtrAnBOBesboUKR.jpg" /><figcaption>How to Create Responsive Card Slider in HTML CSS &amp; JavaScript</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/create-responsive-card-slider-html-javascript/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>You may have seen card or image sliders on different <a href="https://www.codingnepalweb.com/category/website-design/">websites</a>, but have you ever thought about creating your own? Creating this kind of slider is straightforward, especially with SwiperJS — a leading library for modern, touch-friendly, responsive sliders.</p><p>In this blog post, I’ll guide you through creating a Responsive Card Slider using <a href="https://www.codingnepalweb.com/category/html-and-css/">HTML, CSS</a>, and <a href="https://www.codingnepalweb.com/category/javascript/">JavaScript</a> (SwiperJS) and how to make it attractive with the glassmorphism effect. By the end of this post, you’ll have a visually appealing and interactive slider for your website projects or portfolio.</p><p>If you prefer not to use SwiperJS and want to create a slider with vanilla JavaScript, check out this blog post on <a href="https://www.codingnepalweb.com/responsive-image-slider-html-css-javascript/">Responsive Image Slider in HTML CSS &amp; JavaScript</a>. Creating the slider with vanilla JavaScript can help you understand the underlying mechanisms of sliders and enhance your JavaScript skills.</p><h3>Video Tutorial of Responsive Card Slider in HTML CSS &amp; JavaScript</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXxG7vqFecR8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXxG7vqFecR8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FXxG7vqFecR8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/eebbad2c1a244097e5212028176246b1/href">https://medium.com/media/eebbad2c1a244097e5212028176246b1/href</a></iframe><p>If you prefer video tutorials, the YouTube video above is a great resource. It explains each line of code and provides comments to make the process of creating your <a href="https://www.codingnepalweb.com/draggable-card-slider-html-css-javascript/">card slider</a> project easy to follow. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Steps to Create Responsive Card Slider in HTML &amp; JavaScript</h3><p>To create a responsive card slider using HTML, CSS, and JavaScript (SwiperJS), follow these simple step-by-step instructions:</p><ul><li>Create a folder with any name you like, e.g., card-slider.</li><li>Inside it, create the necessary files: index.html, style.css, and script.js.</li><li>Download the <a href="https://codingnepalweb.com/custom-projects/card-slider-images-24-07-05.zip">Images</a> folder and put it in your project directory. This folder contains all the images you’ll need for this card slider. Alternatively, you can also use your images.</li></ul><p>In your index.html file, add the essential HTML markup with different semantic tags and SwiperJS CDN links to create the card slider layout.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;!-- Coding By CodingNepal - www.codingnepalweb.com --&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;Card Slider HTML and CSS | CodingNepal&lt;/title&gt;<br>  &lt;!-- Linking SwiperJS CSS --&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css&quot;&gt;<br>  &lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div class=&quot;container swiper&quot;&gt;<br>    &lt;div class=&quot;slider-wrapper&quot;&gt;<br>      &lt;div class=&quot;card-list swiper-wrapper&quot;&gt;<br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-1.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;James Wilson&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Software Developer&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-2.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;Sarah Johnson&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Graphic Designer&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-3.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;Michael Brown&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Project Manager&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-4.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;Emily Davis&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Marketing Specialist&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-5.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;Christopher Garcia&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Data Scientist&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br><br>        &lt;div class=&quot;card-item swiper-slide&quot;&gt;<br>          &lt;img src=&quot;images/img-6.jpg&quot; alt=&quot;User Image&quot; class=&quot;user-image&quot;&gt;<br>          &lt;h2 class=&quot;user-name&quot;&gt;Richard Wilson&lt;/h2&gt;<br>          &lt;p class=&quot;user-profession&quot;&gt;Product Designer&lt;/p&gt;<br>          &lt;button class=&quot;message-button&quot;&gt;Message&lt;/button&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br><br>      &lt;div class=&quot;swiper-pagination&quot;&gt;&lt;/div&gt;<br>      &lt;div class=&quot;swiper-slide-button swiper-button-prev&quot;&gt;&lt;/div&gt;<br>      &lt;div class=&quot;swiper-slide-button swiper-button-next&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br><br>  &lt;!-- Linking SwiperJS script --&gt;<br>  &lt;script src=&quot;https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js&quot;&gt;&lt;/script&gt;<br><br>  &lt;!-- Linking custom script --&gt;<br>  &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>In your style.css file, style your card slider, and give it a sleek and modern glassmorphism effect. Experiment with different CSS properties such as colors, fonts, and backgrounds to make your slider more attractive.</p><pre>/* Importing Google Font - Montserrat */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Montserrat&quot;, sans-serif;<br>}<br><br>body {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  min-height: 100vh;<br>  background: url(https://medium.com/&quot;images/bg.jpg&quot;) #030728 no-repeat center;<br>}<br><br>.slider-wrapper {<br>  overflow: hidden;<br>  max-width: 1200px;<br>  margin: 0 70px 55px;<br>}<br><br>.card-list .card-item {<br>  height: auto;<br>  color: #fff;<br>  user-select: none;<br>  padding: 35px;<br>  display: flex;<br>  flex-direction: column;<br>  align-items: center;<br>  justify-content: center;<br>  border-radius: 10px;<br>  backdrop-filter: blur(30px);<br>  background: rgba(255, 255, 255, 0.2);<br>  border: 1px solid rgba(255, 255, 255, 0.5);<br>}<br><br>.card-list .card-item .user-image {<br>  width: 150px;<br>  height: 150px;<br>  border-radius: 50%;<br>  margin-bottom: 40px;<br>  border: 3px solid #fff;<br>  padding: 4px;<br>}<br><br>.card-list .card-item .user-profession {<br>  font-size: 1.15rem;<br>  color: #e3e3e3;<br>  font-weight: 500;<br>  margin: 14px 0 40px;<br>}<br><br>.card-list .card-item .message-button {<br>  font-size: 1.25rem;<br>  padding: 10px 35px;<br>  color: #030728;<br>  border-radius: 6px;<br>  font-weight: 500;<br>  cursor: pointer;<br>  background: #fff;<br>  border: 1px solid transparent;<br>  transition: 0.2s ease;<br>}<br><br>.card-list .card-item .message-button:hover {<br>  background: rgba(255, 255, 255, 0.1);<br>  border: 1px solid #fff;<br>  color: #fff;<br>}<br><br>.slider-wrapper .swiper-pagination-bullet {<br>  background: #fff;<br>  height: 13px;<br>  width: 13px;<br>  opacity: 0.5;<br>}<br><br>.slider-wrapper .swiper-pagination-bullet-active {<br>  opacity: 1;<br>}<br><br>.slider-wrapper .swiper-slide-button {<br>  color: #fff;<br>  margin-top: -55px;<br>  transition: 0.2s ease;<br>}<br><br>.slider-wrapper .swiper-slide-button:hover {<br>  color: #4658ff;<br>}<br><br>@media (max-width: 768px) {<br>  .slider-wrapper {<br>    margin: 0 10px 40px;<br>  }<br><br>  .slider-wrapper .swiper-slide-button {<br>    display: none;<br>  }<br>}</pre><p>In your script.js file, add JavaScript code to initialize SwiperJS, and make your card slider functional.</p><pre>const swiper = new Swiper(&#39;.slider-wrapper&#39;, {<br>  loop: true,<br>  grabCursor: true,<br>  spaceBetween: 30,<br><br>  // Pagination bullets<br>  pagination: {<br>    el: &#39;.swiper-pagination&#39;,<br>    clickable: true,<br>    dynamicBullets: true<br>  },<br><br>  // Navigation arrows<br>  navigation: {<br>    nextEl: &#39;.swiper-button-next&#39;,<br>    prevEl: &#39;.swiper-button-prev&#39;,<br>  },<br><br>  // Responsive breakpoints<br>  breakpoints: {<br>    0: {<br>      slidesPerView: 1<br>    },<br>    768: {<br>      slidesPerView: 2<br>    },<br>    1024: {<br>      slidesPerView: 3<br>    }<br>  }<br>});</pre><p>That’s it! If you’ve added the code correctly, you’re ready to see your card slider. Open the index.html file in your preferred browser to view the slider in action.</p><h3>Conclusion and final words</h3><p>By following these steps, you have created a responsive card slider using HTML, CSS, and JavaScript (SwiperJS). This slider project not only helps you understand the basics of web development but also demonstrates the power of using libraries to create interactive and useful web components easily.</p><p>Feel free to customize the slider and experiment with different settings to make it your own. For more customization details, you can check out the <a href="https://swiperjs.com/get-started">SwiperJS</a> documentation.</p><p>For additional inspiration, check out my blog post on <a href="https://www.codingnepalweb.com/best-javascript-image-sliders-with-code/">10+ Best Image Sliders with Source Codes</a>. Among these sliders, some utilize SwiperJS, some use Owl Carousel, and others are created with vanilla JavaScript, providing a wide range of examples to learn from.</p><p>If you encounter any problems while creating your slider, you can download the source code files for this project for free by clicking the “Download” button. You can also view a live demo of it by clicking the “View Live” button.</p><p><a href="https://www.codingnepalweb.com/demos/create-responsive-card-slider-html-javascript/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/create-responsive-card-slider-html-javascript/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/create-responsive-card-slider-html-javascript/"><em>https://www.codingnepalweb.com</em></a><em> on July 5, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1da1f5ddb78e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build A Currency Converter in ReactJS | Best Beginner ReactJS Project]]></title>
            <link>https://codingnepal.medium.com/build-a-currency-converter-in-reactjs-best-beginner-reactjs-project-0cb6d7e04303?source=rss-95c702a58378------2</link>
            <guid isPermaLink="false">https://medium.com/p/0cb6d7e04303</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[react-js-tutorials]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <dc:creator><![CDATA[CodingNepal]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 15:34:21 GMT</pubDate>
            <atom:updated>2024-07-16T17:36:22.398Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H0lC97xigGOnp6j8.jpg" /><figcaption>Build A Currency Converter in ReactJS | Best Beginner ReactJS Project</figcaption></figure><p>“<em>This article was originally published at </em><a href="https://www.codingnepalweb.com/build-currency-converter-project-reactjs/"><em>https://www.codingnepalweb.com</em></a><em>.</em>”</p><p>Are you new to ReactJS and looking for a project to enhance your skills? Building a currency converter using ReactJS and CSS is an excellent way to do just that. This project reinforces fundamental concepts like components, state management, and <a href="https://www.codingnepalweb.com/category/api-projects/">API integration</a>, while also providing a practical and rewarding application.</p><p>In this blog post, I’ll guide you through building a Currency Converter using <a href="https://www.codingnepalweb.com/category/reactjs/">ReactJS</a> and pure <a href="https://www.codingnepalweb.com/category/html-and-css/">CSS</a>. In this currency converter, users can input an amount, choose the currencies for conversion, and click a button to get the exchange rate.</p><p>Additionally, the converter will display flags representing the currency codes, and users will be able to switch the currencies by clicking a swap button.</p><h3>Why Build a Currency Converter in ReactJS?</h3><p>By building this currency converter project using React js and CSS, you can gain the following skills:</p><ul><li><strong>ReactJS Fundamentals:</strong> You’ll get hands-on experience with React components, state management, and hooks.</li><li><strong>API Integration:</strong> Learn how to interact with web services, handle asynchronous operations, and manage data fetching in React.</li><li><strong>CSS Skills:</strong> Learn how to create a responsive and visually appealing UI without relying on pre-built components.</li><li><strong>Practical Application:</strong> This project provides a tangible result that you can showcase in your portfolio or use in real-life scenarios.</li></ul><h3>Video Tutorial to Build Currency Converter in ReactJS</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F0_Lwi5ucGwM%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D0_Lwi5ucGwM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F0_Lwi5ucGwM%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a344faf198c283c47113231aee95442c/href">https://medium.com/media/a344faf198c283c47113231aee95442c/href</a></iframe><p>If you prefer video tutorials, the YouTube video above is a great resource. It explains each line of code and provides comments to make the process of building your ReactJS currency converter easy to follow. If you prefer reading or need a step-by-step guide, keep following this post.</p><h3>Setting Up the Project</h3><p>Before we start making the <a href="https://www.codingnepalweb.com/currency-converter-app-in-html-javascript/">currency converter</a> with ReactJS and CSS, make sure you have Node.js installed on your computer. If you don’t have it, you can download and install it from the official <a href="https://nodejs.org/en/download/prebuilt-installer">Node.js</a> website.</p><p><strong>Create a Project Folder</strong></p><ul><li>Make a new folder, for instance, “currency-converter”.</li><li>Open this folder in your VS Code editor.</li></ul><p><strong>Initialize the Project</strong></p><p>Use <a href="https://vitejs.dev/">Vite</a> to create a new React app with this command:</p><pre>npm create vite@latest ./ -- --template react</pre><p>Install necessary dependencies and start the development server:</p><pre>npm install<br>npm run dev</pre><p>If your project is up and running in your browser, congratulations! You’ve successfully set up your project. Now, let’s move on to the next step modifying folders and files.</p><p><strong>Modify folder and CSS Files:</strong></p><ul><li>Remove the default assets folder and App.css file.</li><li>Download the <a href="https://codingnepalweb.com/demos/build-currency-converter-project-reactjs/bg.png">bg.png</a> image and place it inside the public folder.</li><li>Replace the content of index.css with the provided code.</li></ul><pre>/* Import Google Font */<br>@import url(https://medium.com/&#39;https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&amp;display=swap&#39;);<br><br>* {<br>  margin: 0;<br>  padding: 0;<br>  box-sizing: border-box;<br>  font-family: &quot;Montserrat&quot;, sans-serif;<br>}<br><br>body {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  min-height: 100vh;<br>  background: url(https://medium.com/&quot;bg.png&quot;) #030728 no-repeat center;<br>}<br><br>#root {<br>  width: 100%;<br>}<br><br>.currency-converter {<br>  max-width: 410px;<br>  margin: 0 auto;<br>  padding: 40px 30px 50px;<br>  border-radius: 8px;<br>  backdrop-filter: blur(30px);<br>  background: rgba(2, 7, 40, 0.5);<br>  border: 1px solid rgba(255, 255, 255, 0.3);<br>  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);<br>}<br><br>.currency-converter .converter-title {<br>  color: #fff;<br>  font-size: 1.65rem;<br>  font-weight: 600;<br>  text-align: center;<br>}<br><br>.currency-converter .converter-form {<br>  margin-top: 45px;<br>}<br><br>.converter-form .form-group {<br>  display: flex;<br>  margin-bottom: 30px;<br>  flex-direction: column;<br>}<br><br>.converter-form .form-group .form-label {<br>  color: #fff;<br>  font-weight: 500;<br>  display: block;<br>  margin-bottom: 9px;<br>  font-size: 1rem;<br>}<br><br>.converter-form .form-group .form-input {<br>  outline: none;<br>  font-size: 1.1rem;<br>  padding: 0 15px;<br>  color: #fff;<br>  font-weight: 500;<br>  min-height: 48px;<br>  border-radius: 6px;<br>  background: rgba(255, 255, 255, 0.1);<br>  border: 1px solid rgba(255, 255, 255, 0.5);<br>}<br><br>.converter-form .form-currency-group {<br>  flex-direction: row;<br>  align-items: center;<br>  justify-content: space-between;<br>}<br><br>.form-currency-group .currency-select {<br>  display: flex;<br>  padding: 0 10px;<br>  min-height: 45px;<br>  align-items: center;<br>  border-radius: 6px;<br>  background: rgba(255, 255, 255, 0.1);<br>  border: 1px solid rgba(255, 255, 255, 0.5);<br>}<br><br>.form-currency-group .currency-select img {<br>  width: 25px;<br>}<br><br>.form-currency-group .currency-select .currency-dropdown {<br>  outline: none;<br>  border: none;<br>  background: none;<br>  color: #fff;<br>  font-size: 1rem;<br>  font-weight: 500;<br>  padding: 0 10px 0 5px;<br>}<br><br>.form-currency-group .currency-select .currency-dropdown option {<br>  color: #000;<br>  font-weight: 500;<br>}<br><br>.form-currency-group .swap-icon {<br>  height: 40px;<br>  width: 40px;<br>  cursor: pointer;<br>  display: flex;<br>  margin-top: 25px;<br>  align-items: center;<br>  justify-content: center;<br>  border-radius: 50%;<br>  background: rgba(255, 255, 255, 0.1);<br>  border: 1px solid rgba(255, 255, 255, 0.5);<br>  transition: 0.2s ease;<br>}<br><br>.form-currency-group .swap-icon:hover {<br>  background: rgba(255, 255, 255, 0.3);<br>}<br><br>.converter-form .submit-button {<br>  width: 100%;<br>  min-height: 52px;<br>  border-radius: 6px;<br>  border: none;<br>  outline: none;<br>  font-size: 1rem;<br>  font-weight: 600;<br>  cursor: pointer;<br>  margin-top: 5px;<br>  transition: 0.2s ease;<br>}<br><br>.converter-form .submit-button.loading {<br>  opacity: 0.7;<br>  pointer-events: none;<br>}<br><br>.converter-form .submit-button:hover {<br>  background: rgba(255, 255, 255, 0.7);<br>}<br><br>.converter-form .exchange-rate-result {<br>  color: #fff;<br>  font-size: 1.1rem;<br>  font-weight: 600;<br>  text-align: center;<br>  padding: 25px 0;<br>  margin-top: 25px;<br>  border-radius: 6px;<br>  letter-spacing: 0.5px;<br>  background: rgba(255, 255, 255, 0.15);<br>}<br><br>@media (max-width: 640px) {<br>  body {<br>    padding: 0 10px;<br>  }<br><br>  .currency-converter {<br>    padding: 30px 20px 40px;<br>  }<br>}</pre><h3>Creating the Components</h3><p>Within the <strong>src</strong> directory of your project, organize your files by creating a “components” folder. Inside the components folder, create the following files:</p><ul><li>ConverterForm.jsx</li><li>CurrencySelect.jsx</li></ul><h3>Adding the Codes</h3><p>Add the respective code to each newly created file. These files define the layout and functionality of the currency converter.</p><p>In components/ConverterForm.jsx, add the code for rendering the converter form, and fetch the exchange rate with an API call.</p><pre>import { useEffect, useState } from &quot;react&quot;;<br>import CurrencySelect from &quot;./CurrencySelect&quot;;<br><br>const ConverterForm = () =&gt; {<br>    const [amount, setAmount] = useState(100);<br>    const [fromCurrency, setFromCurrency] = useState(&quot;USD&quot;);<br>    const [toCurrency, setToCurrency] = useState(&quot;INR&quot;);<br>    const [result, setResult] = useState(&quot;&quot;);<br>    const [isLoading, setIsLoading] = useState(false);<br><br>    // Swap the values of fromCurrency and toCurrency<br>    const handleSwapCurrencies = () =&gt; {<br>        setFromCurrency(toCurrency);<br>        setToCurrency(fromCurrency);<br>    }<br><br>    // Function to fetch the exchange rate and update the result<br>    const getExchangeRate = async () =&gt; {<br>        const API_KEY = &quot;PASTE-YOUR-API-KEY&quot;;<br>        const API_URL = `https://v6.exchangerate-api.com/v6/${API_KEY}/pair/${fromCurrency}/${toCurrency}`;<br><br>        if (isLoading) return;<br>        setIsLoading(true);<br><br>        try {<br>            const response = await fetch(API_URL);<br>            if (!response.ok) throw Error(&quot;Something went wrong!&quot;);<br><br>            const data = await response.json();<br>            const rate = (data.conversion_rate * amount).toFixed(2);<br>            setResult(`${amount} ${fromCurrency} = ${rate} ${toCurrency}`);<br>        } catch (error) {<br>            setResult(&quot;Something went wrong!&quot;);<br>        } finally {<br>            setIsLoading(false);<br>        }<br>    }<br><br>    // Handle form submission<br>    const handleFormSubmit = (e) =&gt; {<br>        e.preventDefault();<br>        getExchangeRate();<br>    }<br><br>    // Fetch exchange rate on initial render<br>    // eslint-disable-next-line react-hooks/exhaustive-deps<br>    useEffect(() =&gt; getExchangeRate, []);<br><br>    return (<br>        &lt;form className=&quot;converter-form&quot; onSubmit={handleFormSubmit}&gt;<br>            &lt;div className=&quot;form-group&quot;&gt;<br>                &lt;label className=&quot;form-label&quot;&gt;Enter Amount&lt;/label&gt;<br>                &lt;input<br>                    type=&quot;number&quot;<br>                    className=&quot;form-input&quot;<br>                    value={amount}<br>                    onChange={(e) =&gt; setAmount(e.target.value)}<br>                    required<br>                /&gt;<br>            &lt;/div&gt;<br><br>            &lt;div className=&quot;form-group form-currency-group&quot;&gt;<br>                &lt;div className=&quot;form-section&quot;&gt;<br>                    &lt;label className=&quot;form-label&quot;&gt;From&lt;/label&gt;<br>                    &lt;CurrencySelect<br>                        selectedCurrency={fromCurrency}<br>                        handleCurrency={e =&gt; setFromCurrency(e.target.value)}<br>                    /&gt;<br>                &lt;/div&gt;<br><br>                &lt;div className=&quot;swap-icon&quot; onClick={handleSwapCurrencies}&gt;<br>                    &lt;svg width=&quot;16&quot; viewBox=&quot;0 0 20 19&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;<br>                        &lt;path d=&quot;M19.13 11.66H.22a.22.22 0 0 0-.22.22v1.62a.22.22 0 0 0 .22.22h16.45l-3.92 4.94a.22.22 0 0 0 .17.35h1.97c.13 0 .25-.06.33-.16l4.59-5.78a.9.9 0 0 0-.7-1.43zM19.78 5.29H3.34L7.26.35A.22.22 0 0 0 7.09 0H5.12a.22.22 0 0 0-.34.16L.19 5.94a.9.9 0 0 0 .68 1.4H19.78a.22.22 0 0 0 .22-.22V5.51a.22.22 0 0 0-.22-.22z&quot;<br>                            fill=&quot;#fff&quot; /&gt;<br>                    &lt;/svg&gt;<br>                &lt;/div&gt;<br><br>                &lt;div className=&quot;form-section&quot;&gt;<br>                    &lt;label className=&quot;form-label&quot;&gt;To&lt;/label&gt;<br>                    &lt;CurrencySelect<br>                        selectedCurrency={toCurrency}<br>                        handleCurrency={e =&gt; setToCurrency(e.target.value)}<br>                    /&gt;<br>                &lt;/div&gt;<br>            &lt;/div&gt;<br><br>            &lt;button type=&quot;submit&quot; className={`${isLoading ? &quot;loading&quot; : &quot;&quot;} submit-button`}&gt;Get Exchange Rate&lt;/button&gt;<br>            &lt;p className=&quot;exchange-rate-result&quot;&gt;<br>                {/* Display the conversion result */}<br>                {isLoading ? &quot;Getting exchange rate...&quot; : result}<br>            &lt;/p&gt;<br>        &lt;/form&gt;<br>    )<br>}<br><br>export default ConverterForm</pre><p>Remember to paste your API key into the API_KEY variable within the getExchangeRate() function. For security, consider storing your API key in a .env file in your project&#39;s root directory. You can get a free API key from the <a href="https://www.exchangerate-api.com/">ExchangeRate-API</a> website.</p><p>In components/CurrencySelect.jsx, add the code for rendering the currency selection dropdowns.</p><pre>// Array of currency codes<br>const currencyCodes = [<br>    &quot;AED&quot;, &quot;AFN&quot;, &quot;ALL&quot;, &quot;AMD&quot;, &quot;ANG&quot;, &quot;AOA&quot;, &quot;ARS&quot;, &quot;AUD&quot;, &quot;AWG&quot;, &quot;AZN&quot;,<br>    &quot;BAM&quot;, &quot;BBD&quot;, &quot;BDT&quot;, &quot;BGN&quot;, &quot;BHD&quot;, &quot;BIF&quot;, &quot;BMD&quot;, &quot;BND&quot;, &quot;BOB&quot;, &quot;BRL&quot;,<br>    &quot;BSD&quot;, &quot;BTN&quot;, &quot;BWP&quot;, &quot;BYN&quot;, &quot;BZD&quot;, &quot;CAD&quot;, &quot;CDF&quot;, &quot;CHF&quot;, &quot;CLP&quot;, &quot;CNY&quot;,<br>    &quot;COP&quot;, &quot;CRC&quot;, &quot;CUP&quot;, &quot;CVE&quot;, &quot;CZK&quot;, &quot;DJF&quot;, &quot;DKK&quot;, &quot;DOP&quot;, &quot;DZD&quot;, &quot;EGP&quot;,<br>    &quot;ERN&quot;, &quot;ETB&quot;, &quot;EUR&quot;, &quot;FJD&quot;, &quot;FKP&quot;, &quot;FOK&quot;, &quot;GBP&quot;, &quot;GEL&quot;, &quot;GGP&quot;, &quot;GHS&quot;,<br>    &quot;GIP&quot;, &quot;GMD&quot;, &quot;GNF&quot;, &quot;GTQ&quot;, &quot;GYD&quot;, &quot;HKD&quot;, &quot;HNL&quot;, &quot;HRK&quot;, &quot;HTG&quot;, &quot;HUF&quot;,<br>    &quot;IDR&quot;, &quot;ILS&quot;, &quot;IMP&quot;, &quot;INR&quot;, &quot;IQD&quot;, &quot;IRR&quot;, &quot;ISK&quot;, &quot;JEP&quot;, &quot;JMD&quot;, &quot;JOD&quot;,<br>    &quot;JPY&quot;, &quot;KES&quot;, &quot;KGS&quot;, &quot;KHR&quot;, &quot;KID&quot;, &quot;KMF&quot;, &quot;KRW&quot;, &quot;KWD&quot;, &quot;KYD&quot;, &quot;KZT&quot;,<br>    &quot;LAK&quot;, &quot;LBP&quot;, &quot;LKR&quot;, &quot;LRD&quot;, &quot;LSL&quot;, &quot;LYD&quot;, &quot;MAD&quot;, &quot;MDL&quot;, &quot;MGA&quot;, &quot;MKD&quot;,<br>    &quot;MMK&quot;, &quot;MNT&quot;, &quot;MOP&quot;, &quot;MRU&quot;, &quot;MUR&quot;, &quot;MVR&quot;, &quot;MWK&quot;, &quot;MXN&quot;, &quot;MYR&quot;, &quot;MZN&quot;,<br>    &quot;NAD&quot;, &quot;NGN&quot;, &quot;NIO&quot;, &quot;NOK&quot;, &quot;NPR&quot;, &quot;NZD&quot;, &quot;OMR&quot;, &quot;PAB&quot;, &quot;PEN&quot;, &quot;PGK&quot;,<br>    &quot;PHP&quot;, &quot;PKR&quot;, &quot;PLN&quot;, &quot;PYG&quot;, &quot;QAR&quot;, &quot;RON&quot;, &quot;RSD&quot;, &quot;RUB&quot;, &quot;RWF&quot;, &quot;SAR&quot;,<br>    &quot;SBD&quot;, &quot;SCR&quot;, &quot;SDG&quot;, &quot;SEK&quot;, &quot;SGD&quot;, &quot;SHP&quot;, &quot;SLE&quot;, &quot;SLL&quot;, &quot;SOS&quot;, &quot;SRD&quot;,<br>    &quot;SSP&quot;, &quot;STN&quot;, &quot;SYP&quot;, &quot;SZL&quot;, &quot;THB&quot;, &quot;TJS&quot;, &quot;TMT&quot;, &quot;TND&quot;, &quot;TOP&quot;, &quot;TRY&quot;,<br>    &quot;TTD&quot;, &quot;TVD&quot;, &quot;TWD&quot;, &quot;TZS&quot;, &quot;UAH&quot;, &quot;UGX&quot;, &quot;USD&quot;, &quot;UYU&quot;, &quot;UZS&quot;, &quot;VES&quot;,<br>    &quot;VND&quot;, &quot;VUV&quot;, &quot;WST&quot;, &quot;XAF&quot;, &quot;XCD&quot;, &quot;XOF&quot;, &quot;XPF&quot;, &quot;YER&quot;, &quot;ZAR&quot;, &quot;ZMW&quot;,<br>    &quot;ZWL&quot;<br>];<br><br>const CurrencySelect = ({ selectedCurrency, handleCurrency }) =&gt; {<br>    // Extract the country code from the selected currency code<br>    const countryCode = selectedCurrency.substring(0, 2);<br><br>    return (<br>        &lt;div className=&quot;currency-select&quot;&gt;<br>            &lt;img src={`https://flagsapi.com/${countryCode}/flat/64.png`} alt=&quot;Flag&quot; /&gt;<br>            &lt;select<br>                onChange={handleCurrency}<br>                className=&quot;currency-dropdown&quot;<br>                value={selectedCurrency}<br>            &gt;<br>                {currencyCodes.map(currency =&gt; (<br>                    &lt;option key={currency} value={currency}&gt;{currency}&lt;/option&gt;<br>                ))}<br>            &lt;/select&gt;<br>        &lt;/div&gt;<br>    )<br>}<br><br>export default CurrencySelect</pre><p>Finally, replace the content of src/App.jsx with the provided code. It imports and renders the ConverterForm component.</p><pre>import ConverterForm from &quot;./components/ConverterForm&quot;;<br><br>const App = () =&gt; {<br>  return (<br>    &lt;div className=&quot;currency-converter&quot;&gt;<br>      &lt;h2 className=&quot;converter-title&quot;&gt;Currency Converter&lt;/h2&gt;<br>      &lt;ConverterForm /&gt;<br>    &lt;/div&gt;<br>  )<br>}<br><br>export default App;</pre><p>That’s it! If you’ve completed all the steps, you should now see your currency converter project in your browser. You can interact with it by entering an amount, selecting currencies, and clicking the swap button to switch between them.</p><h3>Conclusion and final words</h3><p>Building a currency converter with <a href="https://www.codingnepalweb.com/react-vs-angular-which-is-best-for-frontend/">ReactJS</a> and CSS is a rewarding project for beginners. It enhances your knowledge of React components, state management, and hooks, while also giving you hands-on experience with API integration and CSS styling.</p><p>Keep experimenting with additional features like historical exchange rates or different themes to continue learning and improving your skills. If you encounter any issues, you can download the source code files for free by clicking the “Download” button and view a live demo by clicking the “View Live” button.</p><p>After downloading the zip file, unzip it and open the “currency-converter” folder in VS Code. Then, open components/ConverterForm.jsx file and paste your API key into the API_KEY variable within the getExchangeRate() function. For security, consider storing your API key in a .env file in your project&#39;s root directory. You can get a free API key from the <a href="https://www.exchangerate-api.com/">ExchangeRate-API</a> website.</p><p>Finally, open the terminal by pressing Ctrl + J and run these commands to view your currency converter project in the browser:</p><pre>npm install<br>npm run dev</pre><p><a href="https://www.codingnepalweb.com/demos/build-currency-converter-project-reactjs/">View Live Demo</a></p><p><a href="https://www.codingnepalweb.com/build-currency-converter-project-reactjs/">Download Code Files</a></p><p><em>Originally published at </em><a href="https://www.codingnepalweb.com/build-currency-converter-project-reactjs/"><em>https://www.codingnepalweb.com</em></a><em> on June 26, 2024.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0cb6d7e04303" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>