<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: RAJ</title>
    <description>The latest articles on DEV Community by RAJ (@verreauxblack).</description>
    <link>https://dev.to/verreauxblack</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F454788%2F147c3b0d-d61a-4402-8f4e-4f635d332e13.jpg</url>
      <title>DEV Community: RAJ</title>
      <link>https://dev.to/verreauxblack</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/verreauxblack"/>
    <language>en</language>
    <item>
      <title>How to use TailwindCSS with ReactJs</title>
      <dc:creator>RAJ</dc:creator>
      <pubDate>Sun, 08 Aug 2021 11:33:40 +0000</pubDate>
      <link>https://dev.to/verreauxblack/how-to-use-tailwindcss-with-reactjs-kp7</link>
      <guid>https://dev.to/verreauxblack/how-to-use-tailwindcss-with-reactjs-kp7</guid>
      <description>&lt;p&gt;In this article, You will learn how to use &lt;a href="https://tailwindcss.com/" rel="noopener noreferrer"&gt;Tailwindcss&lt;/a&gt; in &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;Reactjs&lt;/a&gt;. This process is not complicated when you do step by step.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;basic understanding of Reactjs&lt;/li&gt;
&lt;li&gt;basic understanding in TailwindCSS&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt;&lt;br&gt;
       open a terminal or cmd and go to your project folder, then create react app using the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app myapp 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then go to &lt;code&gt;myapp&lt;/code&gt;   in the terminal by using the command  &lt;code&gt;cd myapp&lt;/code&gt; &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;br&gt;
       Now install the necessary dependencies for TailwindCSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss-cli autoprefixer@^9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we use &lt;code&gt;postcss-cli&lt;/code&gt;, because tailwind requires a CSS build process and step to run the build process we use &lt;code&gt;postcss-cli&lt;/code&gt;. &lt;code&gt;autoprefixer&lt;/code&gt; also needs our CSS build process. option &lt;code&gt;-D&lt;/code&gt; means all the dependencies are development dependencies. &lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;br&gt;
Open the project folder &lt;code&gt;myapp&lt;/code&gt; in your favorite code editor.  I preferred Vs Code.  the open terminal in vs code. Then type the following command to create a full Tailwind configuration file for our project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx tailwind init --full
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command creates the &lt;code&gt;tailwind.config.js&lt;/code&gt; file.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt;&lt;br&gt;
Now create a file as &lt;code&gt;postcss.config.js&lt;/code&gt;. In this file, we going to specify our CSS build process.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; Both &lt;code&gt;tailwind.config.js&lt;/code&gt; and &lt;code&gt;postcss.config.js&lt;/code&gt; must be located in the root of our project folder.&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt;&lt;br&gt;
Add the following lines in the &lt;code&gt;postcss.config.js&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
    plugins: [
        require('tailwindcss'),
        require('autoprefixer')
    ]
};                      
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 6:&lt;/strong&gt;&lt;br&gt;
Create a folder as &lt;code&gt;style&lt;/code&gt; in the src folder. Then create two more files in the &lt;code&gt;style&lt;/code&gt; folder as follows.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;tailwind.css&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;main.css&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt;&lt;br&gt;
In the &lt;code&gt;tailwind.css&lt;/code&gt; file add the following files of code. These are basic packages we need to use in our project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@tailwind base;

@tailwind components;

@tailwind utilities;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;tailwind.css&lt;/code&gt; is an input file and  &lt;code&gt;main.css&lt;/code&gt; is an output file.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt;&lt;br&gt;
Open the &lt;code&gt;package.json&lt;/code&gt; file and add the following scripts below the &lt;code&gt;eject&lt;/code&gt; script. This script is used to build tailwind CSS.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"build:css": "postcss src/styles/tailwind.css -o src/styles/main.css"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Modify the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;build&lt;/code&gt; scripts as follows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"start": "npm run build:css &amp;amp;&amp;amp; react-scripts start"
"build": "npm run build:css &amp;amp;&amp;amp; react-scripts build",
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;sample figure 1&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1620399221155%2F_mferMoTU.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1620399221155%2F_mferMoTU.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Step 9:&lt;/strong&gt;&lt;br&gt;
We are in the final step to complete the TailwindCSS with reactjs setup!&lt;br&gt;
Now you can import our &lt;code&gt;main.css&lt;/code&gt; file into the &lt;code&gt;App.js&lt;/code&gt; file. &lt;code&gt;App.js&lt;/code&gt; is enough.  no need to import &lt;code&gt;main.css&lt;/code&gt; in every component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import './styles/main.css';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One last step. Open the terminal in vs code, and type the following command to start build process&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build:css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now you can add tailwind classes to your components 🥳🥳&lt;/p&gt;

&lt;p&gt;Start you react app server and Happy coding!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;sample figure 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1620400292914%2FbJREPAclxa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1620400292914%2FbJREPAclxa.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I would love to connect with you at &lt;a href="https://twitter.com/verreauxblack" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; | &lt;a href="https://www.linkedin.com/in/verreauxblack/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See you in my next Blog article, Take care!!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Reference :&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://tailwindcss.com/docs/guides/create-react-app" rel="noopener noreferrer"&gt;Tailwindcss doc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://reactjs.org/docs/getting-started.html" rel="noopener noreferrer"&gt;React doc&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>tailwindcss</category>
      <category>tutorial</category>
      <category>react</category>
      <category>css</category>
    </item>
    <item>
      <title>Weekly web dev challenge: currency converter! </title>
      <dc:creator>RAJ</dc:creator>
      <pubDate>Mon, 18 Jan 2021 09:15:30 +0000</pubDate>
      <link>https://dev.to/verreauxblack/weekly-web-dev-challenge-currency-converter-2kfd</link>
      <guid>https://dev.to/verreauxblack/weekly-web-dev-challenge-currency-converter-2kfd</guid>
      <description>&lt;p&gt;Recently I saw  &lt;a href="https://scrimba.com/"&gt;scrimba's&lt;/a&gt; weekly web dev challenge currency converter. Here I'll share my knowledge about this currency converter from the scratch. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CwncXZIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610869457492/V1CLKMWHV.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CwncXZIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1610869457492/V1CLKMWHV.png" alt="image.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Basic understanding of&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;JS&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Content :
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
HTML and CSS code.&lt;/li&gt;
&lt;li&gt;
Javascript code.&lt;/li&gt;
&lt;li&gt;
Sample in Codepen.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;First, Let's have a look at the &lt;a href="https://scrimba.com/scrim/coa164702a455306fc9062373"&gt;given code&lt;/a&gt;. &lt;br&gt;
Let's start with the make of the structure of the currency converter. &lt;/p&gt;

&lt;p&gt;Now, Let's change the look and style of the currency converter to our own.&lt;/p&gt;
&lt;h2&gt;
  
  
  HTML and CSS:
&lt;/h2&gt;

&lt;p&gt;First, we are going to add some CSS property for the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;&lt;br&gt;
 tag, this will place our currency converter in the centre of the screen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html, body {
    margin: 0;
    padding: 0;
}

body {
    text-align: center;
    font-family: sans-serif;
    background-color: #00539CFF;
    display: flex;
    height: 80vh;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag for the Heading of our currency converter also add some CSS for &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Awesome Currency Converter&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1{
    color: #FFD662FF;
    font-size: 3rem;  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add  &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;  tag for the &lt;code&gt;label&lt;/code&gt;. Label name is Convert, then add &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag as a child of &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="convert"&amp;gt;
    Convert :
    &amp;lt;input type="number" id="original-currency-amount" 
        placeholder="0" value="1"&amp;gt; &amp;lt;/input&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add css property for the class &lt;strong&gt;convert&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.convert{
    font-family: 'Sansita Swashed', cursive;
    font-size: 25px;
    color: #ffffff;
    padding-right: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h6&gt;
  
  
  Get currency
&lt;/h6&gt;

&lt;p&gt;Now going to set &lt;strong&gt;from_currency&lt;/strong&gt; and &lt;strong&gt;to_currency&lt;/strong&gt; for the conversion. Here I used &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; tag to set the &lt;strong&gt;from_currency&lt;/strong&gt; and &lt;strong&gt;to_currency&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;select id="from_currency"&amp;gt;
    &amp;lt;option value="AED"&amp;gt;AED&amp;lt;/option&amp;gt;
    &amp;lt;option value="ARS"&amp;gt;ARS&amp;lt;/option&amp;gt;
    &amp;lt;option value="AUD"&amp;gt;AUD&amp;lt;/option&amp;gt;
    &amp;lt;option value="BGN"&amp;gt;BGN&amp;lt;/option&amp;gt;
    &amp;lt;option value="BRL"&amp;gt;BRL&amp;lt;/option&amp;gt;
    &amp;lt;option value="BSD"&amp;gt;BSD&amp;lt;/option&amp;gt;
    &amp;lt;option value="CAD"&amp;gt;CAD&amp;lt;/option&amp;gt;
    &amp;lt;option value="CHF"&amp;gt;CHF&amp;lt;/option&amp;gt;
    &amp;lt;option value="CLP"&amp;gt;CLP&amp;lt;/option&amp;gt;
    &amp;lt;option value="CNY"&amp;gt;CNY&amp;lt;/option&amp;gt;
    &amp;lt;option value="COP"&amp;gt;COP&amp;lt;/option&amp;gt;
    &amp;lt;option value="CZK"&amp;gt;CZK&amp;lt;/option&amp;gt;
    &amp;lt;option value="DKK"&amp;gt;DKK&amp;lt;/option&amp;gt;
    &amp;lt;option value="DOP"&amp;gt;DOP&amp;lt;/option&amp;gt;
    &amp;lt;option value="EGP"&amp;gt;EGP&amp;lt;/option&amp;gt;
    &amp;lt;option value="EUR"&amp;gt;EUR&amp;lt;/option&amp;gt;
    &amp;lt;option value="FJD"&amp;gt;FJD&amp;lt;/option&amp;gt;
    &amp;lt;option value="GBP"&amp;gt;GBP&amp;lt;/option&amp;gt;
    &amp;lt;option value="GTQ"&amp;gt;GTQ&amp;lt;/option&amp;gt;
    &amp;lt;option value="HKD"&amp;gt;HKD&amp;lt;/option&amp;gt;
    &amp;lt;option value="HRK"&amp;gt;HRK&amp;lt;/option&amp;gt;
    &amp;lt;option value="HUF"&amp;gt;HUF&amp;lt;/option&amp;gt;
    &amp;lt;option value="IDR"&amp;gt;IDR&amp;lt;/option&amp;gt;
    &amp;lt;option value="ILS"&amp;gt;ILS&amp;lt;/option&amp;gt;
    &amp;lt;option value="INR"&amp;gt;INR&amp;lt;/option&amp;gt;
    &amp;lt;option value="ISK"&amp;gt;ISK&amp;lt;/option&amp;gt;
    &amp;lt;option value="JPY"&amp;gt;JPY&amp;lt;/option&amp;gt;
    &amp;lt;option value="KRW"&amp;gt;KRW&amp;lt;/option&amp;gt;
    &amp;lt;option value="KZT"&amp;gt;KZT&amp;lt;/option&amp;gt;
    &amp;lt;option value="MXN"&amp;gt;MXN&amp;lt;/option&amp;gt;
    &amp;lt;option value="MYR"&amp;gt;MYR&amp;lt;/option&amp;gt;
    &amp;lt;option value="NOK"&amp;gt;NOK&amp;lt;/option&amp;gt;
    &amp;lt;option value="NZD"&amp;gt;NZD&amp;lt;/option&amp;gt;
    &amp;lt;option value="PAB"&amp;gt;PAB&amp;lt;/option&amp;gt;
    &amp;lt;option value="PEN"&amp;gt;PEN&amp;lt;/option&amp;gt;
    &amp;lt;option value="PHP"&amp;gt;PHP&amp;lt;/option&amp;gt;
    &amp;lt;option value="PKR"&amp;gt;PKR&amp;lt;/option&amp;gt;
    &amp;lt;option value="PLN"&amp;gt;PLN&amp;lt;/option&amp;gt;
    &amp;lt;option value="PYG"&amp;gt;PYG&amp;lt;/option&amp;gt;
    &amp;lt;option value="RON"&amp;gt;RON&amp;lt;/option&amp;gt;
    &amp;lt;option value="RUB"&amp;gt;RUB&amp;lt;/option&amp;gt;
    &amp;lt;option value="SAR"&amp;gt;SAR&amp;lt;/option&amp;gt;
    &amp;lt;option value="SEK"&amp;gt;SEK&amp;lt;/option&amp;gt;
    &amp;lt;option value="SGD"&amp;gt;SGD&amp;lt;/option&amp;gt;
    &amp;lt;option value="THB"&amp;gt;THB&amp;lt;/option&amp;gt;
    &amp;lt;option value="TRY"&amp;gt;TRY&amp;lt;/option&amp;gt;
    &amp;lt;option value="TWD"&amp;gt;TWD&amp;lt;/option&amp;gt;
    &amp;lt;option value="UAH"&amp;gt;UAH&amp;lt;/option&amp;gt;
    &amp;lt;option value="USD" selected&amp;gt;USD&amp;lt;/option&amp;gt;
    &amp;lt;option value="UYU"&amp;gt;UYU&amp;lt;/option&amp;gt;
    &amp;lt;option value="VND"&amp;gt;VND&amp;lt;/option&amp;gt;
    &amp;lt;option value="ZAR"&amp;gt;ZAR&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we add CSS property for &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;select{
    width: 80px;
    height: 35px;
    font-size: 20px;
    text-align: center;
    padding-left: 10px;
    outline: 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; tag to interchange the &lt;strong&gt;from_currency&lt;/strong&gt; and &lt;strong&gt;to_currency&lt;/strong&gt;&lt;br&gt;
and add &lt;code&gt;&amp;lt;i&amp;gt;&lt;/code&gt; tag for the double ended arrow &lt;strong&gt;&amp;lt;--&amp;gt;&lt;/strong&gt; icon.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button id="exchange"&amp;gt;
    &amp;lt;i class="fas fa-exchange-alt"&amp;gt;&amp;lt;/i&amp;gt;
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add some CSS property to button id &lt;code&gt;exchange&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#exchange{
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin: 0 20px;
    outline: 0;
    color: #00539CFF;
    border: 4px solid #FFD662FF;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;active&lt;/code&gt; pseudo-class for the real button effect.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#exchange:active{
    transform: scale(0.9);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again use the same &lt;code&gt;&amp;lt;select&amp;gt;&lt;/code&gt; tag and code of &lt;strong&gt;from_currency&lt;/strong&gt; for &lt;strong&gt;to_currency&lt;/strong&gt; also!!&lt;/p&gt;

&lt;p&gt;Now add &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag for the &lt;code&gt;label&lt;/code&gt; &lt;strong&gt;Exchange Rate&lt;/strong&gt;, and add &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tag as a child of &lt;code&gt;p&lt;/code&gt; tag to display the &lt;strong&gt;Exchange rate&lt;/strong&gt; of the currency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="exchange"&amp;gt;
    Exchange Rate: 
    &amp;lt;input type="text" id="exchange-rate" &amp;gt;&amp;lt;/input&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add CSS property for &lt;code&gt;p&lt;/code&gt; class &lt;code&gt;exchange&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.exchange{
    font-family: 'Sansita Swashed', cursive;
    font-size: 25px;
    color: #ffffff;
    padding-right: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now add &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; tag, this button converts the currency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;button id="exchange_button"&amp;gt;Exchange my money now!&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final Tag, add &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag to display the converted amount. I added two &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; tag inside &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;, This &lt;code&gt;span&lt;/code&gt; tag will help to highlight the amount.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p id="output-text"&amp;gt;
        &amp;lt;span id="from"&amp;gt;&amp;lt;/span&amp;gt; converted to &amp;lt;span id="to"&amp;gt;&amp;lt;/span&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS property for &lt;code&gt;p&lt;/code&gt; id &lt;code&gt;output-text&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#output-text{
    display: none;
    padding: 20px;
    font-size: 30px;
    color: #ffffff;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;

&lt;p&gt;Finally, we are in the Awesome part of the currency converter, i.e., &lt;strong&gt;Javascript&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In Javascript first, we are going to define the variables to get the element from the &lt;strong&gt;HTML&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//input amount
var input_amount = document.getElementById("original-currency-amount");
//input currency
var from_currency = document.getElementById("from_currency");
//output currency
var to_currency = document.getElementById("to_currency");
//exchange rate
var exchange_rate = document.getElementById("exchange-rate");
var exchange = document.getElementById("exchange");
var output_amount = document.getElementById("output-text");
//to display the final output
var output_from = document.getElementById("from");
var output_to = document.getElementById("to");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember, we added one &lt;code&gt;button&lt;/code&gt; to interchange the &lt;strong&gt;from_currency&lt;/strong&gt; and &lt;strong&gt;to_currency&lt;/strong&gt;, for that, call the &lt;code&gt;addEventListener&lt;/code&gt; set the parameter as &lt;code&gt;click&lt;/code&gt;, then create an anonymous function to swap the &lt;strong&gt;from_currency&lt;/strong&gt; and &lt;strong&gt;to_currency&lt;/strong&gt; and then call the main function &lt;code&gt;calculate()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When you click the button it will automatically call the corresponding function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exchange.addEventListener("click",()=&amp;gt;{
    [from_currency.value, to_currency.value] = 
    [to_currency.value, from_currency.value];
    calculate();
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, we have used &lt;code&gt;from_currency.value&lt;/code&gt; because we defined the variable to get the element. But we need to swap the value of that element, So, we have used &lt;code&gt;from_currency.value&lt;/code&gt; to get the values.&lt;/p&gt;

&lt;p&gt;Create a function to convert the currency. This is the main part of the conversion.&lt;br&gt;
Here we use an &lt;code&gt;API&lt;/code&gt; to get the &lt;strong&gt;exchange rate&lt;/strong&gt; of each currency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function calculate(){
    const from_currency_value = from_currency.value;
    const to_currency_value = to_currency.value;

    //api call to get exchange rate of each currency
    fetch(`https://api.exchangerate-api.com/v4/latest/${from_currency_value}`)
    .then(res =&amp;gt; res.json())
    .then(res =&amp;gt; {
        const rate = res.rates[to_currency_value];
        exchange_rate.value = `${rate}`
        to_amount = (input_amount.value * rate).toFixed(3);

        //it will display the output to screen
        output_from.innerText= `${input_amount.value} ${from_currency_value}`;
        output_to.innerText = `${to_amount} ${to_currency_value}`;
        output_amount.style.display="block";
    })
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Congratulations You did it 🥳🥳.
&lt;/h3&gt;

&lt;p&gt;If you need more clarity code check below &lt;strong&gt;pen&lt;/strong&gt;👇🏻.&lt;/p&gt;

&lt;h2&gt;
  
  
  codepen
&lt;/h2&gt;

&lt;p&gt;%[&lt;a href="https://codepen.io/verreauxblack/pen/xxEmEXq"&gt;https://codepen.io/verreauxblack/pen/xxEmEXq&lt;/a&gt;]&lt;/p&gt;

&lt;p&gt;Thank you for reading !!&lt;/p&gt;

&lt;p&gt;Get in Touch &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/verreauxblack"&gt;GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://twitter.com/verreauxblack"&gt;Twitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://instagram.com/_verreauxblack"&gt;Instagram&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>css</category>
    </item>
  </channel>
</rss>
