<?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>Forem: Vaibhav Khulbe</title>
    <description>The latest articles on Forem by Vaibhav Khulbe (@vaibhavkhulbe).</description>
    <link>https://forem.com/vaibhavkhulbe</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%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg</url>
      <title>Forem: Vaibhav Khulbe</title>
      <link>https://forem.com/vaibhavkhulbe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vaibhavkhulbe"/>
    <language>en</language>
    <item>
      <title>Tailwind CSS from Zero to Hero - Up and Running (Part 1 of 4) 🚀</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Thu, 06 May 2021 11:49:38 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/tailwind-css-from-zero-to-hero-up-and-running-part-1-of-4-an6</link>
      <guid>https://forem.com/vaibhavkhulbe/tailwind-css-from-zero-to-hero-up-and-running-part-1-of-4-an6</guid>
      <description>&lt;p&gt;Check out the next articles in the series &amp;gt;&lt;/p&gt;

&lt;p&gt;Welcome to the complete Tailwind CSS guide you need to build high-quality frontend webpages. In this entire series of articles, we will be covering every single topic needed in order to master the complete workflow of Tailwind.&lt;/p&gt;

&lt;p&gt;Starting from absolutely nothing you will get to know all about it, including why you should use it, what features does it offers and what are the benefits over other frameworks.&lt;/p&gt;

&lt;p&gt;And don’t worry there will be examples, clear explanations, and details you need to know about each topic covered. Not only that, we will be focussing on some lesser-known features which are useful for real-life applications.&lt;/p&gt;

&lt;p&gt;So who is ready to dive into the world of Tailwind? Let’s start with the most common question you might have now.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Tailwind CSS?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://tailwindcss.com/"&gt;&lt;strong&gt;Tailwind&lt;/strong&gt;&lt;/a&gt; is a &lt;em&gt;utility-first&lt;/em&gt; CSS framework that lets you add styles to your web pages without writing a single line of custom CSS code.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s dissect the two important things I wrote above:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘Utility-first’&lt;/em&gt; means that instead of regular and old-fashioned framework classes, it works on low-level utilities which are essential to style any HTML element you wish. These may include styles like &lt;code&gt;padding&lt;/code&gt;, &lt;code&gt;display&lt;/code&gt;, &lt;code&gt;width&lt;/code&gt;, &lt;code&gt;height&lt;/code&gt; etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;‘Without writing a single line of custom CSS code’&lt;/em&gt; means that well...you are getting rid of those long CSS code blocks you need to write just to style one element according to the design provided to you. Tailwind handles this all.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So instead of pre-built components, it provides utility classes. That’s what makes it different from others. Adam Wathan, the creator of Tailwind, writes how a utility class is approached in &lt;a href="https://adamwathan.me/css-utility-classes-and-separation-of-concerns/"&gt;this article&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  But why Tailwind?
&lt;/h3&gt;

&lt;p&gt;I get it. There are many CSS frameworks and libraries like Bootstrap, Bulma, Foundation, etc. which are really popular and used widely. You might feel, “Why do I need to learn about yet another CSS framework? What’s the use? How will it benefit me?”  And my answer is, “While it may not be the perfect solution to your style needs, it does have the following features that you should reflect on and try…”:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You use only what you need&lt;/strong&gt;: most of its competitors give you too many unnecessary classes, straight at your face. That becomes a lot to digest especially when you are working on some large-scale projects. With Tailwind you choose what styles you need to apply, code it and there it reflects immediately. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;You don’t need to code custom CSS&lt;/strong&gt;: well, in most cases you don’t need to override base classes. Until you have a very complex design system with tons of the custom element, you will be using the in-built styles provided by this framework as it always gives you low-level utility classes. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It even removes the not-used CSS code!&lt;/strong&gt; Thanks to PurgeCSS (we will talk about this next), when you run its commands, it will automatically remove every CSS code we aren’t using in our project. The output of the final bundle we get is clean without any heavy load, thereby improving CSS load time and thus the overall load time of the page. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Really easy to customize, if you like&lt;/strong&gt;: of course, there are times when what’s provided isn’t enough. You are free to change its config file, add your own mix, and deliver on what your design lead said! It’s just a matter of adding some objects to its JSON file and there you have it! &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Built-in responsive classes&lt;/strong&gt;: no need to write those tricky media queries. With Tailwind, you plug in the responsive powers directly in your HTML. Everything changes magically once you have applied the breakpoints.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Awesome auto-complete support&lt;/strong&gt;: if you are working on the popular VS Code tool to write code, you can install the &lt;a href="https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss"&gt;Tailwind CSS IntelliSense extension&lt;/a&gt; which provides you autocomplete suggestions, linting, class definitions, etc. So if you forget what &lt;code&gt;padding&lt;/code&gt; size to apply, just start typing and see the difference. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Support for &lt;strong&gt;dark mode&lt;/strong&gt;, new CSS features like &lt;strong&gt;Grids&lt;/strong&gt;, and even their own &lt;strong&gt;&lt;a href="https://tailwindui.com/components?utm_source=tailwindcss&amp;amp;utm_medium=navigation"&gt;component library&lt;/a&gt;&lt;/strong&gt;. Need I say more?&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The PurgeCSS Effect
&lt;/h3&gt;

&lt;p&gt;Tailwind CSS is blessed with Purge. &lt;a href="http://purgecss.com"&gt;PurgeCSS&lt;/a&gt; is a tool to remove unused CSS from your CSS file. You can easily integrate it with your Tailwind project.   &lt;/p&gt;

&lt;p&gt;While optimizing for production (more about production in Part 4 of this series), when you use Purge, it will check for all of the unused classes in your HTML code. You just add any file extension that includes a markup code like &lt;em&gt;.html&lt;/em&gt;, &lt;em&gt;.jsx&lt;/em&gt;, &lt;em&gt;.vue&lt;/em&gt;, etc. to the config object and then run the Purge command. You can see your output build files are much optimized and use only the classes they need.  &lt;/p&gt;

&lt;p&gt;Don’t worry, we will get to know all about this towards the end of the article series.&lt;/p&gt;

&lt;p&gt;Now you know what all it has to offer and why it just might be the next CSS framework for your web app. &lt;/p&gt;

&lt;p&gt;Part 1 of this article series will cover how to get started with Tailwind and make a quick webpage section. Just the barebones you need to have the confidence in writing the code.&lt;/p&gt;

&lt;p&gt;Here’s a quick rundown of the entire process we will go through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
Installation &lt;/li&gt;
&lt;li&gt;
Basic concepts
&lt;/li&gt;
&lt;li&gt;
Browser support
&lt;/li&gt;
&lt;li&gt;
A quick demo
&lt;/li&gt;
&lt;li&gt;
Conclusion
&lt;/li&gt;
&lt;li&gt;What’s next?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Pssst...wait. I have to tell you that there is no such thing as running some &lt;code&gt;npm&lt;/code&gt; commands for now. We will be scratching only the upper layer of simply pulling the CDN for the current demo. &lt;/p&gt;

&lt;p&gt;The main goal right now is not to start with a heavy workflow but to understand the basic concepts.  &lt;/p&gt;

&lt;p&gt;With that, you can open up your &lt;em&gt;index.html&lt;/em&gt; file, write the initial HTML code and then add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This pulls in the latest configuration build via CDN so that you can use the base classes on the go. &lt;/p&gt;

&lt;p&gt;Okay, looks like this really quick installation is done! Can we move on with what we are about to build? Not yet. First, let’s clear out some basic concepts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Basic concepts
&lt;/h3&gt;

&lt;p&gt;Tailwind comes with a good amount of &lt;a href="https://tailwindcss.com/docs/utility-first"&gt;utility classes&lt;/a&gt; that you should know. Let’s take a look at the most common ones with an example.&lt;/p&gt;

&lt;p&gt;If you were to make this small box which is aligned to the center of the webpage you will need to write the following CSS (the exact numbers will vary):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sxjk3ehsbvzbqbnf7bf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sxjk3ehsbvzbqbnf7bf.png" alt="Box image" width="368" height="362"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;14px&lt;/span&gt; &lt;span class="m"&gt;-1px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.16&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But the same style can be done with Tailwind CSS as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"min-h-screen bg-gray-200 flex flex-col justify-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"sm:mx-auto"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-white shadow-lg p-20 rounded-lg"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance this might be a bit uneasy for you to comprehend what is written but allow me to explain each entity here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There are three &lt;code&gt;div&lt;/code&gt; elements we need to create that element from scratch. The first one provides the whole container a minimum height of &lt;code&gt;100vh&lt;/code&gt; so that now we can use the power of &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox"&gt;Flexbox&lt;/a&gt; to align the entire element to the center of the screen. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second &lt;code&gt;div&lt;/code&gt; has some responsive alignment class which can be realized when you change the width of the viewport (see the live demo link to this code below).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, we have the actual square element with all the style properties. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s now understand what utility classes are being used.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;min-h-screen&lt;/code&gt;: this equals &lt;code&gt;min-height: 100vh;&lt;/code&gt; in CSS. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;bg-gray-200&lt;/code&gt;: this gives the webpage &lt;code&gt;body&lt;/code&gt; element a background color of light gray or &lt;code&gt;rgba(229, 231, 235, 1)&lt;/code&gt; to be specific.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;flex flex-col justify-center&lt;/code&gt;: these are all the Flexbox styles. It tells Tailwind to use &lt;code&gt;display: flex;&lt;/code&gt; use &lt;code&gt;flex-direction&lt;/code&gt; like &lt;code&gt;column&lt;/code&gt; and then justify the content to center.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;sm:mx-auto&lt;/code&gt;: every time you see a prefix applied to a Tailwind property, you can be sure that it’s either using a responsive design feature or some state prefixes like hover, focus, and other states. Here on the small viewports, we want the horizontal margin (i.e. left and right margins) of our container to be &lt;code&gt;auto&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;bg-white shadow-lg p-20 rounded-lg&lt;/code&gt;: all of these corresponds to how the box we made actually ‘looks’. Starting from making its color white to adding a large shadow, adding padding of &lt;code&gt;5rem&lt;/code&gt;, and then rounding off the corners.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now from where I got to know that &lt;code&gt;p-20&lt;/code&gt; equals &lt;code&gt;padding: 5rem;&lt;/code&gt;? Well, all of these are very well documented on &lt;a href="https://tailwindcss.com/docs"&gt;their official documentation&lt;/a&gt;. It's good to know that &lt;em&gt;Tailwind sizes are based on the multiplications of &lt;code&gt;0.25rem&lt;/code&gt; units.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you like then you can try to play with this code I wrote above &lt;a href="https://play.tailwindcss.com/7nFzsDaoz3"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser support
&lt;/h3&gt;

&lt;p&gt;It is really important to know which browsers Tailwind supports and how to manage vendor prefixes if any so that a wide array of browsers and systems are supported.&lt;/p&gt;

&lt;p&gt;As of the time of writing this article, Tailwind CSS supports the latest stable versions of Chrome, Firefox, Edge, and Safari. But if you are the old IE guy and need support for that (in any case) then the latest (v2.0) version of Tailwind isn’t for you. You have to &lt;a href="https://blog.tailwindcss.com/tailwindcss-1-9#upgrading"&gt;downgrade to v.1.9&lt;/a&gt; for that.&lt;/p&gt;

&lt;p&gt;For those who are not using the Tailwind CLI tool (which adds all the vendor prefixes automatically), you can use &lt;a href="https://github.com/postcss/autoprefixer"&gt;Autoprefixer&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  A quick demo
&lt;/h3&gt;

&lt;p&gt;Time to put some things into practice as we make the following button with Tailwind CSS. Let’s try making this one:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y0dvb4tc5zxv75zhd9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y0dvb4tc5zxv75zhd9z.png" alt="Final button output" width="340" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;Padding:&lt;/strong&gt; first, we use the &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; HTML element, add the label and give it proper padding values. Now, this might be something different from what we usually do in proper CSS. No need to add custom height and width values or use &lt;code&gt;display: block;&lt;/code&gt;  We are simply using the padding values both on the &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; axes. &lt;/p&gt;

&lt;p&gt;The button is rectangular and thus we can give it more &lt;code&gt;x&lt;/code&gt; padding value than &lt;code&gt;y&lt;/code&gt;. In the language of Tailwind, it is &lt;code&gt;px-8 py-4&lt;/code&gt; respectively. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;px-8&lt;/code&gt; equals &lt;code&gt;padding-left: 2rem; padding-right: 2rem;&lt;/code&gt; &lt;br&gt;
&lt;code&gt;py-4&lt;/code&gt; equals &lt;code&gt;padding-top: 1rem; padding-bottom: 1rem;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 px-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Join now&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ &lt;strong&gt;Background:&lt;/strong&gt; this button has a blue background and Tailwind comes with a lot of &lt;a href="https://tailwindcss.com/docs/customizing-colors"&gt;different color shades&lt;/a&gt; for one prominent color. For us &lt;code&gt;bg-blue-500&lt;/code&gt; suits as it gives us the &lt;code&gt;500&lt;/code&gt; color shade of the blue color. &lt;a href="https://tailwindcss.com/docs/background-color#class-reference"&gt;Here is the entire list of background colors to choose from&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;The higher the shade number, the darker the color gets and vice-versa.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;bg-blue-500&lt;/code&gt; equals &lt;code&gt;background-color: rgba(99, 102, 241, 1);&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisxs8cs1fki9fane777r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fisxs8cs1fki9fane777r.png" alt="Button with padding and background" width="306" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3️⃣ &lt;strong&gt;Rounded corners:&lt;/strong&gt; here we can either use &lt;code&gt;rounded-xl&lt;/code&gt; or &lt;code&gt;rounded-lg&lt;/code&gt; classes which simply means ‘extra-large rounded corners’ or ‘large rounded corners’. The first one fits well and thus &lt;code&gt;xl&lt;/code&gt; seems a good choice.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;rounded-xl&lt;/code&gt; equals &lt;code&gt;border-radius: 0.75rem;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 px-8 bg-blue-500 rounded-xl"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Join now&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz2vp4wg516svqgsyarfn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz2vp4wg516svqgsyarfn.png" alt="Button with rounder corners" width="304" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;4️⃣ &lt;strong&gt;Text color, transform, and weight:&lt;/strong&gt; the black text on a blue background calls for contrast issues. So we have to change it to white. For text colors, you can simply say &lt;code&gt;text-white&lt;/code&gt;. As for making it uppercase, it’s simply the &lt;code&gt;uppercase&lt;/code&gt; utility class. Easy!&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;font-weight&lt;/code&gt; is not the regular one or full-blown bold. Hence &lt;code&gt;font-semibold&lt;/code&gt; is the way to go!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;text-white&lt;/code&gt; equals &lt;code&gt;color: rgba(255, 255, 255, 1);&lt;/code&gt;&lt;br&gt;
&lt;code&gt;uppercase&lt;/code&gt; equals &lt;code&gt;text-transform: uppercase;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;font-semibold&lt;/code&gt; equals &lt;code&gt;font-weight: 600;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 px-8 bg-blue-500 rounded-xl text-white uppercase font-semibold"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Join now&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OUTPUT:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dapsjmqnubrhqup48ly.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8dapsjmqnubrhqup48ly.png" alt="Button with text transforms" width="322" height="150"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;5️⃣ &lt;strong&gt;Shadows:&lt;/strong&gt; the final step is to add some shadows around our button. The &lt;code&gt;shadow-lg&lt;/code&gt; class gives us the appropriate shadow values we need for our button. It’s not entirely big and not very small.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;shadow-lg&lt;/code&gt; equals:&lt;br&gt;
&lt;code&gt;box-shadow: --tw-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); &lt;br&gt;
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 px-8 bg-blue-500 rounded-xl text-white uppercase font-semibold shadow-lg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Join now&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;FINAL OUTPUT: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y0dvb4tc5zxv75zhd9z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2y0dvb4tc5zxv75zhd9z.png" alt="Final button output" width="340" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you go! You just styled a button without coding any CSS! The best part? You never left your HTML document and it was way quick and easy to make such elements.&lt;/p&gt;

&lt;p&gt;Here’s the entire code with responsive utility classes included just like we did it in the box above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"min-h-screen flex flex-col justify-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;   
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"sm:mx-auto"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-4 px-8 bg-blue-500 rounded-xl text-white uppercase font-semibold shadow-lg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Join now&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In this article, you were introduced to what Tailwind is, how it provides you with its special utility classes, its features, and how you can make a custom button element without ever leaving the HTML file.&lt;/p&gt;

&lt;p&gt;It was all about kickstart your Tailwind journey as a complete beginner. I hope I was able to give you a quick glimpse of the topic.&lt;/p&gt;

&lt;h3&gt;
  
  
  What’s next?
&lt;/h3&gt;

&lt;p&gt;In the next tutorial of the Tailwind CSS from Zero to Hero series, we will look into how the utility-first approach really works and how Tailwind uses it to make more dynamic and functional elements. Stay tuned!&lt;/p&gt;




&lt;p&gt;Hope you liked the information. You can comment below with your thoughts about it.&lt;/p&gt;

&lt;p&gt;And now...as always, enjoy a meme! 😆&lt;/p&gt;




&lt;h2&gt;
  
  
  The &lt;a href="https://twitter.com/search?q=%23devhumour&amp;amp;src=typed_query"&gt;#DevHumour&lt;/a&gt; Corner 😂
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc83yfqnclnyv7op7o9zo.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc83yfqnclnyv7op7o9zo.jpeg" alt="Dev Humour Image" width="640" height="948"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Some of my previous articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/create-powerful-and-flexible-forms-with-react-hook-form-1cd1"&gt;Create powerful and flexible forms with React Hook Form. 🪝&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/create-smoking-hot-toast-notifications-in-react-with-react-hot-toast-30p8"&gt;Create smoking Hot toast notifications in React with React Hot Toast. 🔥&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/5-really-cool-web-technologies-to-know-2maj"&gt;5 really cool web technologies to know! 🤩&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Find me on
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;a href="https://twitter.com/vaibhav_khulbe"&gt;Twitter 🐦&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://instagram.com/vaibhavkhulbe143/"&gt;Instagram 📸&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://www.linkedin.com/in/vaibhav-khulbe/"&gt;LinkedIn 👨🏻‍💻&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://about.me/vaibhav_khulbe"&gt;Everywhere else 🌐&lt;/a&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;




&lt;h3&gt;
  
  
  Next articles in the series
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://daily.dev/blog/tailwind-css-the-utility-first-workflow"&gt;Tailwind CSS from Zero to Hero - The Utility-First Workflow (Part 2 of 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://daily.dev/blog/tailwind-css-the-utility-first-workflow"&gt;Tailwind CSS from Zero to Hero - Responsiveness and Custom Utilities (Part 3 of 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://daily.dev/blog/tailwind-css-from-zero-to-hero-extracting-components-and-setting-up-for-production-part-4-of-4"&gt;Tailwind CSS from Zero to Hero - Extracting Components and Setting up for Production (Part 4 of 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://daily.dev/blog/tailwind-css-from-zero-to-hero-dark-mode-jit-more-bonus"&gt;Tailwind CSS from Zero to Hero - Dark Mode, JIT &amp;amp; More!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tailwindcss</category>
      <category>html</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create powerful and flexible forms with React Hook Form. 🪝</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Wed, 21 Apr 2021 14:39:53 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/create-powerful-and-flexible-forms-with-react-hook-form-1cd1</link>
      <guid>https://forem.com/vaibhavkhulbe/create-powerful-and-flexible-forms-with-react-hook-form-1cd1</guid>
      <description>&lt;p&gt;Someone inputting his details and hitting that ‘Submit’ button is one of the most widely used and reliable forms of getting the data from a user on any website. We call such web entities ‘forms’ and forms on a webpage are nothing but a collection of elements that allows a user to enter data that is then sent over to the server for further processing.&lt;/p&gt;

&lt;p&gt;While the traditional approach to build, code and gather information from a form in a webpage can simply be done with the power of HTML code, but when the website gets complex or scales up in size, (say, when you are on an e-commerce website), we need to leverage some of the external libraries that were meant to get things done easily and are able to integrate with other tech stacks quickly.&lt;/p&gt;

&lt;p&gt;One such open-source library to handle all things related to forms is React Form Hook and in this article, we will get to know how to use this with a suitable example.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the library
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://react-hook-form.com"&gt;React Form Hook&lt;/a&gt;&lt;/strong&gt; is a React library that is used to make performant, flexible, and extensible forms with easy-to-use validation support.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sure, there have been other libraries like &lt;a href="https://formik.org"&gt;Formik&lt;/a&gt;, &lt;a href="https://final-form.org/react"&gt;React Final Form&lt;/a&gt;, etc. that falls under similar lines but here’s why it goes above all those:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Small in size&lt;/strong&gt;: it’s a tiny library with no other dependencies to install.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance&lt;/strong&gt;: the best part is that it minimizes the re-renders required and also mounts up fairly quickly, thereby increasing the overall experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uses existing HTML&lt;/strong&gt;: you can leverage the powers of HTML to work with this library.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Less code and more features&lt;/strong&gt;: almost every form handling scenario is covered all in fairly fewer lines of code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we have some information, here’s what the rest of the blog will tell you about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;li&gt;API references with examples&lt;/li&gt;
&lt;li&gt;A quick but powerful demo&lt;/li&gt;
&lt;li&gt;Conclusion&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Time to make our forms powerful with the use of React Hook Forms! Fire up your terminal and then execute the following commands which makes a new React project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app react-form-hook-demo 
&lt;span class="nb"&gt;cd &lt;/span&gt;react-form-hook-demo
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your default React project should be running in your browser by now. Next, we need to add the library. Use the following command to install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;react-hook-form
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  API References
&lt;/h2&gt;

&lt;p&gt;Before we move ahead typing code carelessly, we need to know how this library works, or more precisely what are the different APIs it has and how they function. Here are some common ones:&lt;/p&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;&lt;a href="https://react-hook-form.com/api#useForm"&gt;The &lt;code&gt;useForm&lt;/code&gt; API&lt;/a&gt;&lt;/strong&gt;: this is one of those functions which you will be calling first before you apply any handling logic to your existing forms. It takes some optional arguments like &lt;code&gt;mode&lt;/code&gt;, &lt;code&gt;defaultValues&lt;/code&gt;, &lt;code&gt;shouldFocusError&lt;/code&gt;, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;register&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;onSubmit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;reValidateMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;onChange&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;defaultValues&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="na"&gt;resolver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;criteriaMode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;firstError&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;shouldFocusError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;shouldUnregister&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As for its methods, take a look at how these are used:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react-hook-form.com/api#register"&gt;&lt;code&gt;register&lt;/code&gt;&lt;/a&gt;: allows you to register an input/select ref and apply validation rules into React Hook Form based on both HTML default and custom validations.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react-hook-form.com/api#unregister"&gt;&lt;code&gt;unregister&lt;/code&gt;&lt;/a&gt;: allows you to unregister a single input or an array of inputs.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;  &lt;span class="nx"&gt;unregister&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;button&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;unregister&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lastName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;unregister&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react-hook-form.com/api#errors"&gt;&lt;code&gt;errors&lt;/code&gt;&lt;/a&gt;: it’s an object which contains form errors and error messages corresponding to each field. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note that this will get deprecated in the next major version (i.e. v7). &lt;code&gt;formState&lt;/code&gt; is likely to be the alternative.&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;singleErrorInput&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;singleErrorInput&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your input is required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react-hook-form.com/api#handleSubmit"&gt;&lt;code&gt;handleSubmit&lt;/code&gt;&lt;/a&gt;: it’s a function that will pass the form data when form validation is successful and can be invoked remotely as well.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onError&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onError&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;firstName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lastName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Submit&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://react-hook-form.com/api#setError"&gt;&lt;code&gt;setError&lt;/code&gt;&lt;/a&gt;: allows you to manually set one or more errors.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; 
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;manual&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Dont Forget Your Username Should Be Cool!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}}&lt;/span&gt;
  &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ &lt;a href="https://react-hook-form.com/api#Controller"&gt;&lt;strong&gt;The &lt;code&gt;Controller&lt;/code&gt; API&lt;/strong&gt;&lt;/a&gt;: it’s a wrapper component that makes it easier to work with external components from other libraries and frameworks like &lt;a href="https://react-select.com/home"&gt;React-Select&lt;/a&gt;, &lt;a href="https://material-ui.com"&gt;Material UI&lt;/a&gt;, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Controller&lt;/span&gt;
  &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="nx"&gt;render&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onBlur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isTouched&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;isDirty&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Checkbox&lt;/span&gt;
      &lt;span class="nx"&gt;onBlur&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;onBlur&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
      &lt;span class="nx"&gt;checked&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="nx"&gt;inputRef&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;)}&lt;/span&gt;
&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3️⃣ &lt;a href="https://react-hook-form.com/api#useWatch"&gt;&lt;strong&gt;The &lt;code&gt;useWatch&lt;/code&gt; API&lt;/strong&gt;&lt;/a&gt;: if you want to reduce the re-rendering at the component level of your form then this API ‘watches’ for any changes to result in better performance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;IsolateReRender&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;control&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;firstName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useWatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;firstName&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;defaultValue&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;default&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;firstName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&amp;gt;;&lt;/span&gt;&lt;span class="err"&gt; 
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;data&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;))}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;firstName&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;last&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IsolateReRender&lt;/span&gt; &lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;control&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A Quick but powerful Demo
&lt;/h2&gt;

&lt;p&gt;Okay, now we know most of the APIs and functions to use from this library. Let’s put that into work by creating something fruitful. How about we make the following form?&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/react-hook-form-demo-wv3px"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Here is what’s happening in the form interface:&lt;/p&gt;

&lt;p&gt;We have six basic elements in the form; 4 text fields, 1 select field, and lastly a button. We will be adding some important form validations in each of these elements except the select field. Here are all the rules to be implemented:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;The First Name&lt;/em&gt;: it should not be empty and should have a minimum length of 5 characters. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;The Last Name&lt;/em&gt;: it is required and has a maximum of 15 characters. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;The Email&lt;/em&gt;: like others, this cannot be left blank.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Username&lt;/em&gt;: this also should not be blank but also we have a custom validation where only the string “John” will be accepted. The error will pop out asynchronously after 3 seconds.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Finally, when you click on the Submit button, an alert is shown along with the entered details. If any validation check goes wrong, the error will be shown instantly and the data won’t submit.&lt;/p&gt;

&lt;p&gt;Okay, enough of the information, let’s quickly begin coding all of this..&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Code the interface&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Open the &lt;em&gt;index.js&lt;/em&gt; file and inside the &lt;code&gt;return&lt;/code&gt; statement, start by using a &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element. Make sure you don’t add any &lt;code&gt;action&lt;/code&gt; or &lt;code&gt;method&lt;/code&gt; attributes. Everything will be handled by the library.&lt;/p&gt;

&lt;p&gt;Our first label will be of the “First Name” field. Make sure you add a suitable placeholder value to its &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element. Here we added “John”. The same goes for the “Last Name” field.&lt;/p&gt;

&lt;p&gt;Then we have the “Email” field. Here we can specify that the type of the form element is “email” so that it knows beforehand that a proper email syntax should be added. Why not use some good old powers of HTML!&lt;/p&gt;

&lt;p&gt;The “Username” field is the same as the name fields. So, it’s important to add a placeholder value here too.&lt;/p&gt;

&lt;p&gt;Up next the &lt;code&gt;select&lt;/code&gt; field is to be added with the &lt;code&gt;name&lt;/code&gt; attribute along with multiple options you want to provide in the drop-down. Here we need to make sure that each of the  elements must have a proper “value” attribute attached to it. It will be used later when we use the library.&lt;/p&gt;

&lt;p&gt;After you have coded all the form interface you will have a code similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;Up&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;First&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Last&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;  &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Email&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john@doe.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Only John is accepted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;How&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;got&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;know&lt;/span&gt; &lt;span class="nx"&gt;about&lt;/span&gt; &lt;span class="nx"&gt;us&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;select&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;info&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Select&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Twitter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Twitter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Facebook&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Facebook&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Other&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Other&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/select&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
 &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Power up the form with validation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the single &lt;code&gt;useForm&lt;/code&gt; hook, we will be doing almost all of the operations to make it functional.&lt;/p&gt;

&lt;p&gt;Start by importing the hook from the library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useForm&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-hook-form&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it’s time to register all the inputs we have used in the HTML code above. For that, we will be calling the imported useForm hook as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have to handle the functioning of the data submission. For that, we will be using the &lt;code&gt;onSubmit&lt;/code&gt; attribute of the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; element. We call the &lt;code&gt;handleSubmit&lt;/code&gt; function passing on a new &lt;code&gt;onSubmit()&lt;/code&gt; method to it. We haven’t added any code to this new method so let’s do that first.&lt;/p&gt;

&lt;p&gt;Make this new method after you register the inputs. We will pass on the data obtained from the form. We use JavaScript’s &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/alert"&gt;&lt;code&gt;alert()&lt;/code&gt;&lt;/a&gt; method inside which we use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals"&gt;string interpolation&lt;/a&gt; so that we have a dynamic text string shown in the alert box. We can also log down the data into the console just to make sure our object prints out as we are expecting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="s2"&gt;`Here are your details: \nName: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nEmail: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nUsername: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nSource: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
   &lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the power of &lt;a href="https://reactjs.org/docs/refs-and-the-dom.html"&gt;&lt;code&gt;refs&lt;/code&gt;&lt;/a&gt; in React, we access a particular DOM node in the &lt;code&gt;render()&lt;/code&gt; method. Hence, for all the 4 inputs and the 1 select element of the form, we add the &lt;code&gt;ref&lt;/code&gt; attribute which calls the &lt;code&gt;register&lt;/code&gt; function of the &lt;code&gt;useHook&lt;/code&gt; API.&lt;/p&gt;

&lt;p&gt;Now here comes all the goodies! Everything we need to validate, we can pass inside this &lt;code&gt;register&lt;/code&gt; function. This makes the form very flexible to change and each element can have similar or dissimilar validations as you like.&lt;/p&gt;

&lt;p&gt;For the “First Name” and the “Last Name” fields, we pass on the boolean &lt;code&gt;true&lt;/code&gt; value to the required property along with a &lt;code&gt;minLength&lt;/code&gt; of &lt;code&gt;5&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; length of &lt;code&gt;15&lt;/code&gt; characters.&lt;/p&gt;

&lt;p&gt;To apply the error messages to a specific field (say, &lt;code&gt;name&lt;/code&gt;), simply use the &lt;code&gt;errors&lt;/code&gt; prop along with the property &lt;code&gt;name&lt;/code&gt; like &lt;code&gt;errors.name&lt;/code&gt; or &lt;code&gt;errors.name.type&lt;/code&gt;. Then we can add any HTML element inside this check like a simple paragraph that says “First Name is required!”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;First&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;required&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As for the message for the minimum length check, we check the &lt;code&gt;errors.name.type === "minLength"&lt;/code&gt; and pass on the custom message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;minLength&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;requires&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what about the Username field where we only want specific data to be valid? For this to work as expected, we need to use the validate property of the &lt;code&gt;register&lt;/code&gt; function. The value of this property can be a separate function where the actual logic of the validation can be stored.&lt;/p&gt;

&lt;p&gt;We are using the &lt;code&gt;sleep()&lt;/code&gt; method so that the error is shown after 3 seconds to the user and this will only fire if the value of the string is not equal to “John”.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;validateUserName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure you predefine the async event code for this to function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sleep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sweet! The form should now be backed by powerful validations and is equally flexible with its elements. Test out your new form and you will see an alert box with all the inputs.&lt;/p&gt;

&lt;p&gt;Here’s the entire code along with accessibility attributes we wrote for making this form:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useForm&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sleep&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Promise&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ms&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
     &lt;span class="s2"&gt;`Here are your details: \nName: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nEmail: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nUsername: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; \nSource: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
   &lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;};&lt;/span&gt;

 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;validateUserName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

   &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;};&lt;/span&gt;

 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;handleSubmit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onSubmit&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt; &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Sign&lt;/span&gt; &lt;span class="nx"&gt;Up&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;First name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;First&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;John&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;minLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="p"&gt;})}&lt;/span&gt;
     &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;required&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;First&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;required&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;)}&lt;/span&gt;

     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;minLength&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;requires&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;)}&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt; &lt;span class="nx"&gt;htmlFor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Last name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Last&lt;/span&gt; &lt;span class="nx"&gt;Name&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Doe&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;minLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;max&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt; &lt;span class="p"&gt;})}&lt;/span&gt;
     &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;minLength&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt; &lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;This&lt;/span&gt; &lt;span class="nx"&gt;requires&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;min&lt;/span&gt; &lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;!&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;)}&lt;/span&gt;

     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Email&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;john@doe.com&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})}&lt;/span&gt;
     &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;username&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Only John is accepted&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
         &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="na"&gt;validate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;validateUserName&lt;/span&gt;
       &lt;span class="p"&gt;})}&lt;/span&gt;
     &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;How&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;got&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;know&lt;/span&gt; &lt;span class="nx"&gt;about&lt;/span&gt; &lt;span class="nx"&gt;us&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/label&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;select&lt;/span&gt;
       &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;info&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
       &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;invalid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;info&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;true&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;false&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;register&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;required&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})}&lt;/span&gt;
     &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Select&lt;/span&gt; &lt;span class="nx"&gt;source&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Twitter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Twitter&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Facebook&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Facebook&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;option&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Other&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Other&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/option&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/select&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/form&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is just the tip of an iceberg when you start making forms with React Hook Form. With its easy-to-go syntax and great features, you can also &lt;a href="https://react-hook-form.com/ts"&gt;use it with TypeScript&lt;/a&gt;, &lt;a href="https://react-hook-form.com/advanced-usage#WizardFormFunnel"&gt;create wizard-like multiple forms&lt;/a&gt; and even &lt;a href="https://react-hook-form.com/form-builder"&gt;use their online form builder&lt;/a&gt; where you simply add the elements you want along with rules, and bam! You get your generated code in one click.&lt;/p&gt;




&lt;p&gt;Hope you liked the information. You can comment below with your thoughts about it.&lt;/p&gt;

&lt;p&gt;And now...as always, enjoy a meme! 😆&lt;/p&gt;




&lt;h2&gt;
  
  
  The &lt;a href="https://twitter.com/search?q=%23devhumour&amp;amp;src=typed_query"&gt;#DevHumour&lt;/a&gt; Corner 😂
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdr0fsfnxcuurdaq84tj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpdr0fsfnxcuurdaq84tj.jpeg" alt="Dev Humour Image" width="800" height="253"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Some of my previous articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/create-smoking-hot-toast-notifications-in-react-with-react-hot-toast-30p8"&gt;Create smoking Hot toast notifications in React with React Hot Toast. 🔥&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/5-really-cool-web-technologies-to-know-2maj"&gt;5 really cool web technologies to know! 🤩&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/5-quick-and-easy-fixes-to-improve-your-react-app-performance-5g43"&gt;5 quick and easy fixes to improve your React app performance 🚀&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Find me on
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;a href="https://twitter.com/vaibhav_khulbe"&gt;Twitter 🐦&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://instagram.com/vaibhavkhulbe143/"&gt;Instagram 📸&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://www.linkedin.com/in/vaibhav-khulbe/"&gt;LinkedIn 👨🏻‍💻&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://about.me/vaibhav_khulbe"&gt;Everywhere else 🌐&lt;/a&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create smoking hot toast notifications in React with React Hot Toast. 🔥</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Mon, 22 Mar 2021 14:10:48 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/create-smoking-hot-toast-notifications-in-react-with-react-hot-toast-30p8</link>
      <guid>https://forem.com/vaibhavkhulbe/create-smoking-hot-toast-notifications-in-react-with-react-hot-toast-30p8</guid>
      <description>&lt;p&gt;Ding ding! A new toast shop is around your town and what a unique take to make toasts! But more importantly, to notify others of their presence!&lt;/p&gt;

&lt;p&gt;Well, what is this new toast? How does it help developers in particular? Here’s all you need to know about the hottest new React library to make toast notifications.&lt;/p&gt;

&lt;h2&gt;
  
  
  About the library
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://react-hot-toast.com"&gt;&lt;strong&gt;React Hot Toast&lt;/strong&gt;&lt;/a&gt; is a library that aims to include toast notifications in your React applications easily and intuitively. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s a three-step process to add the simplest of all notifications in your app. But before we even start doing anything with it, we need to take a look at some of the features it has to offer.&lt;/p&gt;

&lt;p&gt;Here are its top 5 features:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Easy to use&lt;/strong&gt;: just three simple steps needed to start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lots of customizations&lt;/strong&gt;: there are many ways you can set a notification to your liking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Uses native &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise"&gt;Promise API&lt;/a&gt;&lt;/strong&gt;: after all, everything is in JavaScript so why not use its wonderful event feature!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support for headless hooks&lt;/strong&gt;: by this, you can make your custom notifications. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Supports emojis&lt;/strong&gt;! 🤩&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we have some information, here’s what the rest of the blog will tell you about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installation&lt;/li&gt;
&lt;li&gt;A basic demo&lt;/li&gt;
&lt;li&gt;API references with examples&lt;/li&gt;
&lt;li&gt;A smoking hot real-life example&lt;/li&gt;
&lt;li&gt;Conclusion &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Ready to start off making some toasts? Let’s begin by creating an empty React project from scratch. Open up your terminal and run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-react-app hot-toast-demo 
&lt;span class="nb"&gt;cd &lt;/span&gt;hot-toast-demo 
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will start a new React project on the current directory and will run it on your default browser window. Let’s just do the necessary things first. It’s time to install the &lt;a href="https://www.npmjs.com/package/react-hot-toast"&gt;react-hot-toast package&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;On the terminal, under the same project directory, run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;react-hot-toast
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, if you are using Yarn as the package manager:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add react-hot-toast
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Basic demo
&lt;/h2&gt;

&lt;p&gt;Now that we have the library installed, we can go ahead and do some changes. We will modify the entry-level &lt;em&gt;app.js&lt;/em&gt; file so that we have a very basic interface to kick things off.&lt;/p&gt;

&lt;p&gt;Simply remove all the code you have on the file and then follow the below steps to have an interface similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3abo8j8xkwiqhae7tgil.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3abo8j8xkwiqhae7tgil.gif" alt="Notification demo" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see we have three buttons, the first one simply sends a toast notification with a text message, the second one is a success toast message which tells us that the action you did was successful, and the third button is just the opposite, it notifies that the action was not successful.&lt;/p&gt;

&lt;p&gt;Okay, let’s code now.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Build the interface
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="nx"&gt;Hot&lt;/span&gt; &lt;span class="nx"&gt;Toast&lt;/span&gt; &lt;span class="err"&gt;🍞&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;sucessNotify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;sucess&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errorNotify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Toaster&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under the default App export, we have one &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; heading and three buttons &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; with their &lt;code&gt;onClick&lt;/code&gt; handlers like &lt;code&gt;notify&lt;/code&gt;, &lt;code&gt;sucessNotify&lt;/code&gt; and &lt;code&gt;errorNotify&lt;/code&gt; linked to three different functions which are defined outside the &lt;code&gt;App()&lt;/code&gt; scope. Next, we have the  component which comes from the &lt;code&gt;react-hot-toast&lt;/code&gt; package we installed earlier. So, make sure you import the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Toaster&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-hot-toast&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The notification that pops up after clicking the button comes from the &lt;code&gt;Toaster&lt;/code&gt; component. Next, let’s add the notify logic by working on the functions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Add the notifications
&lt;/h3&gt;

&lt;p&gt;We have three things to do here, the usual text notification, the success one, and then the error notification.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding the &lt;em&gt;basic&lt;/em&gt; notification:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;notify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Here is my toast!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;notify&lt;/code&gt; function simply takes in the &lt;code&gt;toast&lt;/code&gt; function. Inside it, we can pass any text we want to display in the notification toast. Notice we are using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions"&gt;arrow syntax&lt;/a&gt; here to write our function.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding the &lt;em&gt;success&lt;/em&gt; notification:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sucessNotify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;success&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sucess!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;successNotify&lt;/code&gt; creates an animated check mark notification. For that, we need to call in the &lt;code&gt;toast.success()&lt;/code&gt; method. Just pass in any string you want to show alongside the check icon.&lt;/p&gt;

&lt;h4&gt;
  
  
  Adding the &lt;em&gt;error&lt;/em&gt; notification:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errorNotify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This creates a toast notification with an animated cross icon. Simply call the &lt;code&gt;toast.error()&lt;/code&gt; method. Just pass in any string you want to show alongside the cross icon.&lt;/p&gt;

&lt;p&gt;Here’s our entire code for now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Toaster&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react-hot-toast&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;notify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Here is my toast!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sucessNotify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;success&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Sucess!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errorNotify&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="nx"&gt;Hot&lt;/span&gt; &lt;span class="nx"&gt;Toast&lt;/span&gt; &lt;span class="err"&gt;🍞&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;sucessNotify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;sucess&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;errorNotify&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Make&lt;/span&gt; &lt;span class="nx"&gt;me&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;error&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Toaster&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now click on each button we made and it will pop up the notification presets we added!&lt;/p&gt;

&lt;h2&gt;
  
  
  API references
&lt;/h2&gt;

&lt;p&gt;We are about to build something more usable now. Before we do that, we first need to understand its two important APIs:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The &lt;a href="https://react-hot-toast.com/docs/toast"&gt;&lt;code&gt;toast()&lt;/code&gt;&lt;/a&gt; API
&lt;/h3&gt;

&lt;p&gt;This is the most basic API from where all the toasts are made. You can call this method anywhere you like. It even works outside React. For it to work, you need to define the &lt;code&gt;&amp;lt;Toaster /&amp;gt;&lt;/code&gt; component first.&lt;/p&gt;

&lt;p&gt;Apart from the three methods used in the above examples the &lt;code&gt;toast()&lt;/code&gt; API has the following two advanced usages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1. &lt;strong&gt;The &lt;em&gt;Loading&lt;/em&gt; state&lt;/strong&gt;: this is used when you need to define that the action done by the user is currently being processed.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Waiting for the action to complete...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But using only the loading indication &lt;em&gt;should be avoided&lt;/em&gt; as we can’t end this action, the notification will persist indefinitely causing the app to use more resources and finally, slowing it down. Instead, we can use the next alternative…&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;2. &lt;strong&gt;The &lt;em&gt;Promise&lt;/em&gt; state&lt;/strong&gt;: this is based on the asynchronous Promise concept of ES6. It maps the Promise to the notification used and updates automatically when the Promise is resolved or failed. You can give proper arguments as to what needs to be there in the toast for either of the cases.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myPromise&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="na"&gt;loading&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Data is loading...&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="na"&gt;success&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Got the data!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
 &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error when fetching data :(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. The &lt;a href="https://react-hot-toast.com/docs/toaster"&gt;&lt;code&gt;Toaster&lt;/code&gt;&lt;/a&gt; API
&lt;/h3&gt;

&lt;p&gt;Here things get exciting. You can &lt;em&gt;make your own notifications&lt;/em&gt; from this API. You can render any component you want, all &lt;code&gt;Toaster&lt;/code&gt; does is that it provides the notification’s current state.&lt;/p&gt;

&lt;p&gt;Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buildNotification&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;myToasts&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToaster&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;myToasts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
       &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;     &lt;span class="p"&gt;))}&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hey toast!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A practical example
&lt;/h2&gt;

&lt;p&gt;Let’s make a more practical example with this library. Here’s what we are trying to achieve:&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/react-hot-toast-demo-2-zotek"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;As you can see in the embed above, this is a chat-like interface where you can type your message in the input and hit the “Send a hot toast 🍞 ” button to get a customized toast notification. Moreover, if you try to send toast several times, you see the notification which came earlier goes away first with a transition, and if you start hovering the cursor over any of these elements, the notification stays there, just like we have on our systems! It goes away when you stop hovering.&lt;/p&gt;

&lt;p&gt;Note that the input box does nothing but shows you a practical scenario where we can use this library. We have a lot to explore here, so let’s get to code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Code the interface
&lt;/h3&gt;

&lt;p&gt;There are three UI elements here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The input field&lt;/li&gt;
&lt;li&gt;The button&lt;/li&gt;
&lt;li&gt;The notification itself
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HotToastNotifications&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Write your toast here...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;🛎 Toast message sent!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
       &lt;span class="nx"&gt;Send&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="nx"&gt;hot&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt; &lt;span class="err"&gt;🍞&lt;/span&gt;
     &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the &lt;code&gt;onClick&lt;/code&gt; of the button we need to fire the &lt;code&gt;toast()&lt;/code&gt; method wherein we add the string needed to show on the notification. Here it says, "🛎 Toast message sent!". We render the notification component named &lt;code&gt;HotToastNotifications&lt;/code&gt; beforehand.&lt;/p&gt;

&lt;p&gt;Next, let’s make something unique. Here, we will be using the &lt;a href="https://react-hot-toast.com/docs/use-toaster"&gt;&lt;code&gt;useToaster()&lt;/code&gt;&lt;/a&gt; headless API to make our custom component from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Create handlers and the notification component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;toasts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handlers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToaster&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the &lt;code&gt;HotToastNotifications&lt;/code&gt; component, we first define the two handlers for &lt;code&gt;useToaster()&lt;/code&gt; i.e. &lt;code&gt;toasts&lt;/code&gt; and &lt;code&gt;handlers&lt;/code&gt;. The first one will be used to map over the number of notifications to render and the latter is to add the hover-based handling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;toasts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateOffset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="na"&gt;reverseOrder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="na"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
       &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using JavaScript’s native &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map"&gt;&lt;code&gt;map()&lt;/code&gt;&lt;/a&gt; method, we loop over each individual &lt;code&gt;toast&lt;/code&gt; element, calculating its &lt;code&gt;offset&lt;/code&gt; position defined on the &lt;code&gt;calculateOffset&lt;/code&gt; handler of &lt;code&gt;useToaster&lt;/code&gt; API. In this, we need to pass the &lt;code&gt;toastId&lt;/code&gt; which is a unique identifier for each toast, the &lt;code&gt;reverseOrder&lt;/code&gt; which is a boolean property to state whether notifications appear in reverse order or not, and the &lt;code&gt;margin&lt;/code&gt; between each notification when they appear together. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Create a custom shape of the component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoundingClientRect&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
           &lt;span class="nf"&gt;updateHeight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, to make the shape of the custom notification, we are using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect"&gt;&lt;code&gt;getBoundingClientRect()&lt;/code&gt;&lt;/a&gt; method on the element which returns &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMRect"&gt;&lt;code&gt;DOMRect&lt;/code&gt;&lt;/a&gt; object to get the precise size of the &lt;code&gt;height&lt;/code&gt; of the element. Then with the &lt;code&gt;updateHeight&lt;/code&gt; handler, we set it to the toast’s ID and the calculated height.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Style the notification
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
           &lt;span class="nx"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;alert&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
           &lt;span class="nx"&gt;aria&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;notification&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
           &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
           &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
           &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
             &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;13rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0.7rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(175, 75, 62, 0.1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all 0.2s&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`translateY(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;px)`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visible&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
           &lt;span class="p"&gt;}}&lt;/span&gt;
         &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
           &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Time to add some styles to the custom notification we just made! You can choose any HTML element to make them but usually &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; works just fine. We give it the necessary &lt;code&gt;key&lt;/code&gt; which is the ID of the toast, the &lt;code&gt;ref&lt;/code&gt; element we made above, and finally, the &lt;code&gt;style&lt;/code&gt; property where you can add any CSS styling to your need. Notice that we have dynamic &lt;code&gt;opacity&lt;/code&gt; here so when &lt;code&gt;toast&lt;/code&gt; is removed, it turns the opacity to &lt;code&gt;0&lt;/code&gt; else, it stays at &lt;code&gt;1&lt;/code&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Create the hover based interactions
&lt;/h3&gt;

&lt;p&gt;Finally, we have one last thing left. We want that until we hover the notification, it shouldn’t go away. It can go when we remove hovering.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
     &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
       &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fixed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
     &lt;span class="p"&gt;}}&lt;/span&gt;
     &lt;span class="nx"&gt;onMouseEnter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;startPause&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="nx"&gt;onMouseLeave&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;endPause&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make this possible we make the same &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element but we do two important things; first, we need to style it such a way that its position stays the same until we remove the hover, and second, we use &lt;code&gt;onMouseEnter&lt;/code&gt; and &lt;code&gt;onMouseLeave&lt;/code&gt; events and set it to the &lt;code&gt;startPause&lt;/code&gt; and &lt;code&gt;endPause&lt;/code&gt; handlers respectively. &lt;/p&gt;

&lt;p&gt;And that’s it! If you implement all the code above you can now play with your own custom toast notification sent whenever the &lt;code&gt;onClick&lt;/code&gt; event is triggered! Here’s the entire code of the custom notification component we made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HotToastNotifications&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;toasts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handlers&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useToaster&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
 &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;startPause&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;endPause&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;calculateOffset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;updateHeight&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;handlers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
     &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
       &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fixed&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="na"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
     &lt;span class="p"&gt;}}&lt;/span&gt;
     &lt;span class="nx"&gt;onMouseEnter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;startPause&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
     &lt;span class="nx"&gt;onMouseLeave&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;endPause&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
     &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toasts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;offset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculateOffset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="na"&gt;reverseOrder&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
         &lt;span class="na"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
       &lt;span class="p"&gt;});&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ref&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
         &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;el&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;el&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoundingClientRect&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
           &lt;span class="nf"&gt;updateHeight&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;height&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
         &lt;span class="p"&gt;}&lt;/span&gt;
       &lt;span class="p"&gt;};&lt;/span&gt;
       &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
           &lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
           &lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
           &lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{{&lt;/span&gt;
             &lt;span class="na"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;absolute&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;13rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.7rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgba(175, 75, 62, 0.1)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;borderRadius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;3rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all 0.2s&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`translateY(&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;offset&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;px)`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
             &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;visible&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
           &lt;span class="p"&gt;}}&lt;/span&gt;
         &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
           &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;toast&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;       &lt;span class="p"&gt;);&lt;/span&gt;
     &lt;span class="p"&gt;})}&lt;/span&gt;
   &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Wasn’t it that easy! I mean, the ability to use hooks to make a custom notification is so mind-blowing and that comes with such ease to make. Let me know how you will be using this library, you can surely open a new issue to &lt;a href="https://github.com/timolins/react-hot-toast"&gt;its GitHub&lt;/a&gt; and let the library author know of any bugs you encountered or a new feature to include!&lt;/p&gt;




&lt;p&gt;Hope you liked the information. You can comment below with your thoughts about it.&lt;/p&gt;

&lt;p&gt;And now...as always, enjoy a meme! 😆&lt;/p&gt;




&lt;h2&gt;
  
  
  The &lt;a href="https://twitter.com/search?q=%23devhumour&amp;amp;src=typed_query"&gt;#DevHumour&lt;/a&gt; Corner 😂
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhn0vrd4udwqsix4x129t.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhn0vrd4udwqsix4x129t.jpeg" alt="Dev Humour Image" width="800" height="336"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Some of my previous articles
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/5-really-cool-web-technologies-to-know-2maj"&gt;5 really cool web technologies to know! 🤩&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/5-quick-and-easy-fixes-to-improve-your-react-app-performance-5g43"&gt;5 quick and easy fixes to improve your React app performance 🚀&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/demystifying-lesser-known-redux-terms-and-features-with-examples-112k"&gt;Demystifying 15 lesser-known React Redux terms and features (With examples) 🔮&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Find me on
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;a href="https://twitter.com/vaibhav_khulbe"&gt;Twitter 🐦&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://instagram.com/vaibhavkhulbe143/"&gt;Instagram 📸&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://www.linkedin.com/in/vaibhav-khulbe/"&gt;LinkedIn 👨🏻‍💻&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://about.me/vaibhav_khulbe"&gt;Everywhere else 🌐&lt;/a&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>5 really cool web technologies to know! 🤩</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Sat, 09 Jan 2021 17:56:39 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/5-really-cool-web-technologies-to-know-2maj</link>
      <guid>https://forem.com/vaibhavkhulbe/5-really-cool-web-technologies-to-know-2maj</guid>
      <description>&lt;p&gt;Welcome to my first article in 2021! This time I'm not focusing much on &lt;a href="https://dev.to/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2"&gt;writing articles every week&lt;/a&gt; but of course, I will continue to write useful content whenever I feel the need.&lt;/p&gt;

&lt;p&gt;Okay okay, back to the grind...&lt;/p&gt;

&lt;p&gt;There are some web technologies which you already know and must’ve mastered. Need examples? How about JavaScript libraries, PWAs, or even CSS Subgrids?&lt;/p&gt;

&lt;p&gt;There are all quite common and used in most of the projects (well, I don't know about Subgrids though). But there are some more really cool ones out there about which you might or mightn’t have heard about.&lt;/p&gt;

&lt;p&gt;Here are 5 of those about which I recently got to know about and they can be the future, who knows!&lt;/p&gt;




&lt;h1&gt;
  
  
  1. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API" rel="noopener noreferrer"&gt;Web Animation API&lt;/a&gt; ✨
&lt;/h1&gt;

&lt;h3&gt;
  
  
  ➡️ What is it?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The Web Animations API &lt;strong&gt;allows developers to describe animations to DOM elements by syncing animation with the help of the Timing and Animation model.&lt;/strong&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  ➡️ Why use it?
&lt;/h3&gt;

&lt;p&gt;It combines the best of CSS animation and transition to give you the best performance without using any external optimizations.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use both CSS or JavaScript. &lt;/li&gt;
&lt;li&gt;Move animations from stylesheets to JavaScript easily.&lt;/li&gt;
&lt;li&gt;You no longer rely on writing CSS properties and scoping classes onto elements to control the playback of animations.&lt;/li&gt;
&lt;li&gt;You can now dynamically set values from properties to durations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ➡️ What about the browser support?
&lt;/h3&gt;

&lt;p&gt;Here's what &lt;a href="https://caniuse.com/web-animation" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; says. The red blocks mean it's not supported and the green ones symbolize it is supported. Everything in between the two colors means partial support:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fungo5vy8b6jrm1s7hw4x.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fungo5vy8b6jrm1s7hw4x.png" alt="Web Animations API support"&gt;&lt;/a&gt;&lt;/p&gt;
92.67% usage



&lt;h3&gt;
  
  
  ➡️ How to write the code?
&lt;/h3&gt;

&lt;p&gt;Usually, if I say you to write an animation code for an HTML element, you would do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;animationName&lt;/span&gt; &lt;span class="n"&gt;infinite&lt;/span&gt; &lt;span class="m"&gt;1s&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;animationName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;translate3D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;translate3D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;360deg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;translate3D&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;-50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For the Web Animation API you would do something like this:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Representing the keyframes&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;animationName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rotate(0) translate3D(-50%, -50%, 0)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;rotate(360deg) translate3D(-50%, -50%, 0)&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Representing timing properties&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;animTiming&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;iterations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;Infinity&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//3. Applying the animation&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;element&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;animate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;animationName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;animTiming&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  ➡️ Where can I get more resources?
&lt;/h3&gt;

&lt;p&gt;Apart from the documentation linked above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://danielcwilson.com/blog/2015/07/animations-intro/" rel="noopener noreferrer"&gt;Let’s talk about the Web Animations API&lt;/a&gt; by Daniel C. Wilson.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://web.dev/web-animations/" rel="noopener noreferrer"&gt;Web Animations API improvements in Chromium 84&lt;/a&gt; by Una Kravets and Kevin Ellis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/web-animations/web-animations-js" rel="noopener noreferrer"&gt;web-animations-js&lt;/a&gt; by Web Animations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  2. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API" rel="noopener noreferrer"&gt;WebRTC&lt;/a&gt; 🔌
&lt;/h1&gt;
&lt;h3&gt;
  
  
  ➡️ What is it?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;WebRTC or Web Real-Time Communication is a technology that &lt;strong&gt;enables web apps and websites to store and stream audio/video media&lt;/strong&gt;, as well as to exchange data between browsers without the need of any plugin or a third-party software/tool.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  ➡️ Why use it?
&lt;/h3&gt;

&lt;p&gt;Because it supports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Media capture.&lt;/li&gt;
&lt;li&gt;Media streaming.&lt;/li&gt;
&lt;li&gt;Video and audio conferencing.&lt;/li&gt;
&lt;li&gt;File transfer.&lt;/li&gt;
&lt;li&gt;Screen share.&lt;/li&gt;
&lt;li&gt;Interfacing with legacy devices.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  ➡️ What about the browser support?
&lt;/h3&gt;

&lt;p&gt;Here's what &lt;a href="https://caniuse.com/rtcpeerconnection" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; says:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fggruchqnzbs4zi9laxk5.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fggruchqnzbs4zi9laxk5.png" alt="WebRTC Support"&gt;&lt;/a&gt;&lt;/p&gt;
93.91% usage


&lt;h3&gt;
  
  
  ➡️ How to write the code?
&lt;/h3&gt;

&lt;p&gt;Here's a quick example of sending a text message:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Signalling the server and greeting a user with a text message&lt;/span&gt;

&lt;span class="c1"&gt;//1. Get the WebSocket library &lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;WebSocketServer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ws&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="c1"&gt;//2. Create a server at port 8080&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;wss&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WebSocketServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;//3. User connects to the sever &lt;/span&gt;
&lt;span class="nx"&gt;wss&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;connection&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
   &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;user connected&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 

   &lt;span class="c1"&gt;//4. Server gets a message from a connected user &lt;/span&gt;
   &lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;message&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Got message from a user:&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
   &lt;span class="p"&gt;});&lt;/span&gt; 

   &lt;span class="nx"&gt;connection&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello from server&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  ➡️ Where can I get more resources?
&lt;/h3&gt;

&lt;p&gt;Apart from the documentation linked above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/webrtc/samples" rel="noopener noreferrer"&gt;samples repo&lt;/a&gt; by webrtc.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://webrtc.org/" rel="noopener noreferrer"&gt;WebRTC website&lt;/a&gt;.
-&lt;a href="https://codelabs.developers.google.com/codelabs/webrtc-web#0" rel="noopener noreferrer"&gt;Real time communication with WebRTC&lt;/a&gt; by Google Codelabs.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  3. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API" rel="noopener noreferrer"&gt;Web Speech API&lt;/a&gt; 🗣
&lt;/h1&gt;
&lt;h3&gt;
  
  
  ➡️ What is it?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The Web Speech API enables you to &lt;strong&gt;incorporate voice data&lt;/strong&gt; into your web apps. It has two parts: SpeechSynthesis (Text-to-Speech), and SpeechRecognition (Asynchronous Speech Recognition).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  ➡️ Why use it?
&lt;/h3&gt;

&lt;p&gt;In the year 2018, &lt;a href="https://www.thinkwithgoogle.com/data/voice-search-mobile-use-statistics/" rel="noopener noreferrer"&gt;Google reported&lt;/a&gt; that 27% of the global online population is using voice search on mobile.&lt;/p&gt;

&lt;p&gt;With speech-enabled, users can speak across the website to access the data they need.&lt;/p&gt;
&lt;h3&gt;
  
  
  ➡️ What about the browser support?
&lt;/h3&gt;

&lt;p&gt;Here's what &lt;a href="https://caniuse.com/speech-synthesis" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; says:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3smsrfusifdmi97dy704.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3smsrfusifdmi97dy704.png" alt="Web Speech API Support"&gt;&lt;/a&gt;&lt;/p&gt;
93.85% usage.


&lt;h3&gt;
  
  
  ➡️ How to write the code?
&lt;/h3&gt;

&lt;p&gt;I really liked the following example to showcase the speech API by Lindsay Greene, check out the article:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="https://medium.com/voice-tech-podcast/talk-to-me-beginners-tutorial-using-the-web-speech-api-8683cf736395" class="ltag__link__link" rel="noopener noreferrer"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fv2%2Fresize%3Afill%3A88%3A88%2F1%2ATVezBClhud7dlBKIQ5AWnw.png" alt="Lindsay Greene"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://medium.com/voice-tech-podcast/talk-to-me-beginners-tutorial-using-the-web-speech-api-8683cf736395" class="ltag__link__link" rel="noopener noreferrer"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;“Talk to Me” Beginner’s Tutorial: Using the web speech API | by Lindsay Greene | Voice Tech Podcast | Medium&lt;/h2&gt;
      &lt;h3&gt;Lindsay Greene ・ &lt;time&gt;Jan 19, 2021&lt;/time&gt; ・ 
      &lt;div class="ltag__link__servicename"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fmedium-f709f79cf29704f9f4c2a83f950b2964e95007a3e311b77f686915c71574fef2.svg" alt="Medium Logo"&gt;
        Medium
      &lt;/div&gt;
    &lt;/h3&gt;
&lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;h3&gt;
  
  
  ➡️ Where can I get more resources?
&lt;/h3&gt;

&lt;p&gt;Apart from the documentation linked above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.twilio.com/blog/speech-recognition-browser-web-speech-api" rel="noopener noreferrer"&gt;Speech to text in the browser with the Web Speech API&lt;/a&gt; by Phil Nash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/mdn/web-speech-api" rel="noopener noreferrer"&gt;web-speech-api repo&lt;/a&gt; by mdn.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://towardsdatascience.com/voice-to-text-with-chrome-web-speech-api-d98462cb0849" rel="noopener noreferrer"&gt;Voice to Text with Chrome Web Speech API&lt;/a&gt; by Benson Ruan.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  4. &lt;a href="https://www.w3.org/TR/webxr/" rel="noopener noreferrer"&gt;WebXR Device API (formerly WebVR)&lt;/a&gt; 🎮
&lt;/h1&gt;

&lt;h3&gt;
  
  
  ➡️ What is it?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The WebXR Device API &lt;strong&gt;implements the core of the WebXR feature set&lt;/strong&gt;, from the selection of output devices, rendering of the 3D scenes to the chosen device, and managing motion vectors created using input controllers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But what is this WebXR?&lt;/p&gt;

&lt;p&gt;Just like VR is Virtual Reality, AR is Augmented Reality and MR is Mixed Reality, in a similar fashion WebXR combines a group of standards that are used together to support rendering 3D scenes for VR, or for adding graphical imagery to AR.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➡️ Why use it?
&lt;/h3&gt;

&lt;p&gt;Although all these 'reality' based technologies are starting to boom, and you need a setup like below (which isn't much popular yet):&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%2Fmdn.mozillademos.org%2Ffiles%2F11035%2Fhw-setup.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%2Fmdn.mozillademos.org%2Ffiles%2F11035%2Fhw-setup.png" alt="WebXR Setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Still, with this enabled you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Render a 3D scene at an appropriate frame rate.&lt;/li&gt;
&lt;li&gt;Mirror the output to a 2D display.&lt;/li&gt;
&lt;li&gt;Create vectors representing the movements of input controls.&lt;/li&gt;
&lt;li&gt;Use the full potential of technologies like &lt;a href="https://developers.google.com/ar" rel="noopener noreferrer"&gt;ARCore&lt;/a&gt; or use hardware like &lt;a href="https://www.oculus.com/rift/" rel="noopener noreferrer"&gt;Oculus Rift&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Gain the benefit of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API" rel="noopener noreferrer"&gt;WebGL&lt;/a&gt;'s rich development tool ecosystem and a large&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ➡️ What about the browser support?
&lt;/h3&gt;

&lt;p&gt;Here's what &lt;a href="https://caniuse.com/webvr" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; says:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhjh0axxjvgg31204mzxa.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fhjh0axxjvgg31204mzxa.png" alt="WebXR Support"&gt;&lt;/a&gt;&lt;/p&gt;
7.09% usage.



&lt;h3&gt;
  
  
  ➡️ How to write the code?
&lt;/h3&gt;

&lt;p&gt;To access the WebXR API, we use &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/xr" rel="noopener noreferrer"&gt;&lt;code&gt;navigator.xr&lt;/code&gt;&lt;/a&gt; property of the current window which returns the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/XRSystem" rel="noopener noreferrer"&gt;&lt;code&gt;XRSystem&lt;/code&gt;&lt;/a&gt; object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Initiating the XR interface to use&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;xr&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;XRSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;requestHitTest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;device&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;xr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;requestDevice&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onNoXRDevice&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onNoXRDevice&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#enter-ar&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onEnterAR&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ➡️ Where can I get more resources?
&lt;/h3&gt;

&lt;p&gt;Apart from the documentation linked above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://immersiveweb.dev/" rel="noopener noreferrer"&gt;WebXR website&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://codelabs.developers.google.com/codelabs/ar-with-webxr#0" rel="noopener noreferrer"&gt;Building an augmented reality (AR) application using the WebXR Device API&lt;/a&gt; by Google Codelabs.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.smashingmagazine.com/2020/10/using-webxr-with-babylonjs/" rel="noopener noreferrer"&gt;Using WebXR With Babylon.js&lt;/a&gt; by Preston So.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  5. &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API" rel="noopener noreferrer"&gt;WebSocket&lt;/a&gt; 🎛
&lt;/h1&gt;

&lt;h3&gt;
  
  
  ➡️ What is it?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;The WebSocket API makes it possible to &lt;strong&gt;open a two-way interactive communication session between the client and a server&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  ➡️ Why use it?
&lt;/h3&gt;

&lt;p&gt;You can send messages to a server and receive event-driven responses without having to poll the server for a reply. So you can use it on social feeds, multiplayer games, collaborative environment, etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➡️ What about the browser support?
&lt;/h3&gt;

&lt;p&gt;Here's what &lt;a href="https://caniuse.com/mdn-api_websocket" rel="noopener noreferrer"&gt;caniuse.com&lt;/a&gt; says:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fas9vm9n89m0v251d59gk.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fas9vm9n89m0v251d59gk.png" alt="Websocket Support"&gt;&lt;/a&gt;&lt;/p&gt;
95.85% usage.



&lt;h3&gt;
  
  
  ➡️ How to write the code?
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// 1. Create a new WebSocket&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;exampleSocket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WebSocket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;wss://www.example.com/socketserver&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;protocolOne&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//2. Send data to the server&lt;/span&gt;
&lt;span class="nx"&gt;exampleSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Text to server&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//3. Closing the connection&lt;/span&gt;
&lt;span class="nx"&gt;exampleSocket&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ➡️ Where can I get more resources?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://spring.io/guides/gs/messaging-stomp-websocket/" rel="noopener noreferrer"&gt;Using WebSocket to build an interactive web application&lt;/a&gt; by Spring.io.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://blog.logrocket.com/websockets-tutorial-how-to-go-real-time-with-node-and-react-8e4693fbf843/" rel="noopener noreferrer"&gt;WebSockets tutorial: How to go real-time with Node and React&lt;/a&gt; by LogRocket.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://javascript.info/websocket" rel="noopener noreferrer"&gt;WebSocket&lt;/a&gt; by The Modern JavaScript Tutorial.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Hope you liked the information. You can comment below with your thoughts about it.&lt;/p&gt;

&lt;p&gt;And now...as always, enjoy a meme! 😆&lt;/p&gt;




&lt;h1&gt;
  
  
  The &lt;a href="https://twitter.com/search?q=%23devhumour&amp;amp;src=typed_query" rel="noopener noreferrer"&gt;#DevHumour&lt;/a&gt; Corner 😂
&lt;/h1&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fble8edl78i03op57qru2.jpeg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fble8edl78i03op57qru2.jpeg" alt="Dev Humour Image"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Some of my previous articles
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2"&gt;The importance of writing a technical article consistently. ✍️&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/vaibhavkhulbe/bring-the-power-of-semantic-html-to-make-a-hero-section-with-mvp-css-1dho"&gt;Bring the power of semantic HTML to make a hero section with MVP.css. 🕴&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/dailydotdev/create-a-crazy-input-interaction-with-lax-js-51fj"&gt;Create a crazy input interaction with lax.js. 🤪&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Find me on
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;a href="https://twitter.com/vaibhav_khulbe" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://instagram.com/vaibhavkhulbe143/" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://www.linkedin.com/in/vaibhav-khulbe/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/th&gt;
&lt;th&gt;&lt;a href="https://about.me/vaibhav_khulbe" rel="noopener noreferrer"&gt;Everywhere else&lt;/a&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>webdev</category>
      <category>html</category>
      <category>javascript</category>
      <category>css</category>
    </item>
    <item>
      <title>The importance of writing a technical article consistently. ✍️</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 25 Dec 2020 13:33:02 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2</link>
      <guid>https://forem.com/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2</guid>
      <description>&lt;blockquote&gt;
&lt;h3&gt;
  
  
  One article a week, throughout the year: My reflections
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yes, you read that correctly. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I wrote one article, each week, throughout the year 2020, consistently, there was no stopping me.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This was me, in the first week of the year:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/how-to-start-a-coding-project-making-sure-you-remember-it-months-later-42c5" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to start a coding project making sure you remember it months later 🌟&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Jan 1 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#project&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#code&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#programming&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;And this is me now, in the last week of the year:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/the-importance-of-writing-a-technical-article-consistently-3dh2" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;The importance of writing a technical article consistently. ✍️&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Dec 25 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#discuss&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#writing&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#productivity&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;In the first week, we didn’t know how harsh this year would be. I have seen, heard, and saw many people online (mostly) and offline saying, "2020 is the worst." Well, every time I would hear the words 2020 and worst together, I wondered "Why 2020 isn't bad for me? Why every third person I meet say the same thing?"&lt;/p&gt;

&lt;p&gt;Little did I knew I was to embark on a journey that would last forever with me. The journey isn’t just about writing articles, the journey is definitely about &lt;strong&gt;being consistent like mad&lt;/strong&gt;!&lt;/p&gt;

&lt;p&gt;In my last article of this year, I write some of the reflections I can pass to the readers. &lt;/p&gt;




&lt;h2&gt;
  
  
  What was my goal? 🎯
&lt;/h2&gt;

&lt;p&gt;More than a 'goal' or a 'target', this was my 'thought':&lt;/p&gt;

&lt;p&gt;I became active on DEV towards the end of December 2019. I just read posts, bookmarked, liked, commented (with a slight fear). Then I had a thought, &lt;em&gt;"Why do I just like and leave? Why can't I write here just like I did on &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;Medium&lt;/a&gt; for 3+ years?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And then, it was almost the 31st of the month, that morning I sat down to write some markdown. I decided to hit the 'Publish' button the next year. Nothing was planned. But the next week was about to start, so I drafted my 2nd article and the cycle continued from that day and hasn't stopped till now.&lt;/p&gt;

&lt;p&gt;That was that! Nothing fancy or crazy like writing on my notes and sticking them on my desk. &lt;strong&gt;The onset of thought was everything for me.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Quality of articles v/s quantity of articles. 🙃
&lt;/h2&gt;

&lt;p&gt;You may ask, "But Vaibhav, how do you get topics to write each week? You must've focused on &lt;em&gt;the more the articles, the better&lt;/em&gt; approach?"&lt;/p&gt;

&lt;p&gt;To which I would answer, "Hey! You know what, I just did what others would. &lt;strong&gt;I DOCUMENTED&lt;/strong&gt;. When you document what you are learning, working on, where and how you got solutions to your problems, how you solved them on your projects, what were you shortcoming, what you can share with others...then you just can't focus on the quantity!"&lt;/p&gt;

&lt;p&gt;I always made sure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I write what I'm working on at the present moment.&lt;/li&gt;
&lt;li&gt;I have a good knowledge of that topic. Not a God-level knowledge.&lt;/li&gt;
&lt;li&gt;I write with less complex words so that even a beginner in the dev industry can connect.&lt;/li&gt;
&lt;li&gt;I formatted and used a clear and good-grammar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And honestly, if I cared just about the numbers (followers, likes, engagement numbers) you would see a LOT of the following type of articles on my profile:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;THE TOP 10 LANGUAGES WHICH WILL GUARANTEE YOU TO GET A JOB!&lt;/li&gt;
&lt;li&gt;MY TOP VSCODE EXTENSIONS FOR EVERY DEVELOPER OUT THERE.&lt;/li&gt;
&lt;li&gt;GET THESE TIPS FROM A 3+ YEARS EXPERIENCED DEVELOPER TO SHINE LIKE A STAR.&lt;/li&gt;
&lt;li&gt;THE DEVELOPER ROADMAP YOU NEED TO FOLLOW NOW.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You get the idea, right? I already know these type of posts gets the maximum engaging, but how many of these give some &lt;em&gt;value&lt;/em&gt;?&lt;/p&gt;

&lt;h2&gt;
  
  
  So what benefits you got? 💐
&lt;/h2&gt;

&lt;p&gt;The one thing you can get by creating content consistently on any platform is that &lt;strong&gt;you improve your communication skills to a great extent&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Scared of talking in front of an audience, break out, give that talk (online/offline), in the same way, if you are not sure if someone will read what you write, just kill that thought for a moment and &lt;strong&gt;focus on the content&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By improving my communication (in my opinion more important than your technical skills), I got to showcase my talent, my projects, my concepts, my way of writing to a community. Thanks to this wonderful DEV Community, I get these comments:&lt;/p&gt;


&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/amansagar"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F472765%2Fffd5ab35-4c87-4b1a-92ab-aca746936574.jpg" alt="amansagar profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/amansagar"&gt;
        &lt;span class="comment-username"&gt;aman-sagar&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/amansagar/comment/16p6m" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Oct 16 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      &lt;p&gt;Okay, this was my first hacktober fest participation, was eager to choose plant a tree option, then my 4 pull requests got approved and passed the review period today. And then I thought of requesting a t-shirt, you know the craze of a hacktoberfest t-shirt, right? Then, i tried finding alternatives, found some, but then I thought of finding the some inspiration to plant a tree, I cam across your post, read it, and right away chose the plant a tree option.&lt;br&gt;
Thank you for inspiring me to plant a tree!!!......&lt;/p&gt;


    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/gagansingh"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F471504%2F62460d8d-b9fa-4dad-b5c3-2b6c3661ade3.png" alt="gagansingh profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/gagansingh"&gt;
        &lt;span class="comment-username"&gt;Gagandeep Singh&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/gagansingh/comment/17a20" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Oct 27 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      &lt;p&gt;I wanna say, you are awesome man!!&lt;br&gt;
Thanks for sharing such a rich content.&lt;/p&gt;


    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/binyamin"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F252160%2F4446a5fc-3de3-46a7-8cb3-9a8427baa3a4.png" alt="binyamin profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/binyamin"&gt;
        &lt;span class="comment-username"&gt;Binyamin Green&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/binyamin/comment/m821" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Mar 4 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      

&lt;p&gt;This is one of those moments where I wish I could &lt;em&gt;save comments&lt;/em&gt; on DEV!&lt;br&gt;
&lt;a class="comment-mentioned-user" href="https://dev.to/ben"&gt;@ben&lt;/a&gt;
 nudge nudge&lt;/p&gt;



    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/timrodz"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F235832%2F97ae9026-42d7-4100-add1-fb3b058a31dc.jpg" alt="timrodz profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/timrodz"&gt;
        &lt;span class="comment-username"&gt;Juan Alejandro Morais&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/timrodz/comment/m8ef" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Mar 5 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      

&lt;p&gt;Thanks for this great article, Vaibhav. It will definitely help me, and many others, in their writing journey.&lt;/p&gt;

&lt;p&gt;All the best! :)&lt;/p&gt;



    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/ridhikgovind"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F399884%2Fda2cf288-a8ad-442c-81d5-008fcb3dd964.jpeg" alt="ridhikgovind profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/ridhikgovind"&gt;
        &lt;span class="comment-username"&gt;Ridhik Govind&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/ridhikgovind/comment/1779f" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Oct 25 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      &lt;p&gt;What an article man ! No doubt its one of the best articles I've read ! Keep up with the good writing !&lt;/p&gt;


    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="liquid-comment"&gt;
    &lt;div class="details"&gt;
      &lt;a href="/dhruvamsharma"&gt;
        &lt;img class="profile-pic" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F280060%2F04389416-b70e-4e2e-b58f-8f8bf4acd6fc.png" alt="dhruvamsharma profile image"&gt;
      &lt;/a&gt;
      &lt;a href="/dhruvamsharma"&gt;
        &lt;span class="comment-username"&gt;Dhruvam&lt;/span&gt;
      &lt;/a&gt;
      &lt;span class="color-base-30 px-2 m:pl-0"&gt;•&lt;/span&gt;

&lt;a href="https://dev.to/dhruvamsharma/comment/ji9n" class="comment-date crayons-link crayons-link--secondary fs-s"&gt;
  &lt;time class="date-short-year"&gt;
    Jan 1 '20
  &lt;/time&gt;

&lt;/a&gt;

    &lt;/div&gt;
    &lt;div class="body"&gt;
      

&lt;p&gt;Amazing article. Made me want to go into self-introspection right away. Keep writing and inspiring :)&lt;/p&gt;



    &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;And much more to me on &lt;a href="https://about.me/vaibhav_khulbe" rel="noopener noreferrer"&gt;my socials&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Oh, before I forget...&lt;a href="https://dev.to/nimrodkra"&gt;@NimrodKramer&lt;/a&gt;'s 👇&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What I really appreciate about &lt;a href="https://twitter.com/vaibhav_khulbe?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;@vaibhav_khulbe&lt;/a&gt; is his consistency. Every day he reads a few articles and shares his insight. Let alone the incredible and thoughtful posts he writes every week. A true role model for self-learning. &lt;br&gt;&lt;br&gt;Do yourself a favor and follow him ASAP 🎸 &lt;a href="https://t.co/cDIsIDeOxA" rel="noopener noreferrer"&gt;https://t.co/cDIsIDeOxA&lt;/a&gt;&lt;/p&gt;— Nimrod Kramer (@NimrodKramer) &lt;a href="https://twitter.com/NimrodKramer/status/1331618980621062145?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;November 25, 2020&lt;/a&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not only I published articles weekly, the 'consistent me', did the following throughout the year:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Composed &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;my weekly dev newsletter&lt;/a&gt;&lt;/strong&gt; with more than 50+ resources.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;strong&gt;&lt;a href="https://www.goodreads.com/user/show/110007458-vaibhav-khulbe" rel="noopener noreferrer"&gt;read 6+ books&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;summarised in my own words&lt;/strong&gt; on &lt;a href="https://instagram.com/vaibhavkhulbe143/" rel="noopener noreferrer"&gt;my Instagram&lt;/a&gt; stories.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;strong&gt;&lt;a href="https://github.com/Kvaibhav01" rel="noopener noreferrer"&gt;wrote code&lt;/a&gt;&lt;/strong&gt;, each day (minus the weekends). I honestly don’t do #100DaysOfCode! 😂 &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;strong&gt;improved &lt;a href="https://www.behance.net/Kvaibhav01163c" rel="noopener noreferrer"&gt;my UI/UX design&lt;/a&gt; skills&lt;/strong&gt;. For each of my articles, I designed &lt;a href="https://instagram.com/vaibhavkhulbe143/" rel="noopener noreferrer"&gt;Instagram carousel posts&lt;/a&gt; on Adobe XD.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I &lt;strong&gt;got 5 freelance offers all because I was consistent&lt;/strong&gt;. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;What more examples you need than these!?&lt;/p&gt;

&lt;h2&gt;
  
  
  What are your own favorite articles? 👀
&lt;/h2&gt;

&lt;p&gt;Of course, I will say, "Most of them are...can't decide". But, if I had to nit-pick (in no particular order):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/hacktoberfest-through-a-different-lens-8o0"&gt;Hacktoberfest - through a different lens. 🌳&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/how-to-start-a-coding-project-making-sure-you-remember-it-months-later-42c5"&gt;How to start a coding project making sure you remember it months later 🌟&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/create-a-css-art-without-html-3deb"&gt;Create a CSS art without HTML. 🤯&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/framer-motion-beautiful-animations-and-interactions-for-react-1d56"&gt;Framer Motion - beautiful animations and interactions for React. 🤤&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/spring-it-on-a-complete-guide-to-react-spring-1om9"&gt;Spring it on! The complete guide to React Spring. 🧵&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/it-s-time-to-supercharge-your-html-skills-5b6k"&gt;It's time to supercharge your HTML skills! 🔋&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/the-web-without-css-18d"&gt;The Web without CSS. 😿&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/your-guide-to-github-actions-in-5-steps-41ma"&gt;Your guide to GitHub Actions in 5 steps 📚&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/networking-and-open-source-the-what-and-the-why-3n1h"&gt;Networking and Open Source: The What and the Why 👐&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://dev.to/vaibhavkhulbe/hello-test-55l1"&gt;Demystifying 20 lesser-known React terms and features (With examples) 🔮&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The bottom line. ⚡️
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  I'm not saying write articles regularly, write consistently.
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;And never forget:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;em&gt;You need to make sacrifices to achieve a goal. Go make that sacrifice!&lt;/em&gt;
&lt;/h3&gt;




&lt;h4&gt;
  
  
  The sole aim to write this article towards the end of the year was so that I get to know how well I followed my 'thought', how disciplined I am to get results, and what value I can bring to the community.
&lt;/h4&gt;

&lt;p&gt;I could have shown you my stats, how many reactions I got, how many total views are there, and how many people follow me here, but I NEVER believe in these numbers. Just take a sweet guess while you &lt;a href="https://dev.to/vaibhavkhulbe"&gt;visit my profile&lt;/a&gt;. :)&lt;/p&gt;

&lt;p&gt;Hope some of my articles helped you in a way or two. Merry Christmas 🎄 and Happy Holidays! 😄&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;This &lt;a href="https://twitter.com/hashtag/microservices?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#microservices&lt;/a&gt; architecture is only suitable for children/developers age 3 and upwards ⚠️&lt;a href="https://twitter.com/hashtag/microservices?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#microservices&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/microprofile?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#microprofile&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Devhumour?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Devhumour&lt;/a&gt; &lt;a href="https://twitter.com/turnoff_us?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;@turnoff_us&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/monolith?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#monolith&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/programminghumour?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#programminghumour&lt;/a&gt; &lt;a href="https://t.co/eCHmdGZkoD" rel="noopener noreferrer"&gt;pic.twitter.com/eCHmdGZkoD&lt;/a&gt;&lt;/p&gt;— Payara (@Payara_Fish) &lt;a href="https://twitter.com/Payara_Fish/status/1341686288974528512?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;December 23, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>discuss</category>
      <category>writing</category>
      <category>productivity</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Bring the power of semantic HTML to make a hero section with MVP.css. 🕴</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 18 Dec 2020 13:45:55 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/bring-the-power-of-semantic-html-to-make-a-hero-section-with-mvp-css-1dho</link>
      <guid>https://forem.com/vaibhavkhulbe/bring-the-power-of-semantic-html-to-make-a-hero-section-with-mvp-css-1dho</guid>
      <description>&lt;p&gt;What do you call a developer who can make efficient websites with ease? A developer who is ever-ready to finish making landing pages like a pro, or a dev who literally doesn't use any cool frameworks out there but still manages to output a world-class product? &lt;/p&gt;

&lt;p&gt;You may call them: "Most Valuable Dev (MVD)".&lt;/p&gt;

&lt;p&gt;But what if a new dev comes, they just take the bare minimum, focus on &lt;em&gt;meaning&lt;/em&gt; and &lt;em&gt;structures&lt;/em&gt; the code to the best of their knowledge, and still does very best then that MVD? &lt;/p&gt;

&lt;p&gt;You should definitely call them: "Most Valuable Professional (MVP)".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/xdEAArhWF50cM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xdEAArhWF50cM/giphy.gif" alt="MVP Gif"&gt;&lt;/a&gt;&lt;/p&gt;
You got to have some respect for that MVP 



&lt;p&gt;Now, what all was this for? How does an MVP have to do with a developer? Let's take a look.&lt;/p&gt;




&lt;h1&gt;
  
  
  No class names, no frameworks, just semantic HTML, and you're done!
&lt;/h1&gt;

&lt;p&gt;That's not what I promise, that's exactly what MVP.css promises it to be!&lt;/p&gt;

&lt;h3&gt;
  
  
  What is &lt;a href="https://andybrewer.github.io/mvp/" rel="noopener noreferrer"&gt;MVP.css&lt;/a&gt;?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;It is a &lt;strong&gt;minimalist stylesheet for HTML elements&lt;/strong&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Counting on features? Here are some:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Out of the box &lt;em&gt;CSS styling&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;No &lt;em&gt;class names&lt;/em&gt; or no &lt;em&gt;framework(s)&lt;/em&gt; to learn.&lt;/li&gt;
&lt;li&gt;Uses semantic HTML.&lt;/li&gt;
&lt;li&gt;Straight up HTML and nothing else.&lt;/li&gt;
&lt;li&gt;Responsive by default.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have previously tried a similar library where with just HTML, you can have a decent looking webpage.&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/style-your-next-blog-with-vanilla-html-no-css-dc8" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Style your next blog with vanilla HTML. No CSS. 😵&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Jun 12 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#html&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;But that had some specific tags and was geared towards a more complex approach I guess. Here, MVP.css tries to simplify things way more.&lt;/p&gt;

&lt;p&gt;In my opinion, if you need a quick 'starter-template' for your next e-book, product, or you made a really awesome dev library, then this can definitely help. The process is extremely fast, the webpage you get is lightweight, and it follows semantic rules! &lt;/p&gt;

&lt;h3&gt;
  
  
  What we will be making?
&lt;/h3&gt;

&lt;p&gt;This:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fth1zjj90gki56o3ddxn8.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fth1zjj90gki56o3ddxn8.png" alt="MVP.css landing page"&gt;&lt;/a&gt;&lt;/p&gt;
We are not much concerned about the design, but more on the overall building process.



&lt;p&gt;Consider (the aptly named) "Ideanator" to be a fictional service provider whose aim is to make online products. Here are a few things this hero section has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The navigation (with dropdown).&lt;/li&gt;
&lt;li&gt;The sale banner.&lt;/li&gt;
&lt;li&gt;The heading, subheading, and call-to-action buttons.&lt;/li&gt;
&lt;li&gt;The testimonial.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pretty basic of course but let's see how it's done.&lt;/p&gt;

&lt;h4&gt;
  
  
  ➡️ Step 1: Add the MVP to your webpage
&lt;/h4&gt;

&lt;p&gt;There's literally ZERO configuration you need in order to start. No need for any &lt;code&gt;npm install&lt;/code&gt; or some complex SDK integration. Simply load the core &lt;em&gt;mvp.css&lt;/em&gt; file to your &lt;em&gt;index.html&lt;/em&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://unpkg.com/mvp.css"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h4&gt;
  
  
  ➡️ Step 2: Start making the structure!
&lt;/h4&gt;

&lt;p&gt;The game of MVPs is all about being semantic. If you're unsure what semantic HTML means take a look at &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Semantics#Semantics_in_HTML" rel="noopener noreferrer"&gt;this MDN documentation&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;According to them, there are around 100 semantic HTML elements including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;article&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;details&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;figcaption&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/footer" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/header" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/main" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;mark&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/nav" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/section" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/summary" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;summary&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;time&amp;gt;&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, these elements are supported but there are a few more that can spice things up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/blockquote" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;code&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;pre&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/samp" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;samp&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/small" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;small&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;sup&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/table" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ones that are &lt;strong&gt;bold&lt;/strong&gt;, we can make use of those.&lt;/p&gt;

&lt;p&gt;Let's start with the &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;. This houses our &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; with &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; / &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; lists and the headings. As for the following dropdown:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnvj6szkdqib011f9hije.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnvj6szkdqib011f9hije.gif" alt="MVP dropdown"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This can be achieved by simply adding a set of lists under an &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt; as shown:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Learn more&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;About us&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Contact us&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Get help&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next up we have the sale tagline. I thought that can be a good use case of the &lt;code&gt;&amp;lt;article&amp;gt;&lt;/code&gt; tag to achieve the desired result. So, inside it, we will have our &lt;code&gt;&amp;lt;aside&amp;gt;&lt;/code&gt; with the text needed. Now to center the text, we can surely use the famous CSS trick of &lt;code&gt;text-align&lt;/code&gt; but as we are some kind of MVP, so we will use HTML's native &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center" rel="noopener noreferrer"&gt;&lt;code&gt;&amp;lt;center&amp;gt;&lt;/code&gt;&lt;/a&gt; tag. 😎&lt;/p&gt;

&lt;p&gt;That quirky "MADE WITH ❤️ IN MY BACKYARD" might look cliché but that can be a good use of some of the skills to showcase! It's done with the help of the &lt;code&gt;&amp;lt;sup&amp;gt;&lt;/code&gt; tag. Sup!? This is generally a superscript tag but MVP.css makes it look so cool!&lt;/p&gt;

&lt;p&gt;The heading is simply the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag with a few not-so-common mark and &lt;code&gt;code&lt;/code&gt; tags.&lt;/p&gt;

&lt;p&gt;As for the CTA buttons, they simply don’t use the usual &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; tag. A nice trick is to use the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; along with the &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; anchor tag for adding links. MVP will take care of the rest.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Where ideas &lt;span class="nt"&gt;&amp;lt;mark&amp;gt;&lt;/span&gt;thrive&lt;span class="nt"&gt;&amp;lt;/mark&amp;gt;&lt;/span&gt; with &lt;span class="nt"&gt;&amp;lt;code&amp;gt;&lt;/span&gt;code&lt;span class="nt"&gt;&amp;lt;/code&amp;gt;&lt;/span&gt;.&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;We are world's &lt;span class="nt"&gt;&amp;lt;b&amp;gt;&lt;/span&gt;#1&lt;span class="nt"&gt;&amp;lt;/b&amp;gt;&lt;/span&gt; idea building company 💡 
coding all night long 👨🏻‍💻 &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;br&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- CTA BUTTONS --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;i&amp;gt;&lt;/span&gt;Get Quote&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;b&amp;gt;&lt;/span&gt;
Get Started &lt;span class="ni"&gt;&amp;amp;rarr;&lt;/span&gt;&lt;span class="nt"&gt;&amp;lt;/b&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The content section comes next, which semantically means the &lt;code&gt;&amp;lt;main&amp;gt;&lt;/code&gt; area. So that the hero section doesn't become too long (or becomes longer than the viewport), we will just include a testimonial here.&lt;/p&gt;

&lt;p&gt;What great way to make a testimonial with the actual quote and the quoter's name than using the &lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt;. Inside this, you can write the quote sentence (and can make it italic with the &lt;code&gt;&amp;lt;i&amp;gt;&lt;/code&gt; tag). As for the name, the &lt;code&gt;&amp;lt;footer&amp;gt;&lt;/code&gt; is more than enough for us. It gives us the perfect style needed.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;

&lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;blockquote&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;"One of the best services you can get in the year 2020."&lt;span class="nt"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;- &lt;span class="nt"&gt;&amp;lt;b&amp;gt;&lt;/span&gt;PEETER LOO&lt;span class="nt"&gt;&amp;lt;/b&amp;gt;&lt;/span&gt;, COO, Kingley Products Inc&lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/blockquote&amp;gt;&lt;/span&gt;   
&lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Boom! We are done. 🙊&lt;/p&gt;

&lt;p&gt;Hah, two steps in, and you got a solid landing page! That's was super quick if you ask me. ⚡️&lt;/p&gt;

&lt;p&gt;Here's the CodePen of the above example for you to try:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/kvaibhav01/embed/vYXmXJO?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h1&gt;
  
  
  More resources 🤩
&lt;/h1&gt;

&lt;p&gt;Be a good MVP and follow these pieces online for better understanding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/mvp.css" rel="noopener noreferrer"&gt;MVP.css on NPM&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://andybrewer.github.io/mvp/" rel="noopener noreferrer"&gt;Live demo of a landing page made with MVP.css&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/andybrewer/mvp" rel="noopener noreferrer"&gt;MPV.css GitHub repo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading. I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;This week's Dev Humour. 😂 👇&lt;a href="https://twitter.com/hashtag/DevHumour?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#DevHumour&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Developer?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Developer&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Programmer?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Programmer&lt;/a&gt; &lt;a href="https://t.co/369TOve9FP" rel="noopener noreferrer"&gt;pic.twitter.com/369TOve9FP&lt;/a&gt;&lt;/p&gt;— Microsoft Developer UK (@msdevUK) &lt;a href="https://twitter.com/msdevUK/status/1334896574137323520?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;December 4, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>html</category>
      <category>css</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create a crazy input interaction with lax.js. 🤪</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 11 Dec 2020 13:26:31 +0000</pubDate>
      <link>https://forem.com/dailydotdev/create-a-crazy-input-interaction-with-lax-js-51fj</link>
      <guid>https://forem.com/dailydotdev/create-a-crazy-input-interaction-with-lax-js-51fj</guid>
      <description>&lt;p&gt;What's common between circles turning to cubes, pair of shoes swinging around left to right, that cube experiencing &lt;em&gt;inertia&lt;/em&gt; (yes, that physics thing), a text dancing when your cursor meets it, or you are just typing things in a text field and bam! That thing rotates like hell for no reason!&lt;/p&gt;

&lt;p&gt;Well, what I'm even talking about?  ┐(￣ヘ￣;)┌&lt;/p&gt;

&lt;p&gt;I'm talking about some weird and super crazy web experiences you can make (including the examples I gave above) just to have some fun in your websites or implement them cautiously to make a website visitor feel joyful! &lt;/p&gt;

&lt;p&gt;Meet this JavaScript library that can make things look cool with crazy interactions. It's called LAX! &lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/xEGqih6o0meyY/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/xEGqih6o0meyY/giphy.gif" alt="Relax GIF" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;
Don't just relax, but lax...!






&lt;h1&gt;
  
  
  What do I mean by &lt;del&gt;re&lt;/del&gt;lax.js? 🧐
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/alexfoxy/lax.js"&gt;&lt;strong&gt;Lax.js&lt;/strong&gt;&lt;/a&gt; is a JavaScript library to create &lt;strong&gt;smooth &amp;amp; beautiful animations&lt;/strong&gt; when you &lt;strong&gt;scroll&lt;/strong&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But that's not all! Lax is really, really small. When gzipped, it's &lt;em&gt;less than 4 kilobytes in size&lt;/em&gt;! 🤯&lt;/p&gt;

&lt;h3&gt;
  
  
  Here are some of its features:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;It has a new JS animation syntax for advanced animation combinations to work on.&lt;/li&gt;
&lt;li&gt;Now, animations can be given a kick of &lt;em&gt;interia&lt;/em&gt; while scrolling.&lt;/li&gt;
&lt;li&gt;It comes with nice animation easings.&lt;/li&gt;
&lt;li&gt;You can create custom CSS bindings.&lt;/li&gt;
&lt;li&gt;Not only scroll-based, but animations can also be done while typing (we will do a demo of this later), scroll positions, or even according to date and time! &lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  What will we make? 👀
&lt;/h1&gt;

&lt;p&gt;This:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7qk1n3strniksw0nk8l3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7qk1n3strniksw0nk8l3.gif" alt="Lax.js demo" width="270" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whoops! We are not doing a scroll but an input interaction here. 🤪&lt;/p&gt;

&lt;h1&gt;
  
  
  Let's create this input interaction 🌚
&lt;/h1&gt;

&lt;h3&gt;
  
  
  The HTML
&lt;/h3&gt;

&lt;p&gt;Add an &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; field to a new or an existing project file. Make sure you give it a proper &lt;code&gt;id&lt;/code&gt; as it will be needed later when we code the Lax logic. &lt;/p&gt;

&lt;p&gt;Optionally, you can give it the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-autofocus"&gt;&lt;code&gt;autofocus&lt;/code&gt;&lt;/a&gt; attribute so that when the page loads, it automatically focusses on the input. This way, we can start typing weird words right away without the need of having to click on the input field. Also, we should give some &lt;code&gt;placeholder&lt;/code&gt; value to it. Here I have just used a cute smiling kaomoji, but you can have something like, "Input here" or "type here".&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'input'&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"(⊃｡•́‿•̀｡)"&lt;/span&gt; &lt;span class="na"&gt;autofocus&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The CSS
&lt;/h3&gt;

&lt;p&gt;Time to make it looks like a dull stick :') I won't explain each CSS rule here, just the ones so that it looks somewhat like our finished version.&lt;/p&gt;

&lt;p&gt;To start, remove all the borders and outlines, and give it a &lt;code&gt;background-color&lt;/code&gt; of &lt;code&gt;#95853B&lt;/code&gt;. As for the black colored outline you see, it's a shadow added to the element. I have used both &lt;code&gt;rgba()&lt;/code&gt; and &lt;code&gt;rgb()&lt;/code&gt; methods to achieve the result. Add a bit of &lt;code&gt;padding&lt;/code&gt;, center the text, and give it a base &lt;code&gt;font-size&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;30%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#95853B&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0.16&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="m"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
                &lt;span class="nb"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;51&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;51&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nd"&gt;::placeholder&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Lax.js!
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Installation ⬇️
&lt;/h4&gt;

&lt;p&gt;You can use both Yarn or NPM scripts to install the library:&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 lax.js
// OR
yarn add lax.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And then in your JS file, import it as usual:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;lax&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lax.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, as I did here for the demo, grab its CDN file from &lt;a href="https://www.jsdelivr.com/"&gt;JS Delivr&lt;/a&gt; to add it on top of your HTML &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tags.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://cdn.jsdelivr.net/npm/lax.js"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Setup 🛠
&lt;/h4&gt;

&lt;p&gt;For the library to work, what we need is a &lt;em&gt;driver&lt;/em&gt; at least one of the lot as it provides values for our animations, as well as the element animation bindings. This is done by the &lt;a href="https://github.com/alexfoxy/lax.js/blob/362595b5db5428477b31d3564434c35abf8f1589/src/lax.js#L539"&gt;&lt;code&gt;addDriver()&lt;/code&gt;&lt;/a&gt; method.&lt;/p&gt;

&lt;h4&gt;
  
  
  Make some interaction! ✨
&lt;/h4&gt;

&lt;p&gt;We want our interaction to start on page load, or more specifically, whenever the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window"&gt;&lt;code&gt;Window&lt;/code&gt;&lt;/a&gt; is attached to the DOM. Therefore, we make use of its &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onload"&gt;&lt;code&gt;onload&lt;/code&gt;&lt;/a&gt; event handler to create a function that will house all of the Lax code.&lt;/p&gt;

&lt;p&gt;Next, we initialize the library by using the &lt;a href="https://github.com/alexfoxy/lax.js/blob/362595b5db5428477b31d3564434c35abf8f1589/src/lax.js#L488"&gt;&lt;code&gt;init()&lt;/code&gt;&lt;/a&gt; method.&lt;/p&gt;

&lt;p&gt;As we gave an &lt;code&gt;id&lt;/code&gt; to the input in the HTML code, here, we will use it to grab the element and store it inside the &lt;code&gt;input&lt;/code&gt; variable. This is a simple JS thing we do all day...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember I said we need to add a driver? Now we will use this driver to control the animation. Simply call &lt;code&gt;lax.addDriver()&lt;/code&gt;. This takes in the &lt;em&gt;animation value&lt;/em&gt; and a function that returns the &lt;em&gt;calculated amount&lt;/em&gt;. In our case, it is the &lt;code&gt;inputLength&lt;/code&gt; and calculating the total length of characters added in the input element.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;lax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addDriver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;inputLength&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, to actually start triggering the interaction, what we need is to use &lt;a href="https://github.com/alexfoxy/lax.js/blob/362595b5db5428477b31d3564434c35abf8f1589/src/lax.js#L574"&gt;&lt;code&gt;addElements()&lt;/code&gt;&lt;/a&gt; that takes in an &lt;em&gt;element selector rule&lt;/em&gt; along with the &lt;em&gt;animation data&lt;/em&gt;. Hence, we select &lt;code&gt;#input&lt;/code&gt; and &lt;code&gt;inputLength&lt;/code&gt; we defined previously for this. &lt;/p&gt;

&lt;p&gt;If you notice, as soon as we start typing inside the input field, it does two things simultaneously; first, it &lt;em&gt;rotates&lt;/em&gt; anticlockwise, and also it &lt;em&gt;fades&lt;/em&gt; at some specific speed. This effect is achieved by using both &lt;code&gt;rotate&lt;/code&gt; and &lt;code&gt;opacity&lt;/code&gt; &lt;a href="https://github.com/alexfoxy/lax.js#css-properties"&gt;CSS properties&lt;/a&gt; that is supported by the Lax library.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rotate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now from where those numbers come from? Well, technically, they are called &lt;a href="https://github.com/alexfoxy/lax.js#value-maps"&gt;Value Maps&lt;/a&gt;. These are used to manipulate the driver or CSS property values. The two values inside an object are the &lt;em&gt;In&lt;/em&gt; and &lt;em&gt;Out&lt;/em&gt; values. For example, the rotation above starts from &lt;code&gt;0&lt;/code&gt;, rotates from right to left to &lt;code&gt;180&lt;/code&gt; degrees, and then to a complete circle of &lt;code&gt;160&lt;/code&gt; degrees.&lt;/p&gt;

&lt;p&gt;The same goes for opacity. To make it look like a fade-in animation, we start from &lt;code&gt;0&lt;/code&gt; i.e. no fade to &lt;code&gt;1&lt;/code&gt; i.e. complete fade.&lt;/p&gt;

&lt;p&gt;Here's the complete JS code for your reference:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onload&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;lax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

      &lt;span class="nx"&gt;lax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addDriver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;inputLength&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="nx"&gt;lax&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addElements&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#input&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;inputLength&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rotate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;360&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
          &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's the CodePen embed for you to play around :')&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/kvaibhav01/embed/GRjJaXQ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h1&gt;
  
  
  More resources 🤩
&lt;/h1&gt;

&lt;p&gt;Go ahead with and learn more about Lax to make soothing interactions from these resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/alexfoxy/lax.js"&gt;Lax.js GitHub repo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://codepen.io/alexfoxy/pen/ZPRZBq"&gt;Lax.js Vue Example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/jaVy3SCibJw"&gt;Laxxx.js - An Awesome Scroll Animation Library that's Only 2KB! by DesignCourse&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading. I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;🙄 &lt;a href="https://t.co/1G4L5SedDv"&gt;pic.twitter.com/1G4L5SedDv&lt;/a&gt;&lt;/p&gt;— Sasha Rosenbaum (@DivineOps) &lt;a href="https://twitter.com/DivineOps/status/1329244198009262082?ref_src=twsrc%5Etfw"&gt;November 19, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://api.daily.dev/get?r=devto"&gt;daily.dev&lt;/a&gt; delivers the best programming news every new tab. We will rank hundreds of qualified sources for you so that you can hack the future.&lt;/em&gt;&lt;br&gt;
&lt;a href="https://api.daily.dev/get?r=devto"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb996k4sm4efhietrzups.png" alt="Daily Poster" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CSS: Overscroll, Overflow &amp; Touch Actions. ⛷</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 04 Dec 2020 13:42:26 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/css-overscroll-overflow-touch-actions-4lhb</link>
      <guid>https://forem.com/vaibhavkhulbe/css-overscroll-overflow-touch-actions-4lhb</guid>
      <description>&lt;p&gt;Okay, three more cool CSS properties before we end this year. Just for a quick recap, previously I have covered topics like subgrids, writing modes, color gamut, etc. Check out what all it's about: &lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/css-color-gamut-containment-344a" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;CSS: Color gamut &amp;amp; Containment. 🌈&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Oct 23 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#html&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;



&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/css-subgrids-multi-column-and-writing-modes-3jk7" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;CSS: Subgrids, Multi-column, &amp;amp; Writing Modes. 🥸&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Nov 20 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#html&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Alright then, now it's time to know more about what is overscroll, how overflow can help and why do you even need something like touch actions!&lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/POJt9CrJmvN5PageSf/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/POJt9CrJmvN5PageSf/giphy.gif" alt="Overflow GIF"&gt;&lt;/a&gt;&lt;/p&gt;
Let that brew overflow!!






&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior" rel="noopener noreferrer"&gt;CSS Overscroll&lt;/a&gt;
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;overscroll&lt;/strong&gt; property tells the browser what to do when the body content reaches the boundary of the scroll area. Hence the name over-scroll.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So whenever you don't add any overscroll property in your web projects, it defaults to &lt;code&gt;auto&lt;/code&gt;. On mobile, you might have experienced a &lt;em&gt;bounce&lt;/em&gt; effect when you try to scroll to the bottom (or top) of the page, this behavior of a webpage is controlled by overscroll.&lt;/p&gt;

&lt;p&gt;Usually, you will end up using one of the following two properties:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior-x" rel="noopener noreferrer"&gt;&lt;strong&gt;overscroll-behavior-x&lt;/strong&gt;&lt;/a&gt;: to handle the browser scroll behavior when the horizontal (x-axis) boundary is reached.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior-y" rel="noopener noreferrer"&gt;&lt;strong&gt;overscroll-behavior-y&lt;/strong&gt;&lt;/a&gt;: it's the same thing as above but on the vertical (y-axis) boundary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also, you might have also used these properties to hide the default scrollbar of a webpage. If not, here's how to do it:&lt;/p&gt;

&lt;p&gt;Simply go to your CSS file and add the following lines of code to the &lt;code&gt;body&lt;/code&gt; element:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;overflow-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Hide vertical scrollbar */&lt;/span&gt;
  &lt;span class="nl"&gt;overflow-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Hide horizontal scrollbar */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Of course, I won't recommend you to completely get rid of scrollbars (unless you have an accessible custom scrollbar) but for some small demos, this trick is helpful.&lt;/p&gt;

&lt;p&gt;Some of the keyword values supported by overscroll are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overscroll-behavior: auto;&lt;/code&gt;&lt;/strong&gt; The default mode on all webpages. Does, practically, nothing :')&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overscroll-behavior: contain;&lt;/code&gt;&lt;/strong&gt; This will prevent scrolling on underlying elements.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overscroll-behavior: none;&lt;/code&gt;&lt;/strong&gt; The default behavior is prevented and quite common in removing scrollbars :')&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🤩 &lt;strong&gt;Some overscroll resources!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/almanac/properties/o/overscroll-behavior/" rel="noopener noreferrer"&gt;overscroll-behavior on CSS Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developers.google.com/web/updates/2017/11/overscroll-behavior" rel="noopener noreferrer"&gt;Take control of your scroll: customizing pull-to-refresh and overflow effects by Google Web Developers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.smashingmagazine.com/2018/08/scroll-bouncing-websites/" rel="noopener noreferrer"&gt;Scroll Bouncing On Your Websites by Smashing Magazine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Up next...&lt;/p&gt;

&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overflow" rel="noopener noreferrer"&gt;CSS Overflow&lt;/a&gt;
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;overflow&lt;/strong&gt; is a CSS shorthand property that is used to set the, well, the &lt;strong&gt;overflow behavior of an element&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you see content that is overflowing its parent element's boundary, then it's likely that the overflow is &lt;em&gt;visible&lt;/em&gt; and you need to fix this by hiding the overflowing content.&lt;/p&gt;

&lt;p&gt;Check this cool example:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5rkd8k6fx5kpijnji4fa.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5rkd8k6fx5kpijnji4fa.png" alt="Overflow example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Did you notice how the text is just overflowing from its container? It's most likely that they have used something like &lt;code&gt;overflow: visible;&lt;/code&gt;. Now, what are the different options we have here?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overflow: visible;&lt;/code&gt;&lt;/strong&gt; This is the default behavior which is, yes, pretty bad when you have that para or an image overflowing on a card layout. &lt;em&gt;The content is not clipped and is rendered outside the defined margin/padding&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overflow: hidden;&lt;/code&gt;&lt;/strong&gt; That's your rescue! Now the &lt;em&gt;content is clipped&lt;/em&gt; (as it should be) but &lt;em&gt;note that there will not be any scrollbars added&lt;/em&gt; for you here. Also, you won't be able to drag, scroll in any direction.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overflow: scroll;&lt;/code&gt;&lt;/strong&gt; You got the scrollbars here! But the &lt;em&gt;content is still clipped&lt;/em&gt; according to the padding. Note that the &lt;em&gt;scrollbar will always be visible&lt;/em&gt; no matter what. :')&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;overflow: auto;&lt;/code&gt;&lt;/strong&gt; This will &lt;em&gt;automatically decide whether to clip the content or not&lt;/em&gt;. If there the content fits inside the container, it will be similar to the default &lt;code&gt;visible&lt;/code&gt; behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To achieve this scroll:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkoi8xl5ryfd53bqcc6j6.gif" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fkoi8xl5ryfd53bqcc6j6.gif" alt="Overscroll enabled GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You need to add the following in your CSS:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;12em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;6em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;overflow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;scroll&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* always show scrollbars */&lt;/span&gt; 
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;🤩 &lt;strong&gt;Some overflow resources!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/the-css-overflow-property/" rel="noopener noreferrer"&gt;The CSS Overflow Property on CSS Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/findingfixing-unintended-body-overflow/" rel="noopener noreferrer"&gt;Finding/Fixing Unintended Body Overflow by CSS Tricks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Debug_Scrollable_Overflow" rel="noopener noreferrer"&gt;Debug scrollable overflow by Mozilla Developer Network&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And finally, we got...&lt;/p&gt;

&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action" rel="noopener noreferrer"&gt;CSS Touch Actions&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;We come to the touch-enabled devices land! &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The &lt;strong&gt;touch-action&lt;/strong&gt; property sets &lt;strong&gt;how an element's region can be changed&lt;/strong&gt; on a touch-enabled device.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The exciting features that come with touchscreens like pinch-to-zoom, pan, double-tap to quick zoom, etc can all be controlled with this amazing CSS property.&lt;/p&gt;

&lt;p&gt;So, when you start a gesture with your fingers on your smartphone, what happens in the background is that the browser intersects with the &lt;code&gt;touch-action&lt;/code&gt; values of the touched element (like a draggable box) and its ancestors (like a body container), up to the one that implements the gesture. &lt;/p&gt;

&lt;p&gt;Here are some of the exciting values it comes with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;auto&lt;/code&gt;&lt;/strong&gt;: All the panning and zooming features are allowed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;none&lt;/code&gt;&lt;/strong&gt;: With this, you disable all the panning and zooming features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pan-x&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;pan-y&lt;/code&gt;&lt;/strong&gt;: You enable the single-finger horizontal and vertical gestures respectively. Also, there are some sub-values like &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action#pan-x" rel="noopener noreferrer"&gt;&lt;code&gt;pan-x&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action#pan-keywords" rel="noopener noreferrer"&gt;&lt;code&gt;pan-up&lt;/code&gt;&lt;/a&gt;, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action#pan-keywords" rel="noopener noreferrer"&gt;&lt;code&gt;pan-left&lt;/code&gt;&lt;/a&gt; etc.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;manipulation&lt;/code&gt;&lt;/strong&gt;: Here the standard gestures like panning and pinch-zoom features are turned ON but some non-standard ones like double-tap to zoom are turned OFF. A sweet spot? 😏&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;pinch-zoom&lt;/code&gt;&lt;/strong&gt;: The most exciting of the lot! Enable multi-finger panning and zooming of the page combined with any of the &lt;code&gt;pan-&lt;/code&gt; values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Try to interact with the following demo on a touch-enabled device:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/team/css-tricks/embed/PXbPXL?height=600&amp;amp;default-tab=js,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;🤩 &lt;strong&gt;Some touch-action resources!&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.google.com/web/updates/2016/10/touch-action" rel="noopener noreferrer"&gt;Touch Action Options on Google Web Developers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://googlechrome.github.io/samples/touch-action/" rel="noopener noreferrer"&gt;Touch-action pinch-zoom CSS property Sample by Google Chrome Developers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://caniuse.com/css-touch-action" rel="noopener noreferrer"&gt;CSS touch-action property by caniuse.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading, I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Adopting a &lt;a href="https://twitter.com/hashtag/CloudNative?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#CloudNative&lt;/a&gt; architecture means moving in &lt;a href="https://twitter.com/hashtag/Kubernetes?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Kubernetes&lt;/a&gt; and the challenges that come with it! Payara Cloud will save you time and effort running apps on the cloud, and ensure everything works with &lt;a href="https://twitter.com/hashtag/K8s?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#K8s&lt;/a&gt;. Watch this space!&lt;a href="https://twitter.com/hashtag/CloudNative?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#CloudNative&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/DevHumour?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#DevHumour&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Devmeme?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Devmeme&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/K8meme?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#K8meme&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/DevOps?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#DevOps&lt;/a&gt; &lt;a href="https://t.co/iIEANhfVRt" rel="noopener noreferrer"&gt;pic.twitter.com/iIEANhfVRt&lt;/a&gt;&lt;/p&gt;— Payara (@Payara_Fish) &lt;a href="https://twitter.com/Payara_Fish/status/1328647953381257226?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;November 17, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create a CSS art without HTML. 🤯</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 27 Nov 2020 13:15:41 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/create-a-css-art-without-html-3deb</link>
      <guid>https://forem.com/vaibhavkhulbe/create-a-css-art-without-html-3deb</guid>
      <description>&lt;p&gt;Well well well, no catch here. As &lt;a href="https://dev.to/vaibhavkhulbe/the-web-without-css-18d"&gt;I have said already&lt;/a&gt;, learning CSS and using some of its properties carefully, is no joke.&lt;/p&gt;

&lt;p&gt;The concept of CSS art is usually to practice our CSS skills. How to add this property, how to add such values, when to use this unit for precise craft or how to even choose one property over the other.&lt;/p&gt;

&lt;p&gt;If you're into these type of questions or just want to know &lt;em&gt;why&lt;/em&gt; you should dive into making art with CSS, then I would recommend you all to check the following article written by &lt;a href="https://dev.to/s_aitchison"&gt;@Suzanne&lt;/a&gt; on her learnings after she completed 50 Days of CSS:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/s_aitchison" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F197075%2Fac841cbd-abbb-4760-be69-6909cef48656.jpg" alt="s_aitchison"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/s_aitchison/5-lessons-from-50-days-of-css-art-2ae1" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;5 lessons from 50 days of CSS art&lt;/h2&gt;
      &lt;h3&gt;Suzanne Aitchison ・ Jul 4 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#codepen&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#showdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;Okay, so everyone uses some sort of HTML markup to have a basic structure of CSS art but what if you're feeling super cool with your CSS skills and just want to skip the markup? How about we just don't use &lt;em&gt;any&lt;/em&gt; HTML code and make CSS art possible?&lt;/p&gt;

&lt;p&gt;Of course, most of you might already know the 'trick' we will be using but if you're a beginner in CSS or in making art with CSS, read on because we are about to make an emoji which is a blend of 🤯 and 🤪...&lt;/p&gt;




&lt;h1&gt;
  
  
  What is CSS art? 🌚
&lt;/h1&gt;

&lt;p&gt;Hehe, I forgot to even introduce you to this term in case you're unaware...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It's the act of &lt;strong&gt;using only HTML and (of course) CSS to create any art form&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that's a made-up sentence above to convey the meaning briefly. The art form can include anything you can imagine from a cartoon character to illustrations, basically anything that comes under the category of 'art'.&lt;/p&gt;

&lt;p&gt;So you can go from this glass of water...&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/kassandrasanch/embed/VwedQve?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;...to this ridiculously detailed Mona Lisa painting:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/jaysalvat/embed/HaqBf?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Yes, that 'painting' you just saw is not just a &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; tag with an image attached to it, every element you see there is made from scratch!&lt;/p&gt;

&lt;h1&gt;
  
  
  What we will make? 👀
&lt;/h1&gt;

&lt;p&gt;Of course, not another Mona Lisa but yes, we can make a simple (yet different) emoji like this:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faurg57tvu7o1hjsfen4q.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faurg57tvu7o1hjsfen4q.png" alt="CSS art demo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;...and not this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/gVJKzDaWKSETu/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/gVJKzDaWKSETu/giphy.gif" alt="Art Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dang dang! How is it? Of course, not beautiful but yes, might have some taste of humor in it?&lt;/p&gt;

&lt;h1&gt;
  
  
  Breaking down the layout 🖼
&lt;/h1&gt;

&lt;p&gt;Before writing any code, we must understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How many elements we will need?&lt;/li&gt;
&lt;li&gt;What properties we are aware of?&lt;/li&gt;
&lt;li&gt;How can we use those CSS properties?&lt;/li&gt;
&lt;li&gt;Is there any new properties or a CSS feature we need to learn?&lt;/li&gt;
&lt;li&gt;What units should be used for measurement? &lt;code&gt;em&lt;/code&gt;, &lt;code&gt;rem&lt;/code&gt;, or just &lt;code&gt;%&lt;/code&gt;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's visually enhance the output we need (dev mode on!):&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmdgr0jivx9lxqs3xutdw.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fmdgr0jivx9lxqs3xutdw.png" alt="Emoji dev"&gt;&lt;/a&gt;&lt;/p&gt;
Yeah, you can appreciate my Figma skills for that, lol 😆 



&lt;p&gt;We can clearly see (thanks to the dotted borders):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is an overall container to hold our emoji (represented in blue background).&lt;/li&gt;
&lt;li&gt;Then we have the main body of the emoji which is a circle filled with yellow color.&lt;/li&gt;
&lt;li&gt;Inside this, we have the two eyes (super light brown) and then the vague wide mouth (dark brown).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Three quick elements and we got three quick minutes, ready? (I randomly added the 'three minutes' thing, please take as much time you need to fully understand the concept).&lt;/p&gt;

&lt;h1&gt;
  
  
  Start making CSS art with zero HTML characters 🤪
&lt;/h1&gt;

&lt;h3&gt;
  
  
  The markup 🤒
&lt;/h3&gt;

&lt;p&gt;Oops, nothing much here but make sure to either &lt;a href="https://www.hostinger.in/tutorials/difference-between-inline-external-and-internal-css#The-Difference-Between-Inline-External-and-Internal-CSS-Styles" rel="noopener noreferrer"&gt;link your CSS file externally or internally&lt;/a&gt;, whatever you feel is good.&lt;/p&gt;

&lt;h3&gt;
  
  
  The real deal 😎
&lt;/h3&gt;

&lt;p&gt;Open up your stylesheet. Everything we need can be encapsulated inside the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; of the DOM. So we first start by using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body" rel="noopener noreferrer"&gt;&lt;code&gt;body&lt;/code&gt;&lt;/a&gt; selector. &lt;a href="https://css-tricks.com/html-vs-body-in-css/" rel="noopener noreferrer"&gt;Here's a cool CSS Tricks article&lt;/a&gt; on HTML vs Body if you're into that.&lt;/p&gt;

&lt;p&gt;Whatever property you write inside the &lt;code&gt;body&lt;/code&gt; selector will target the DOM's &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element. It consists of basically all of the HTML content you can see. But using just &lt;code&gt;body&lt;/code&gt; and adding some colors will simply apply the entire color to the full page. We don't want that.&lt;/p&gt;

&lt;p&gt;What we need is the 'trick'! And that is to use a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements" rel="noopener noreferrer"&gt;pseudo-element&lt;/a&gt; on the &lt;code&gt;body&lt;/code&gt;! 🥳&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;pseudo-element&lt;/strong&gt; is a &lt;em&gt;keyword&lt;/em&gt; that is attached to any selector that &lt;strong&gt;lets us style a specific part&lt;/strong&gt; of that selected element.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;With this, we can make an infinite amount of shapes, vectors, and yes, CSS art by simply using a single element. In this case, we will just need to work on the &lt;code&gt;body&lt;/code&gt; part and nothing else.&lt;/p&gt;

&lt;p&gt;There is a range of pseudo-elements available, one of the most important among those is the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::before" rel="noopener noreferrer"&gt;&lt;code&gt;::before&lt;/code&gt;&lt;/a&gt; pseudo-element. This one selects the first child of the selected element and is generally used to add a special element by using the mandatory &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/content" rel="noopener noreferrer"&gt;&lt;code&gt;content&lt;/code&gt;&lt;/a&gt; property which generated the value.&lt;/p&gt;

&lt;p&gt;For our emoji art, we don't need any special content inside so we can leave this property's value as blank &lt;code&gt;""&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Position the emoji 📐
&lt;/h4&gt;

&lt;p&gt;Next, we need to position the emoji. To make something visible you can add a &lt;code&gt;background-color&lt;/code&gt; of &lt;code&gt;orangered&lt;/code&gt; because the plain &lt;code&gt;red&lt;/code&gt; value is almost like coding at night with a light theme and maximum screen brightness...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/KGbqQQoVN43cY/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/KGbqQQoVN43cY/giphy.gif" alt="Burning eyes Gif"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to make &lt;a href="https://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/#absolute" rel="noopener noreferrer"&gt;positioning absolute&lt;/a&gt; to the original &lt;code&gt;body&lt;/code&gt; element. Now we need to set where on the viewport we need to show the emoji. For this we use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;top&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;left&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;right&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="nt"&gt;bottom&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;margin&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;auto&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures the CSS art is centered throughout the webpage. Next just give a decent amount of &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; say, &lt;code&gt;15rem&lt;/code&gt; units. And yes, as the &lt;em&gt;body&lt;/em&gt; of the emoji perfect round, just add &lt;code&gt;border-radius: 50%;&lt;/code&gt; to make that happen.&lt;/p&gt;

&lt;p&gt;By now you should have the emoji centered and with fixed dimensions.&lt;/p&gt;

&lt;h4&gt;
  
  
  Working with the background! 🟡
&lt;/h4&gt;

&lt;p&gt;Everyone changes from here! We need to make those facial features like eyes and the mouth.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/background" rel="noopener noreferrer"&gt;&lt;code&gt;background&lt;/code&gt;&lt;/a&gt; (specifically the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/background-color" rel="noopener noreferrer"&gt;&lt;code&gt;background-color&lt;/code&gt;&lt;/a&gt;) property of CSS accepts something cool along with the usual color value i.e. gradients! &lt;/p&gt;

&lt;p&gt;For our demo, we need to only use the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/radial-gradient()" rel="noopener noreferrer"&gt;&lt;code&gt;radial-gradient()&lt;/code&gt;&lt;/a&gt;, a CSS function which creates a gradient that radiates (like a circle) from the center. It has the following syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;radial-gradient(circle at center, red 0, blue, green 100%)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We first provide from where the circle needs to be drawn and then what colors are needed (with the amount).&lt;/p&gt;

&lt;p&gt;As you saw in the layout breakdown, we have 3 circles for 2 eyes and 1 mouth. So, for each of those, we will need to use the &lt;code&gt;radial-gradient&lt;/code&gt;. As for the background of the emoji body, you can change that later. Here how our circles would go:&lt;/p&gt;

&lt;p&gt;1️⃣ The &lt;strong&gt;first eye&lt;/strong&gt; is a big one. First, we need to position it. For that, after &lt;code&gt;circle at&lt;/code&gt; we use a rough estimate of both &lt;em&gt;horizontal and vertical placements&lt;/em&gt; in terms of percentages. Here I have chosen &lt;code&gt;30%&lt;/code&gt; and &lt;code&gt;40%&lt;/code&gt; respectively.&lt;/p&gt;

&lt;p&gt;Next, we give it a color of &lt;code&gt;#b58c1b&lt;/code&gt; (light brown) and a &lt;code&gt;20%&lt;/code&gt; scale from its original scale. The more you increase this percent, the bigger the circle would be. &lt;/p&gt;

&lt;p&gt;The third parameter is simply making it &lt;code&gt;transparent&lt;/code&gt; so that it doesn't affect the color of the emoji body.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;40&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;20&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2️⃣ The &lt;strong&gt;second eye&lt;/strong&gt; is the same but here we need a small size so just change the scale to &lt;code&gt;13%&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;/* Big eye */&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;40&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;20&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;

&lt;span class="c"&gt;/* Small eye */&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;70&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;45&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;13&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3️⃣ The &lt;strong&gt;wide mouth&lt;/strong&gt; is also made up of the same radial gradient but here apart from a different position and color, we need to define the &lt;em&gt;wideness&lt;/em&gt; or the length of the mouth. That slight wide mouth feel can be done by giving external width and height of &lt;code&gt;80rem&lt;/code&gt; and &lt;code&gt;5rem&lt;/code&gt; respectively.&lt;/p&gt;

&lt;p&gt;And make sure to add &lt;code&gt;no-repeat&lt;/code&gt; towards the end else, this mouth would go crazy all over the face!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="c"&gt;/* Big eye */&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;40&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;20&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;

&lt;span class="c"&gt;/* Small eye */&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;70&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;45&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;13&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;

&lt;span class="c"&gt;/* Wide mouth */&lt;/span&gt;
&lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="err"&gt;#672&lt;/span&gt;&lt;span class="nt"&gt;e00&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
&lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%)&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="err"&gt;80&lt;/span&gt;&lt;span class="nt"&gt;rem&lt;/span&gt; &lt;span class="err"&gt;5&lt;/span&gt;&lt;span class="nt"&gt;rem&lt;/span&gt; &lt;span class="nt"&gt;no-repeat&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, the emoji background color hex value can be added towards the end as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
    &lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;30&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;40&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
    &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;20&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;

    &lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;70&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;45&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
    &lt;span class="nf"&gt;#b58c1b&lt;/span&gt; &lt;span class="err"&gt;13&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;0&lt;/span&gt;&lt;span class="o"&gt;%),&lt;/span&gt;

    &lt;span class="nt"&gt;radial-gradient&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;circle&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; &lt;span class="err"&gt;#672&lt;/span&gt;&lt;span class="nt"&gt;e00&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%,&lt;/span&gt; 
    &lt;span class="nt"&gt;transparent&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="o"&gt;%)&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="err"&gt;100&lt;/span&gt;&lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="err"&gt;80&lt;/span&gt;&lt;span class="nt"&gt;rem&lt;/span&gt; &lt;span class="err"&gt;5&lt;/span&gt;&lt;span class="nt"&gt;rem&lt;/span&gt; &lt;span class="nt"&gt;no-repeat&lt;/span&gt;

    &lt;span class="nf"&gt;#ffcf34&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So now the entire code of the CSS emoji looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  
        &lt;span class="n"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;circle&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="m"&gt;30%&lt;/span&gt; &lt;span class="m"&gt;40%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#b58c1b&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="m"&gt;#b58c1b&lt;/span&gt; &lt;span class="m"&gt;20%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;circle&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="m"&gt;70%&lt;/span&gt; &lt;span class="m"&gt;45%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="m"&gt;#b58c1b&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;#b58c1b&lt;/span&gt; &lt;span class="m"&gt;13%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;0%&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="n"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;circle&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
     &lt;span class="m"&gt;#672e00&lt;/span&gt; &lt;span class="m"&gt;10%&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt; &lt;span class="m"&gt;10%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;80rem&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt; &lt;span class="nb"&gt;no-repeat&lt;/span&gt;
        &lt;span class="m"&gt;#ffcf34&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it! You just made CSS art without a single line of HTML but most importantly you learned what is a pseudo-element, how it works, how to make good use of gradients to make art forms, and more! &lt;/p&gt;

&lt;p&gt;Here's the CodePen embed of the above code:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/kvaibhav01/embed/jOMNvKJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;
Lol, there's just a CSS tab, looks weird... 🌚






&lt;h1&gt;
  
  
  More resources 🤩
&lt;/h1&gt;

&lt;p&gt;Go ahead with your new CSS art skills and get more knowledge from these resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://blog.prototypr.io/pure-css-art-a-beginners-tale-2740ebf44199" rel="noopener noreferrer"&gt;Pure CSS Art: A Beginner’s Tale by Alison Quaglia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-art.com" rel="noopener noreferrer"&gt;PURE CSS A​R​T GALLERY&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://youtu.be/uXBoQ4WRD9A" rel="noopener noreferrer"&gt;CSS Art Crash Course - By Example! by DesignCourse&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading, I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Always remember to leave yourself useful comments! 👇&lt;a href="https://twitter.com/hashtag/DevHumour?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#DevHumour&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Developer?src=hash&amp;amp;ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;#Developer&lt;/a&gt; &lt;a href="https://t.co/VJsR6YYVSs" rel="noopener noreferrer"&gt;pic.twitter.com/VJsR6YYVSs&lt;/a&gt;&lt;/p&gt;— Microsoft Developer UK (@msdevUK) &lt;a href="https://twitter.com/msdevUK/status/1327204570913792000?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;November 13, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CSS: Subgrids, Multi-column, &amp; Writing Modes. 🥸</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 20 Nov 2020 13:28:26 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/css-subgrids-multi-column-and-writing-modes-3jk7</link>
      <guid>https://forem.com/vaibhavkhulbe/css-subgrids-multi-column-and-writing-modes-3jk7</guid>
      <description>&lt;p&gt;Three cool topics to cover here! If you're totally new to the Cascading Style Sheets (CSS) this might not be the right article to read! &lt;/p&gt;

&lt;p&gt;But wait! If you really want to dive into some of the un-common (or not-so-famous) terms and practices in the frontend development world, then you're more than welcome :)&lt;/p&gt;

&lt;p&gt;Previously I tried to cover CSS color gamut and containment pattern, you can read all about it here:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/vaibhavkhulbe" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F107614%2Fed59e3ee-6488-4af8-b0e1-7bb38dd2e74c.jpg" alt="vaibhavkhulbe"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/vaibhavkhulbe/css-color-gamut-containment-344a" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;CSS: Color gamut &amp;amp; Containment. 🌈&lt;/h2&gt;
      &lt;h3&gt;Vaibhav Khulbe ・ Oct 23 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#css&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#html&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#tutorial&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;And now, we're into subgrids, multi-column layouts and writing modes so let's talk a bit about each of them briefly in this article.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/uk6hEhjjEkNCoKoh0R/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/uk6hEhjjEkNCoKoh0R/giphy.gif" alt="Daisy GIF"&gt;&lt;/a&gt;&lt;/p&gt;
Enjoy these daisies while you start reading this...






&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid" rel="noopener noreferrer"&gt;Subgrids&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;This is something which Firefox lovers are so proud of. Why? Because as of now, this feature is &lt;a href="https://caniuse.com/css-subgrid" rel="noopener noreferrer"&gt;only supported on Firefox&lt;/a&gt;. Not to worry, let's take a look at what it actually is.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;CSS Subgrid allows a &lt;strong&gt;grid-item&lt;/strong&gt; with its own grid to &lt;strong&gt;align in one or both dimensions&lt;/strong&gt; with its &lt;strong&gt;parent grid&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yeah, we're dealing with &lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Grid" rel="noopener noreferrer"&gt;&lt;code&gt;display: grid&lt;/code&gt;&lt;/a&gt; but here it's &lt;em&gt;nested&lt;/em&gt;! When you add this code to a grid container, we see that only its direct children elements become the actual grid items which are then placed on the newly created grid.&lt;/p&gt;

&lt;p&gt;Now, these grids are usually independent of their parent grid, so naturally, they won't take the grid track sizing. But if you set &lt;code&gt;grid-template-columns: subgrid&lt;/code&gt; or even &lt;code&gt;grid-template-rows: subgrid&lt;/code&gt;, instead of creating a new grid track, listing it here on the nested grid, it uses the tracks defined on the parent.&lt;/p&gt;

&lt;p&gt;Let's take a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example has 6 column and 3-row tracks defined by the &lt;code&gt;grid-template&lt;/code&gt; property. The nested grid is a grid item on the parent &lt;code&gt;.grid&lt;/code&gt; spanning from column 2 to 6, the same goes for the row which goes from row line 1 to 3.&lt;/p&gt;

&lt;p&gt;Now, as we used the value of &lt;code&gt;subgrid&lt;/code&gt; on &lt;code&gt;grid-template-columns&lt;/code&gt; and &lt;code&gt;grid-template-rows&lt;/code&gt; of the &lt;code&gt;.item&lt;/code&gt;, this means that the nested row now has &lt;em&gt;4-column&lt;/em&gt; with &lt;em&gt;2-row tracks&lt;/em&gt;. These values come from the same sizing defined on the parent. With this defined, we can assume that &lt;em&gt;any change to the track sizing on the parent grid will be followed by the nested grid&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Here's how it looks on the Firefox browser with dev tools in action:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq9sehhzk4xgrntgc5fax.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fq9sehhzk4xgrntgc5fax.png" alt="Subgrid Firefox demo"&gt;&lt;/a&gt;&lt;/p&gt;
This is why the Firefox dev tool is so awesome, it shows you all the overlays and line numbers!



&lt;p&gt;Subgrids are way cooler when you have multiple nested items:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.grid&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.item&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;grid-template-rows&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;subgrid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.subitem&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;grid-column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;grid-row&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we got the &lt;code&gt;.subitem&lt;/code&gt; which is nested inside the &lt;code&gt;.item&lt;/code&gt; class. This yields the following output:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvlw2l9iu5wd1ces60cpu.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvlw2l9iu5wd1ces60cpu.png" alt="Subgrid example 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  🤩 Some subgrid resources!
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev.to/kenbellows/why-we-need-css-subgrid-53mh"&gt;Why we need CSS subgrid&lt;/a&gt; by Ken Bellows&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://medium.com/@trekinbami/introduction-to-css-subgrid-cbf21d982994" rel="noopener noreferrer"&gt;Introduction to CSS Subgrid&lt;/a&gt; by Sam Pakvis&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/5Z_JX-EhRJA" rel="noopener noreferrer"&gt;#FutureCSS - The CSS SUBGRID is Awesome!&lt;/a&gt; by DesignCourse&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Onto the next topic...&lt;/p&gt;

&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Columns" rel="noopener noreferrer"&gt;Multi-column layout&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Working on a website layout where you need to display text like this?:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F694tqg88k2cc8wpb1qu4.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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F694tqg88k2cc8wpb1qu4.png" alt="Multi layout column example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Maybe you need a &lt;a href="https://i.stack.imgur.com/O9pc4.jpg" rel="noopener noreferrer"&gt;newspaper layout&lt;/a&gt;, a &lt;a href="https://visme.co/blog/wp-content/uploads/2018/03/How-Grids-Can-Help-You-Create-Professional-Looking-Designs-Column-Grid-magazine.png" rel="noopener noreferrer"&gt;magazine&lt;/a&gt;, an &lt;a href="https://www.kotobee.com/blog/wp-content/uploads/2017/04/reflowable.jpg" rel="noopener noreferrer"&gt;e-book&lt;/a&gt;, or an &lt;a href="https://image.shutterstock.com/image-vector/vector-infographic-thin-line-design-260nw-1237157878.jpg" rel="noopener noreferrer"&gt;infographic type layout&lt;/a&gt;, you're in for the multi-column mode of CSS...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The CSS Multi-column Layout adds &lt;strong&gt;support for multiple-column layouts&lt;/strong&gt;. With this, you can establish the &lt;strong&gt;number of columns&lt;/strong&gt; needed for a layout along with &lt;strong&gt;how the content inside each column should flow&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can control the gap size between the columns, the dividers in between the columns, fragmenting the content, and much more.&lt;/p&gt;

&lt;p&gt;Check-out the following example:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/rachelandrew/embed/aPRjzL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;This uses the following 3 properties:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/column-count" rel="noopener noreferrer"&gt;&lt;code&gt;column-count&lt;/code&gt;&lt;/a&gt;: this is used to break the content inside the element into a number of specified columns. The higher the count, the more number of columns it produces.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap" rel="noopener noreferrer"&gt;&lt;code&gt;column-gap&lt;/code&gt;&lt;/a&gt;: this acts as the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/gap" rel="noopener noreferrer"&gt;&lt;code&gt;gap&lt;/code&gt;&lt;/a&gt; (formerly &lt;code&gt;grid-gap&lt;/code&gt;) property of the columns. The value you give here will add that much amount of gutter gap between the columns.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/column-rule" rel="noopener noreferrer"&gt;&lt;code&gt;column-rule&lt;/code&gt;&lt;/a&gt;: acts much like the border between the two columns. So you have the freedom to add all the styling options of the &lt;code&gt;border&lt;/code&gt; like &lt;code&gt;solid 2px red&lt;/code&gt; etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🤩 Some multi-col resources!
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.smashingmagazine.com/2019/01/css-multiple-column-layout-multicol/" rel="noopener noreferrer"&gt;When And How To Use CSS Multi-Column Layout&lt;/a&gt; by Rachel Andrew.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://css-tricks.com/guide-responsive-friendly-css-columns/" rel="noopener noreferrer"&gt;Guide to Responsive-Friendly CSS Columns&lt;/a&gt; by Katy DeCorah&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://youtu.be/syG7ljxqzNg" rel="noopener noreferrer"&gt;CSS Multi-Columns - Awesome Newspaper Style Layouts (NO Flexbox or Grid)&lt;/a&gt; by DesignCourse&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Talking about some writing...&lt;/p&gt;

&lt;h1&gt;
  
  
  ➡️ &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode" rel="noopener noreferrer"&gt;CSS Writing Mode&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Want a document to show from top to bottom instead of the usual flow of left to right? What do you think is the CSS behind the Arabic words when you visit a webpage in that language? Most probably, you want to fiddle around with the writing modes.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The CSS Writing Mode property sets the &lt;strong&gt;layout of the text&lt;/strong&gt; as well as the &lt;strong&gt;direction of the content block&lt;/strong&gt; along which the entire web document flows.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Take a look at this CodePen demo:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/jensimmons/embed/KNJgmP?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;You might find the text "Octavia Butler" written in an unusual style. This is all done via the writing mode. Let's take a look at different values we can provide to make the text go in unusual directions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;horizontal-tb&lt;/code&gt;&lt;/strong&gt;: If your document text is in &lt;code&gt;ltr&lt;/code&gt; scripts like English or Spanish, then the content will flow horizontally from &lt;em&gt;left to right&lt;/em&gt; as we commonly see. If it's in &lt;code&gt;rtl&lt;/code&gt; script like Arabic or Hebrew, then it reverses, now it will for from &lt;em&gt;right to left&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;vertical-rl&lt;/code&gt;&lt;/strong&gt;: Use it for the  &lt;em&gt;vertical top to bottom&lt;/em&gt; flow. Also, the next line is positioned to the &lt;em&gt;left&lt;/em&gt; of the previous line. For &lt;code&gt;rtl&lt;/code&gt;, this flows &lt;em&gt;bottom to top&lt;/em&gt; and the next line will be towards the &lt;em&gt;right&lt;/em&gt; of the previous one.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;code&gt;vertical-lr&lt;/code&gt;&lt;/strong&gt;: This is 50% similar to the &lt;code&gt;vertical-rl&lt;/code&gt; approach, the only difference being in the flow of the next line, for &lt;code&gt;rtl&lt;/code&gt; it's vertically from &lt;em&gt;bottom to top&lt;/em&gt; and vice-versa for &lt;code&gt;ltr&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  🤩 Some writing mode resources!
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.smashingmagazine.com/2019/08/writing-modes-layout/" rel="noopener noreferrer"&gt;Writing Modes And CSS Layout&lt;/a&gt; by Rachel Andrew&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://24ways.org/2016/css-writing-modes/" rel="noopener noreferrer"&gt;CSS Writing Modes&lt;/a&gt; by Jen Simmons&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://css-tricks.com/author/robinrendle/" rel="noopener noreferrer"&gt;writing-mode&lt;/a&gt; by Robin Rendle&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Okay, now we've reached the end...&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading, I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;🙄 &lt;a href="https://t.co/1G4L5SedDv" rel="noopener noreferrer"&gt;pic.twitter.com/1G4L5SedDv&lt;/a&gt;&lt;/p&gt;— Sasha Rosenbaum (@DivineOps) &lt;a href="https://twitter.com/DivineOps/status/1329244198009262082?ref_src=twsrc%5Etfw" rel="noopener noreferrer"&gt;November 19, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates" rel="noopener noreferrer"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe" rel="noopener noreferrer"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Create a theme with styled-components easily in 3 steps. 💅</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 13 Nov 2020 13:44:47 +0000</pubDate>
      <link>https://forem.com/vaibhavkhulbe/create-a-theme-with-styled-components-easily-in-3-steps-7i3</link>
      <guid>https://forem.com/vaibhavkhulbe/create-a-theme-with-styled-components-easily-in-3-steps-7i3</guid>
      <description>&lt;p&gt;What if you're working on a React based project and suddenly your design team says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Yo, we need to completely change the entire theme of the app due to &lt;em&gt;blah&lt;/em&gt; and &lt;em&gt;blah&lt;/em&gt; reasons..."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Maybe you're not convinced with their reasons or maybe you just need to do this for fun. Whatever the reason, it's quite annoying if you’re just using plain old CSS (even with &lt;a href="https://dev.to/dailydotdev/css-variables-but-with-a-dash-of-javascript-244j"&gt;variables&lt;/a&gt;) to apply the global or per-element styles.&lt;/p&gt;

&lt;p&gt;What comes to the rescue is some method by which you can easily change the entire color, font, gradient, etc. values in one go, a place where all of these are defined in a central place so you don’t have to change things here and there.&lt;/p&gt;

&lt;p&gt;What I'm talking about is creating your own theme with &lt;em&gt;styled-components&lt;/em&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  A quick note on styled-components 📝
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://styled-components.com/"&gt;styled-components&lt;/a&gt;&lt;/strong&gt; is a library that allows you to write actual CSS code to style your components inside a JS file. This follows the &lt;a href="https://medium.com/dailyjs/what-is-actually-css-in-js-f2f529a2757"&gt;CSS-in-JS concept&lt;/a&gt; which allows developers to style using tagged &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals"&gt;template literals&lt;/a&gt; giving extensive flexibility and more control.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All in all, a great merger of CSS and JS! Here are some of its features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic critical CSS&lt;/strong&gt;: it keeps track of which components are rendered and injects their styles and nothing else, automatically.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No class name bugs&lt;/strong&gt;: there are no duplication, overlap, or misspellings.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Easier deletion of CSS&lt;/strong&gt;: if the component is unused and gets deleted, all its styles get deleted with it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simple dynamic styling&lt;/strong&gt;: styling of a component based on its props without having to manually manage dozens of classes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  What we will be styling? 💅
&lt;/h1&gt;

&lt;p&gt;This:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fa8ivog3vego5fnj1zndz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fa8ivog3vego5fnj1zndz.gif" alt="styled components button theming" width="330" height="190"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will be theming out two buttons using styled-components. Notice that we have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different default and hover &lt;em&gt;colors&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Different font &lt;em&gt;styles&lt;/em&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/W3Hi0XQoCmfqQf868O/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/W3Hi0XQoCmfqQf868O/giphy.gif" alt="Hair styling GIF" width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Create global styles! 😍
&lt;/h1&gt;

&lt;p&gt;After you're done &lt;a href="https://styled-components.com/docs/basics#installation"&gt;installing the library&lt;/a&gt;, head over to your &lt;em&gt;index.js&lt;/em&gt; file. Here, all the theme data will go such as the colors, fonts, etc.&lt;/p&gt;

&lt;h4&gt;
  
  
  STEP 1️⃣ : Create a &lt;code&gt;theme&lt;/code&gt; object
&lt;/h4&gt;

&lt;p&gt;This will house all the theme objects we need. Currently, we are only changing the &lt;code&gt;colors&lt;/code&gt; and &lt;code&gt;fonts&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;primary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#6200ee&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;primaryVariant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ede6ff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;secondary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#008073&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;secondaryVariant&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#deffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;fonts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;material&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Roboto&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;default&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Montserrat&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see, there are four color options, one for each variant; primary and secondary. As for the font, we also need to include them in our &lt;em&gt;index.html&lt;/em&gt; file via the &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; method as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&amp;amp;display=swap"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"preconnect"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://fonts.gstatic.com"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&amp;amp;display=swap"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  STEP 2️⃣ : Use the &lt;code&gt;ThemeProvider&lt;/code&gt; component
&lt;/h4&gt;

&lt;p&gt;Next, import the &lt;a href="https://styled-components.com/docs/api#themeprovider"&gt;&lt;code&gt;ThemeProvider&lt;/code&gt;&lt;/a&gt; helper component from &lt;code&gt;styled-components&lt;/code&gt;. This is used to inject the theme into all styled-components in the component tree, via the &lt;a href="https://reactjs.org/docs/context.html"&gt;Context API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We need to wrap our top-level component i.e. &lt;code&gt;&amp;lt;App /&amp;gt;&lt;/code&gt; with this. But for it to actually recognize the &lt;code&gt;theme&lt;/code&gt; object we wrote above, we need it to pass it on as:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hence, now the render methods becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;ReactDOM&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt; &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;App&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;StrictMode&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ThemeProvider&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;rootElement&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  STEP 3️⃣ : Create the buttons and add the theme!
&lt;/h4&gt;

&lt;p&gt;Before we hop into the buttons, did you see that the body color of the demo is not white but instead off-white? Well, here, the global style of the app was triggered.&lt;/p&gt;

&lt;p&gt;Using the &lt;a href="https://styled-components.com/docs/api#createglobalstyle"&gt;&lt;code&gt;createGlobalStyle&lt;/code&gt;&lt;/a&gt; helper function, we can change or reset the base styles of the entire application.&lt;/p&gt;

&lt;p&gt;For this to happen, we need to add the &lt;code&gt;&amp;lt;Global /&amp;gt;&lt;/code&gt; component just before the &lt;code&gt;&amp;lt;App /&amp;gt;&lt;/code&gt; starts inside the &lt;code&gt;App()&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;Now we can add global styles by defining the usual styled-component:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Global&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createGlobalStyle&lt;/span&gt;&lt;span class="s2"&gt;`
  body {
    width: 50%;
    padding: 10px;
    background: #fffaeb;
  }
`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, let's move to those two buttons. We can create two components; &lt;code&gt;&amp;lt;PrimaryButton /&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;DefaultButton /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The usual styles (without colors and fonts) for the buttons are as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="nt"&gt;width&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="o"&gt;%;&lt;/span&gt;
  &lt;span class="nt"&gt;height&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;50&lt;/span&gt;&lt;span class="nt"&gt;px&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;cursor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;pointer&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;transition&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;all&lt;/span&gt; &lt;span class="err"&gt;200&lt;/span&gt;&lt;span class="nt"&gt;ms&lt;/span&gt; &lt;span class="nt"&gt;ease&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;text-decoration&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;none&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;outline&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;none&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;border&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;none&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;border-radius&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;10&lt;/span&gt;&lt;span class="nt"&gt;px&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;float&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;left&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get the value from the &lt;code&gt;theme&lt;/code&gt; which is passed via the &lt;code&gt;ThemeProvider&lt;/code&gt; component, we will use our good old friend in React, i.e. &lt;a href="https://reactjs.org/docs/components-and-props.html"&gt;props&lt;/a&gt;! &lt;/p&gt;

&lt;p&gt;Start with the template literal syntax to pass on the &lt;code&gt;props&lt;/code&gt; parameter to our arrow function, this can now get the global theme object via &lt;code&gt;props.theme&lt;/code&gt;. Now we got the &lt;code&gt;theme&lt;/code&gt; object, so we can assign the values as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;(props)&lt;/span&gt; &lt;span class="err"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;props.theme.colors.primary&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;(props)&lt;/span&gt; &lt;span class="err"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;props.theme.colors.primaryVariant&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We applied the colors, now what about the hover effect? styled-components makes it really easy to add &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes"&gt;pseudo-classes&lt;/a&gt; whether it's &lt;code&gt;:hover&lt;/code&gt; or &lt;code&gt;:active&lt;/code&gt;. Just invert the values of the &lt;code&gt;background&lt;/code&gt; and &lt;code&gt;color&lt;/code&gt; inside the &lt;code&gt;:hover&lt;/code&gt; object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;${&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;primaryVariant&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="err"&gt;(props)&lt;/span&gt; &lt;span class="err"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="err"&gt;props.theme.colors.primary&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same method is applied to other objects inside our &lt;code&gt;theme&lt;/code&gt; such as for the different fonts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="nt"&gt;font-family&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'${(props) =&amp;gt; props.theme.fonts.material}'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="nt"&gt;font-weight&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;500&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
  &lt;span class="o"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's pretty much it! You have used a theme in styled-components. Of course, this is just the beginning, you can bring in the entire library of design assets and tokens with your theme to make it even more dynamic.&lt;/p&gt;




&lt;h1&gt;
  
  
  More resources 🤩
&lt;/h1&gt;

&lt;p&gt;Go ahead with theming when you read from these resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://styled-components.com/docs/advanced#theming"&gt;Theming docs by styled-components&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/aromanarguello/how-to-use-themes-in-styled-components-49h"&gt;How to use Themes in styled-components by @aromanarguello&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/styled-components/styled-theming"&gt;styled-theming repo by styled-components&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Thanks for reading, I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;When the going gets tough, the tough get going. 💪&lt;br&gt;&lt;br&gt;Image source: &lt;a href="https://t.co/f3Mij3xXQs"&gt;https://t.co/f3Mij3xXQs&lt;/a&gt;&lt;a href="https://twitter.com/hashtag/DevHumour?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#DevHumour&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/CodingMemes?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#CodingMemes&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/Developer?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#Developer&lt;/a&gt; &lt;a href="https://t.co/bouXm7eVlx"&gt;pic.twitter.com/bouXm7eVlx&lt;/a&gt;&lt;/p&gt;— Microsoft Developer UK (@msdevUK) &lt;a href="https://twitter.com/msdevUK/status/1324630107240222720?ref_src=twsrc%5Etfw"&gt;November 6, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;h4&gt;
  
  
  &lt;a href="https://mailchi.mp/f59beeac6b9b/devupdates"&gt;📫 Subscribe to my weekly developer newsletter 📫&lt;/a&gt;
&lt;/h4&gt;

&lt;h5&gt;
  
  
  PS: From this year, I've decided to write here on DEV Community. Previously, I wrote on Medium. If anyone wants to take a look at my articles, &lt;a href="https://medium.com/@vaibhavkhulbe"&gt;here&lt;/a&gt;'s my Medium profile.
&lt;/h5&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>react</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CSS variables but with a dash of JavaScript. ✨</title>
      <dc:creator>Vaibhav Khulbe</dc:creator>
      <pubDate>Fri, 06 Nov 2020 09:04:20 +0000</pubDate>
      <link>https://forem.com/dailydotdev/css-variables-but-with-a-dash-of-javascript-244j</link>
      <guid>https://forem.com/dailydotdev/css-variables-but-with-a-dash-of-javascript-244j</guid>
      <description>&lt;p&gt;Okay, we'll go with this quick and straight. When you first start diving into CSS, you do the usual thing like changing color, changing fonts, etc. Then you dive deep into media queries, cross-browser properties, and finally to variables. &lt;/p&gt;

&lt;p&gt;But what if we use these variables in our CSS files alongside with some magic of our old friend JavaScript, then imagine what we can achieve! Something cool? Yes, you're correct. Let's do this and make something nice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/l0IyeRaKu4ikJYE1O/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l0IyeRaKu4ikJYE1O/giphy.gif" alt="Sprinkle GIF" width="480" height="480"&gt;&lt;/a&gt;&lt;/p&gt;
Something to sprinkle!






&lt;h1&gt;
  
  
  Quick note on CSS variables 📝
&lt;/h1&gt;

&lt;p&gt;Of course, some basics first. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;CSS Custom Properties&lt;/strong&gt; or &lt;strong&gt;CSS Variables&lt;/strong&gt; allows us to store a value stored in one place, then referenced in multiple other places. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sometimes specific values need to be reused throughout a document. A typical example is when you get a specific color palette from designers, and you need to add specific hex values of colors, font-sizes, or even some responsive breakpoints. You assign these values to your custom-made CSS properties called variables here. &lt;/p&gt;

&lt;p&gt;This is useful not only because they can be used at multiple instances and makes editing the values easy but also, it makes the properties easier to read when referring to it later. For example: &lt;code&gt;--headline-color&lt;/code&gt; is better to read than &lt;code&gt;#000&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Check out this wonderful CodePen example:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/jdsteinbach/embed/AeEwk?height=600&amp;amp;default-tab=css,result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage and syntax
&lt;/h3&gt;

&lt;p&gt;Declaring a custom CSS property is created by assigning the double hyphen (&lt;code&gt;--&lt;/code&gt;) in front of the variable name, and then the property value is written like any other CSS property. &lt;/p&gt;

&lt;p&gt;Check out this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--main-bg-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;lightgray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to use this custom property anywhere in your CSS file you can do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;element&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--main-bg-color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, you don't need to write &lt;code&gt;lightgray&lt;/code&gt; value for the background-color in all places where there is a need to use the &lt;code&gt;var()&lt;/code&gt; function and pass in the CSS custom variable inside. &lt;/p&gt;

&lt;h1&gt;
  
  
  Introducing JavaScript ✨
&lt;/h1&gt;

&lt;p&gt;Time to start interacting with the web developer's favorite language.&lt;/p&gt;

&lt;p&gt;Let's see how we can write a new property value in JavaScript.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➡️ &lt;code&gt;setProperty&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;element&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, what these new functions mean? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement"&gt;&lt;code&gt;document.documentElement&lt;/code&gt;&lt;/a&gt;: this returns the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element"&gt;&lt;code&gt;Element&lt;/code&gt;&lt;/a&gt; which is usually the root element of your HTML document.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/setProperty"&gt;&lt;code&gt;style.setProperty()&lt;/code&gt;&lt;/a&gt;: it sets a new value for a property on a CSS style declaration object.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;setProperty()&lt;/code&gt; takes in the &lt;em&gt;property name&lt;/em&gt;, it's &lt;em&gt;value&lt;/em&gt;, and optionally the &lt;em&gt;priority&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The code you saw above sets a new value for a globally defined property. This type of JavaScript code is useful when you are managing state and then modifying CSS styles based on given values.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➡️ &lt;code&gt;getPropertyValue&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPropertyValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--my-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yeah, exactly what you're thinking right now. Just as with any other language, we have setters and getters here too. With the &lt;code&gt;setProperty&lt;/code&gt; we were &lt;em&gt;setting&lt;/em&gt; a new value, and here with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/getPropertyValue"&gt;&lt;code&gt;getPropertyValue&lt;/code&gt;&lt;/a&gt;, we return a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMString"&gt;&lt;code&gt;DOMString&lt;/code&gt;&lt;/a&gt; containing the value of the above-specified CSS property.&lt;/p&gt;

&lt;p&gt;Here's a practical example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--accent-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#663399&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPropertyValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--accent-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return the value of &lt;code&gt;--accent-color&lt;/code&gt; as &lt;code&gt;#663399&lt;/code&gt; when the browser renders the webpage.&lt;/p&gt;

&lt;h3&gt;
  
  
  ➡️ &lt;code&gt;removeProperty&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--my-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration/removeProperty"&gt;&lt;code&gt;removeProperty&lt;/code&gt;&lt;/a&gt; method will remove the provided property from a CSS style declaration object.&lt;/p&gt;

&lt;p&gt;So, if you want to dynamically remove the attached custom CSS property, then you can have code similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--accent-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#663399&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPropertyValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--accent-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--accent-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Using event listeners 👂
&lt;/h1&gt;

&lt;p&gt;If there's some JavaScript code, then there are events happening! What if you want to change a &lt;code&gt;div&lt;/code&gt;'s position on cursor click?&lt;/p&gt;

&lt;p&gt;First, start off with declaring the CSS variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--cursor-pos-x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--cursor-pos-y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By declaring them at &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/:root"&gt;&lt;code&gt;:root&lt;/code&gt;&lt;/a&gt;, we're putting them into the &lt;em&gt;root&lt;/em&gt; element of the DOM tree. Typically, it's the &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;Next, we will be using these variables in our &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--cursor-pos-x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--cursor-pos-x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you know by now, it translates into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt; &lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
  &lt;span class="err"&gt;.&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have set the initial position of the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;, now let's interact with an event listener.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--cursor-pos-x&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientX&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--cursor-pos-y&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;clientY&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;px&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are simply using the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientX"&gt;&lt;code&gt;clientX&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/clientY"&gt;&lt;code&gt;clientY&lt;/code&gt;&lt;/a&gt; properties of the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent"&gt;&lt;code&gt;MouseEvent&lt;/code&gt;&lt;/a&gt; interface, whose function is to move the corresponding &lt;code&gt;div&lt;/code&gt; in both &lt;em&gt;X&lt;/em&gt; and &lt;em&gt;Y&lt;/em&gt; directions, respectively.&lt;/p&gt;

&lt;p&gt;The result will be similar to this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F299j5nwbpae0hdy9c2hi.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F299j5nwbpae0hdy9c2hi.gif" alt="Mouse click demo" width="450" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is it! There are endless possibilities when it comes to combining the power of CSS variables with JavaScript. You can make awesome DOM-based games, use it to change component styles dynamically, and more!&lt;/p&gt;

&lt;h1&gt;
  
  
  More resources 🤩
&lt;/h1&gt;

&lt;p&gt;Go ahead and learn more about custom CSS properties from the resources given below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📄 &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties"&gt;MDN CSS Custom Properties docs&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/making-custom-properties-css-variables-dynamic/"&gt;CSS Tricks - Making Custom Properties more dynamic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://slides.com/davidkhourshid/reactanim"&gt;Reactive Animations with CSS Variables by David Khourshid&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://eager.io/blog/communicating-between-javascript-and-css-with-css-variables/"&gt;Communicating Between JavaScript and CSS Using CSS Variables by Zack Bloom&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;em&gt;Thanks for reading. I appreciate it! Have a good day. (✿◕‿◕✿)&lt;/em&gt;&lt;/p&gt;



&lt;blockquote&gt;
&lt;p&gt;Team printf!&lt;a href="https://twitter.com/hashtag/programmingmemes?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#programmingmemes&lt;/a&gt; &lt;a href="https://twitter.com/hashtag/DEVCommunity?src=hash&amp;amp;ref_src=twsrc%5Etfw"&gt;#DEVCommunity&lt;/a&gt; &lt;a href="https://t.co/Ou4sNRPRE7"&gt;pic.twitter.com/Ou4sNRPRE7&lt;/a&gt;&lt;/p&gt;— 🎵PhonoForest🌳GameDev🎮 (@PhonoForest) &lt;a href="https://twitter.com/PhonoForest/status/1321483031627137024?ref_src=twsrc%5Etfw"&gt;October 28, 2020&lt;/a&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;&lt;a href="https://api.daily.dev/get?r=devto"&gt;daily.dev&lt;/a&gt; delivers the best programming news every new tab. We will rank hundreds of qualified sources for you so that you can hack the future.&lt;/em&gt;&lt;br&gt;
&lt;a href="https://api.daily.dev/get?r=devto"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb996k4sm4efhietrzups.png" alt="Daily Poster" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

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