<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: _CODE</title>
    <description>The latest articles on DEV Community by _CODE (@underscorecode).</description>
    <link>https://dev.to/underscorecode</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%2F640282%2F9500a22c-66b5-41d8-bccf-9c4be00410f3.png</url>
      <title>DEV Community: _CODE</title>
      <link>https://dev.to/underscorecode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/underscorecode"/>
    <language>en</language>
    <item>
      <title>Handling exceptions in JavaScript : Key points ⭐️</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Fri, 24 Sep 2021 12:13:57 +0000</pubDate>
      <link>https://dev.to/underscorecode/handling-exceptions-in-javascript-key-points-27je</link>
      <guid>https://dev.to/underscorecode/handling-exceptions-in-javascript-key-points-27je</guid>
      <description>&lt;p&gt;Hello, everybody! 👋🏼&lt;/p&gt;

&lt;p&gt;In today's article we'll be talking about &lt;strong&gt;exceptions&lt;/strong&gt; in JavaScript: what they are, different types, declaration and how to handle and deal with them appropriately.&lt;/p&gt;

&lt;h1&gt;
  
  
  First things first: Main concepts 🧐
&lt;/h1&gt;

&lt;p&gt;Let's first have a look at the main concepts of exception handling to have a clear and concise idea of what they exactly mean in programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an exception? 🚫
&lt;/h3&gt;

&lt;p&gt;An &lt;em&gt;exception&lt;/em&gt; is an anomalous condition that breaks the regular execution of the code.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does &lt;em&gt;handle an exception&lt;/em&gt; mean? 👉🏼
&lt;/h3&gt;

&lt;p&gt;Exception handling is the method by which an exception is &lt;em&gt;caught&lt;/em&gt; and managed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Then, how can we handle exceptions in JavaScript? 🕹
&lt;/h3&gt;

&lt;p&gt;To handle exceptions we'll use the &lt;strong&gt;try...catch&lt;/strong&gt; statement provided by JavaScript.&lt;/p&gt;

&lt;p&gt;As easy as that 😊&lt;/p&gt;

&lt;h1&gt;
  
  
  The &lt;em&gt;try...catch&lt;/em&gt; statement 🤠
&lt;/h1&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;try...catch&lt;/em&gt;&lt;/strong&gt; statement is a block that &lt;strong&gt;tries to perform&lt;/strong&gt; one or several actions that &lt;strong&gt;can lead to error conditions&lt;/strong&gt; and defines the instructions to &lt;strong&gt;handle such errors&lt;/strong&gt; appropriately in case they happen to occur.&lt;/p&gt;

&lt;p&gt;Let's see the structure for this statement:&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;try&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="cm"&gt;/*
 * Action(s) to be performed that can lead
 * to an anomalous condition.
 */&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="cm"&gt;/*
 * Error / exception handling.
 */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="cm"&gt;/*
 * Instruction(s) to be executed after
 * the try...catch statement ends.
 */&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Things to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Curly braces &lt;strong&gt;must be used&lt;/strong&gt; anytime, even for one line statements within the blocks.&lt;/li&gt;
&lt;li&gt;A &lt;em&gt;catch&lt;/em&gt; or a &lt;em&gt;finally&lt;/em&gt; block &lt;strong&gt;must be defined&lt;/strong&gt; as part of the &lt;em&gt;try...catch&lt;/em&gt; statement, but neither of them are mandatory separately.&lt;/li&gt;
&lt;li&gt;The previous point results in the following types of &lt;em&gt;try...catch&lt;/em&gt; statements:

&lt;ul&gt;
&lt;li&gt;try...catch&lt;/li&gt;
&lt;li&gt;try...finally&lt;/li&gt;
&lt;li&gt;try...catch...finally&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  The &lt;em&gt;throw&lt;/em&gt; statement 🎳
&lt;/h1&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;throw&lt;/em&gt;&lt;/strong&gt; statement, as its own name indicates, &lt;strong&gt;throws an exception&lt;/strong&gt; when something wrong occurs within the function or block it is declared.&lt;/p&gt;

&lt;p&gt;When a &lt;em&gt;throw&lt;/em&gt; statement is found, the execution of the current function stops and the &lt;strong&gt;control is shifted to the catch&lt;/strong&gt; block.&lt;/p&gt;

&lt;p&gt;A very simple 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="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&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;Something went wrong!&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="cm"&gt;/*
 * Output:
 * Error: Something went wrong!
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A throw statement &lt;strong&gt;is usually called within the&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;try&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;block&lt;/strong&gt;, but that doesn't mean that can't be called within a &lt;em&gt;catch&lt;/em&gt; block (to &lt;em&gt;rethrow&lt;/em&gt; an exception once it has been caught) or a &lt;em&gt;finally&lt;/em&gt; block (to throw an exception no matter which previous block has been executed).&lt;/p&gt;

&lt;p&gt;▫️ Rethrowing an exception in the &lt;em&gt;catch&lt;/em&gt; block:&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;try&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;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&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;🙄&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="k"&gt;throw&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="cm"&gt;/*
 * Output:
 * Error: 🙄
 * Error: 🙄
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;▫️ Throwing an exception in the &lt;em&gt;finally&lt;/em&gt; block:&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="k"&gt;try&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;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&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 - try block&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&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 - catch block&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;//Note that this exception is never caught&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;finally&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&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 - finally block&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="cm"&gt;/*
 * Output:
 * Error: Error - try block
 * Error: Error - finally block
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  User-defined exceptions 👨🏻‍💻👩🏻‍💻
&lt;/h1&gt;

&lt;p&gt;A &lt;em&gt;user-defined&lt;/em&gt; exception is a custom exception that can contain &lt;strong&gt;any valid expression&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The following statements are all correct:&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;throw&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&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;throw&lt;/span&gt; &lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's see an example where an &lt;strong&gt;object is thrown&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Note that object properties become accessible once the exception is caught, through the &lt;em&gt;error&lt;/em&gt; itself:&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;UserException&lt;/span&gt; &lt;span class="o"&gt;=&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;UserException&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="s1"&gt;There was an 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;try&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;UserException&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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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="nx"&gt;e&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;: &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;message&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="cm"&gt;/*
 * Output:
 * UserException: There was an error 🙃
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;JavaScript &lt;strong&gt;built-in errors&lt;/strong&gt; can also be used as objects for user-defined exceptions and be thrown accordingly.&lt;/p&gt;

&lt;p&gt;Take a look at the following example, where a &lt;strong&gt;&lt;em&gt;TypeError&lt;/em&gt;&lt;/strong&gt; error is thrown if the type of the required value is not &lt;em&gt;String&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="nx"&gt;TypeException&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&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;msg&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;There was an error regarding the data type.&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;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;msg&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;isString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;typeof&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="s1"&gt;string&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;city&lt;/span&gt; &lt;span class="o"&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;setCity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;cityName&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;isString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cityName&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="nx"&gt;city&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="nx"&gt;cityName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;TypeException&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="nx"&gt;setCity&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;28&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--- City name has been set correctly.---&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="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="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&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;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;finally&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;--- The execution has finished ---&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="cm"&gt;/*
 * Output: 
 * TypeError: There was an error regarding the data type.
 * --- The execution has finished. ---
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Conditional &lt;em&gt;catch&lt;/em&gt; blocks 🚀
&lt;/h1&gt;

&lt;p&gt;There may be occasions where the &lt;em&gt;try...catch&lt;/em&gt; block throws &lt;strong&gt;different types of exceptions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In order to handle each of them in a proper way, we can use &lt;strong&gt;&lt;em&gt;if...else&lt;/em&gt;&lt;/strong&gt; statements within the &lt;em&gt;catch&lt;/em&gt; block.&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;month&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;setMonth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;monthValue&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="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;monthValue&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monthValue&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;monthValue&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;monthValue&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;RangeError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;monthValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;month&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;monthValue&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="nx"&gt;setMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`-- Month &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; has been set correctly ---`&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errorInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Please enter a number [1-12]&lt;/span&gt;&lt;span class="dl"&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;e&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;TypeError&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="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Wrong data type: &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;message&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="nx"&gt;errorInfo&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="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;RangeError&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="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Out of range: &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;message&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="nx"&gt;errorInfo&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="cm"&gt;/*
 * Output: 
 * Out of range: -5. Please enter a number [1-12].
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We could also use a &lt;strong&gt;&lt;em&gt;switch&lt;/em&gt;&lt;/strong&gt; statement to handle multiple exceptions, being both examples equivalent:&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="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;setMonth&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&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="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`-- Month &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;month&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; has been set correctly ---`&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;errorInfo&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Please enter a number [1-12]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;switch&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;name&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;TypeError&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Wrong data type: &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;message&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="nx"&gt;errorInfo&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="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;RangeError&lt;/span&gt;&lt;span class="dl"&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="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Out of range: &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;message&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="nx"&gt;errorInfo&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="p"&gt;}&lt;/span&gt;
&lt;span class="cm"&gt;/*
 * Output: 
 * Out of range: -5. Please enter a number [1-12].
 */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h1&gt;
  
  
  Summary: key points 💫
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Exceptions are error conditions that &lt;strong&gt;break the normal flow&lt;/strong&gt; of the code execution.&lt;/li&gt;
&lt;li&gt;An exception can be &lt;strong&gt;any kind of expression&lt;/strong&gt;: a number, a string, an object...&lt;/li&gt;
&lt;li&gt;Exceptions should be thrown and handled appropriately in order &lt;strong&gt;to not crash the app&lt;/strong&gt; and let the user know that something &lt;strong&gt;didn't go as expected&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;JavaScript &lt;strong&gt;built-in errors can be used&lt;/strong&gt; as throwable objects for user-defined exceptions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple exceptions&lt;/strong&gt; can be handled within the same catch block.&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;⚡️ Related post on Instagram:&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CTCVoSDjH9t/embed/captioned"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;






&lt;p&gt;And that's all for today! 😇&lt;/p&gt;

&lt;p&gt;A big thanks for reading  🤗  and don't hesitate to reach out to me if you have any questions or doubts about today's article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" alt='Rachel Green from Friends TV Show behind a desk saying "Ask me anything"'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article useful and I see you all in the next 👋🏼&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt;
 on &lt;a href="https://instagram.com/underscorecode"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode"&gt;Twitter&lt;/a&gt; for more daily webdev content: info, challenges, quizzes &amp;amp; more 💜&lt;/p&gt;




&lt;h4&gt;
  
  
  And last but not least... A quick friendly reminder before we go 😊
&lt;/h4&gt;

&lt;p&gt;We all know there are million ways to get things done when it comes to programming and development, and we're here to &lt;strong&gt;help and learn&lt;/strong&gt;, so, if you know another possible way to do what others are sharing (&lt;strong&gt;not better, not worse, just different&lt;/strong&gt;), feel free to share it if you feel like it, but, please, &lt;strong&gt;always be kind and respectful&lt;/strong&gt; with the author and the rest of the community. Thank you and happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>programming</category>
    </item>
    <item>
      <title>UX 101 📲: Nielsen's 10 Usability Heuristic Principles for User Interface Design (6-10)</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Thu, 16 Sep 2021 11:24:00 +0000</pubDate>
      <link>https://dev.to/underscorecode/ux-101-nielsen-s-10-usability-heuristic-principles-for-user-interface-design-6-10-6gc</link>
      <guid>https://dev.to/underscorecode/ux-101-nielsen-s-10-usability-heuristic-principles-for-user-interface-design-6-10-6gc</guid>
      <description>&lt;p&gt;Hello, everybody! 👋&lt;/p&gt;

&lt;p&gt;And welcome to the second lecture of the &lt;strong&gt;UX 101 series&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;In this series, we will be talking about &lt;strong&gt;UX&lt;/strong&gt; and good practices when it comes to &lt;strong&gt;interface design&lt;/strong&gt; and &lt;strong&gt;user interaction&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;In this second lesson (together with the first lesson, which you can check out through the table above), we'll be studying  Nielsen's 10 Usability Heuristic Principles for User Interface Design.&lt;/p&gt;

&lt;p&gt;In today's lecture we'll be covering &lt;strong&gt;principles 6-10&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;👉🏼 Before delving into the matter, remember that we're also on &lt;a href="https://instagram.com/underscorecode"&gt;Instagram&lt;/a&gt;, where you can find daily content about web development, all the related slides to every published article and... quizzes and challenges! 💜&lt;/p&gt;

&lt;p&gt;Nielsen's Principles (6-10) related post  on Instagram 👇🏼&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CT2DBEIj451/embed/captioned"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


&lt;p&gt;So, with all this said, let's dive in! 🌊&lt;/p&gt;




&lt;h1&gt;
  
  
  6. Recognition rather than recall 👆🏼
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Users shouldn't have to memorize lots of information to be able to perform a task within the system. That's why making elements, actions and options visible helps them carry out their goals in an intuitive and approachable way.&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Reduce the cognitive load and effort on user's side, due to human limited short-term memory.&lt;/li&gt;
&lt;li&gt;Make the interface more intuitive so the user doesn't need to struggle when using the system.&lt;/li&gt;
&lt;li&gt;Accelerate user's learning process.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🧠 Memory retrieval
&lt;/h3&gt;

&lt;p&gt;Human memory is organized in &lt;strong&gt;chunks&lt;/strong&gt; (as it is computer memory), which are &lt;em&gt;activated&lt;/em&gt; when we need to retrieve the information they store. &lt;/p&gt;

&lt;p&gt;For these chunks to be activated and ready to work, three factors come into play:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Practice&lt;/strong&gt;: how often the information stored in a chunk has been retrieved. The more you practice something, the more easily you're going to remember it. When a chunk of memory is the first one in being activated, that means that it's the most accessed and practiced through time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Recency&lt;/strong&gt;: how recently a chunk has been practiced. This helps enormously to how clearly you're going to remember the information it contains. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;: what surrounds the person's focus of attention (stimuli that trigger such retrieval of information, like when you read, hear or see something). The keyword for this factor is &lt;strong&gt;&lt;em&gt;association&lt;/em&gt;&lt;/strong&gt;, a very important concept in psychology that is crucial and explains a lot of human mental conditions. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Association
&lt;/h4&gt;

&lt;p&gt;Association mainly works as a &lt;strong&gt;connection&lt;/strong&gt; between concepts and ideas, providing a link between past and present experience.&lt;/p&gt;

&lt;p&gt;Regarding memory retrieval, this means that when we perceive a stimulus, we're capable of retrieving information from multiple related chunks.&lt;/p&gt;

&lt;p&gt;Association varies a lot from individual to individual because it mainly depends on &lt;strong&gt;personal previous experience&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  👁 Recognition versus recall
&lt;/h3&gt;

&lt;p&gt;The main difference between these concepts is the amount of &lt;strong&gt;&lt;em&gt;cues&lt;/em&gt;&lt;/strong&gt; that can help memory retrieval when we perceive something.&lt;/p&gt;

&lt;p&gt;A &lt;em&gt;cue&lt;/em&gt; can be defined as a piece of information that contains &lt;em&gt;hints&lt;/em&gt; that sends our brain to retrieve information related to what we're perceiving at that precise moment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recognition is preferred&lt;/strong&gt; because it involves more cues than recall.&lt;/p&gt;

&lt;h4&gt;
  
  
  An example
&lt;/h4&gt;

&lt;p&gt;If someone asks you &lt;em&gt;Who wrote El Quijote?&lt;/em&gt;, you would likely have to think for at least a few seconds to be able to give an answer. &lt;strong&gt;That's recall&lt;/strong&gt;. The process involves remembering the name of an author.&lt;/p&gt;

&lt;p&gt;On the other hand, if they ask you &lt;em&gt;Did Miguel de Cervantes write El Quijote?&lt;/em&gt;, you would presumably be able to answer as soon as you're asked. &lt;strong&gt;That's recognition&lt;/strong&gt;. You are capable of easily identify the stated fact and answer rapidly.&lt;/p&gt;




&lt;p&gt;In our everyday lives &lt;strong&gt;we combine both recognition and recall&lt;/strong&gt; to retrieve information from memory (every second of the day, even though we're not aware of it).&lt;/p&gt;

&lt;h4&gt;
  
  
  👉🏼 Recall in user interfaces
&lt;/h4&gt;

&lt;p&gt;A very classical example: &lt;strong&gt;a login system&lt;/strong&gt;. When a user wants to access their profile or their personal area. Nothing but the website interface itself can provide a &lt;em&gt;hint&lt;/em&gt; to make the user remember their username and password (which hardly ever will provide a real hint). &lt;/p&gt;

&lt;p&gt;The user will need to remember their personal credentials, because there aren't &lt;em&gt;real&lt;/em&gt; clues in their current context.&lt;/p&gt;

&lt;h4&gt;
  
  
  👉🏼 Recognition in user interfaces
&lt;/h4&gt;

&lt;p&gt;Another classical example: &lt;strong&gt;a navigation system&lt;/strong&gt;. You're shown a few options, you identify which one you want to access and you perform your task. &lt;/p&gt;

&lt;h3&gt;
  
  
  🖥 How can we prioritize recognition over recall?
&lt;/h3&gt;

&lt;p&gt;The best we can do &lt;strong&gt;to make users&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;recognize our system's interface&lt;/em&gt;&lt;/strong&gt; when interacting with it is to make interface functions &lt;strong&gt;discoverable&lt;/strong&gt;, &lt;strong&gt;visible&lt;/strong&gt; and &lt;strong&gt;easily accessible&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An application mainly comprises &lt;strong&gt;two components&lt;/strong&gt;: the interface (buttons, links, navigation menus, forms...) and the content (the information provided by the system).&lt;/p&gt;

&lt;p&gt;The main goal to achieve with this principle is to make both of these components &lt;strong&gt;easy to remember&lt;/strong&gt; and &lt;strong&gt;reduce cognitive overload&lt;/strong&gt; on user's side, as stated up above.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make the information discoverable and affordable for the user so they don't have to remember it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always offer help based on user's context and try to target their current needs. Never expect the user to read a long tutorial or documentation to learn how to perform a task or to solve a problem. We'll see a more detailed approach to this down below, in the &lt;em&gt;10th Principle: Help and documentation&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try to reduce by any means the information the user needs to remember to be able to carry out an action successfully.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Identify&lt;/li&gt;
&lt;li&gt;Recognize&lt;/li&gt;
&lt;li&gt;Remember&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Association&lt;/li&gt;
&lt;li&gt;Experience&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  7. Flexibility and efficiency of use 🎛
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Users should be provided with different ways to be able to perform tasks within the system, be their expertise level novice or expert.&lt;/p&gt;

&lt;p&gt;Shortcuts are a good example of this: they help expert users achieve their goals faster without being an obstacle for less-experienced users.&lt;/p&gt;

&lt;p&gt;These &lt;em&gt;flexible&lt;/em&gt; ways can be presented in many forms so the users can pick up their &lt;em&gt;own way&lt;/em&gt; out of the choices they're provided with.&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make the system flexible enough to be fully adapted to every user's expertise level so they can feel confident by being presented with a variety of options when it comes to performing tasks.&lt;/li&gt;
&lt;li&gt;Improve user's reliability on the system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  👩‍💻👨‍💻 Different users. Different needs.
&lt;/h3&gt;

&lt;p&gt;When users interact with an interface for the first time, they will presumably need guidance to help them get to know the system environment in order to get familiar with it and be able to achieve their goals. For example, a good idea would be to provide &lt;em&gt;step-by-step&lt;/em&gt; tutorials, since they're likely not going to skip them if they really want to learn how to use the system.&lt;/p&gt;

&lt;p&gt;On the other hand, experienced users may expect &lt;em&gt;accelerators&lt;/em&gt; to perform the same tasks, like &lt;strong&gt;shortcuts&lt;/strong&gt; and &lt;strong&gt;touch gestures&lt;/strong&gt;, although they can still use the traditional methods.&lt;/p&gt;

&lt;p&gt;It's never recommended to provide interaction methods only for a specific population of users, even though you think you already know their level of expertise. Because &lt;strong&gt;every user is different&lt;/strong&gt; and, accordingly, their needs are.&lt;/p&gt;

&lt;p&gt;So the point is to create a &lt;strong&gt;flexible and efficient system&lt;/strong&gt; that provides &lt;strong&gt;multiple methods to perform the same tasks&lt;/strong&gt; according to the variety of users who interact with it.&lt;/p&gt;

&lt;p&gt;The main goal of providing different ways to do the same thing is to &lt;strong&gt;suit the user's working style&lt;/strong&gt;, so they feel confident to use the system &lt;em&gt;their way&lt;/em&gt;. This also improves their reliability on the system, since they feel like someone &lt;em&gt;cares about their needs&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It's recommended to provide a &lt;strong&gt;customizable interface&lt;/strong&gt; when possible, basically to give sort of support users' work habits, even though most users don't bother to customize the system.&lt;/p&gt;

&lt;p&gt;Take into mind that if you provide customization, this should be &lt;strong&gt;consistent between sessions&lt;/strong&gt; and not be lost in-between.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provide shortcuts so the experienced users can speed up their task performance.&lt;/li&gt;
&lt;li&gt;Don't use obstructive ways that can limit a specific group of users.&lt;/li&gt;
&lt;li&gt;Try to customize as much as possible all the content and functionality to adapt them to individual group of users.&lt;/li&gt;
&lt;li&gt;Allow customization on user's side so they can select and adapt the system to meet their own needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Flexibility&lt;/li&gt;
&lt;li&gt;Shortcuts&lt;/li&gt;
&lt;li&gt;Adaptation&lt;/li&gt;
&lt;li&gt;Expertise&lt;/li&gt;
&lt;li&gt;Accelerators&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  8. Aesthetic and minimalist design ✨
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Interfaces shouldn't include information that is unimportant to users, since it may take away visibility of relevant content.&lt;/p&gt;

&lt;p&gt;This doesn't mean you're obliged to use a &lt;em&gt;flat design&lt;/em&gt;. It's more about keeping design &lt;strong&gt;focused&lt;/strong&gt; and &lt;strong&gt;targeted&lt;/strong&gt; to the point.&lt;/p&gt;

&lt;p&gt;This principle is closely related to &lt;strong&gt;&lt;em&gt;Gestalt Principles&lt;/em&gt;&lt;/strong&gt;. In future lessons of this series, we'll be talking about them and going further into the topic of design of interfaces.&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provide a clean, usable interface, focused on users' goals.&lt;/li&gt;
&lt;li&gt;Reduce distracting elements that can constitute an obstacle to them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Regarding visuals, always focus on the basics and don't overload the interface.&lt;/li&gt;
&lt;li&gt;Don't include elements that are not relevant and can become a distraction to the user.&lt;/li&gt;
&lt;li&gt;Focus on users' main goals rather than provide a &lt;em&gt;fancy&lt;/em&gt; interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Minimalism&lt;/li&gt;
&lt;li&gt;Plain&lt;/li&gt;
&lt;li&gt;Clean&lt;/li&gt;
&lt;li&gt;Focused&lt;/li&gt;
&lt;li&gt;Targeted&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  9. Help users recognize, diagnose and recover from errors ⛔️
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Errors should be presented as clear messages, always straight to the point and be written in an understandable language, so the user can easily be aware of what's going on. These messages should be focused on the real problem and provide or recommend a possible solution to the issue.&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Provide quick response when an error appears.&lt;/li&gt;
&lt;li&gt;Help users accomplish their tasks.&lt;/li&gt;
&lt;li&gt;Provide constructive advice for future interaction.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🛑 How error messages should be presented to the user
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Should be &lt;strong&gt;explicit&lt;/strong&gt; and manifest in a clear way that something went wrong.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Should be &lt;strong&gt;human-readable&lt;/strong&gt;, so always avoid using technical vocabulary or jargon words and/or codes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Should be &lt;strong&gt;polite&lt;/strong&gt;. Never blame the user for errors. Remember that all those mistakes are caused by the designer, never the user, so don't patronize them or make them feel like they did something wrong.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Should be &lt;strong&gt;precise&lt;/strong&gt; and &lt;strong&gt;exact&lt;/strong&gt;. Always try to go to the point and avoid general error messages like &lt;em&gt;Fatal error&lt;/em&gt; or &lt;em&gt;Something went wrong&lt;/em&gt;, which don't provide extra information and will likely send the user to wonder what they did wrong.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide &lt;strong&gt;constructive&lt;/strong&gt; advice on what the real problem is. As a very basic example, picture a login system in which there's a form with two fields: &lt;em&gt;username&lt;/em&gt; and &lt;em&gt;password&lt;/em&gt;. Say the user has a typo in the username field, so they receive the following message when trying to log in: &lt;em&gt;Incorrect password or username. Try again.&lt;/em&gt;&lt;br&gt;
Just be clear and tell the user which the username or the password is throwing the error. In this example there's only two fields, but could be way more.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  💬 How to use plain language to communicate with the user
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Identify your &lt;strong&gt;potential audience&lt;/strong&gt; to adapt your writing to their needs and expectations. Try to stick to their level of reading, the language they're used to, the concepts they are familiar with and how they expect the information to be presented. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try &lt;strong&gt;not to use slang&lt;/strong&gt;, idioms, acronyms or complicated terms. Complex language is difficult to understand and may sound pretentious to the user. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Keep sentences and paragraphs &lt;strong&gt;short&lt;/strong&gt;. You can convey the same ideas with less words.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For general audiences, try to write for &lt;strong&gt;6-8th graders&lt;/strong&gt;. For experts, don't go beyond 10-12th.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make use of &lt;em&gt;traditional&lt;/em&gt; error message &lt;em&gt;visuals&lt;/em&gt;, like red color, bold typography, alert sounds, etc.&lt;/li&gt;
&lt;li&gt;Communicate errors using a language users understand.&lt;/li&gt;
&lt;li&gt;Provide valid solutions to fix possible issues as soon as they're identified.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Concise&lt;/li&gt;
&lt;li&gt;Precise&lt;/li&gt;
&lt;li&gt;Constructive&lt;/li&gt;
&lt;li&gt;Plain language&lt;/li&gt;
&lt;li&gt;Straight to the point&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  10. Help and documentation 🗂
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;An optimal system would be that one that doesn't need to provide extra information, but, most times, that's something we can't avoid because &lt;strong&gt;users need clues on how to perform tasks&lt;/strong&gt; so they can reach their goals.&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Anticipate problems the user may be facing when interacting with the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provide users with relevant extra information to make them feel comfortable, successful and to improve their reliability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make users succeed when carrying out tasks and meet their expectations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🗄 Types of help: proactive and reactive
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Proactive help
&lt;/h4&gt;

&lt;p&gt;Proactive help is used to &lt;strong&gt;prevent problems&lt;/strong&gt; and its main goal is &lt;strong&gt;to get the user know&lt;/strong&gt; how the system's interface works. There are two types of &lt;em&gt;notifications&lt;/em&gt; that belong to this kind of help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Push revelations&lt;/strong&gt;: used to provide help to the user with no regard to the task they're trying to accomplish in that precise moment. They use to appear randomly and out of nowhere containing information that hasn't been asked for.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pull revelations&lt;/strong&gt;: used to provide help that is relevant to the task that is being performed by the user. They can appear when the user has initiated a new task or when they're &lt;em&gt;close&lt;/em&gt; to face a problem.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's highly recommended to always &lt;strong&gt;choose pull over push&lt;/strong&gt; revelations when possible.&lt;/p&gt;

&lt;p&gt;Take into mind that we will face three types of scenarios when dealing with proactive help provision: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;New users using the interface for the first time. &lt;/li&gt;
&lt;li&gt;Novice users that are still learning how to use the system.&lt;/li&gt;
&lt;li&gt;Expert users that encounter an update of the interface (for example, a new design or new functionalities).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Reactive help
&lt;/h4&gt;

&lt;p&gt;Resources like documentation, videos, tutorials and guides constitute reactive help, which is useful when a user encounters an issue and needs help to address it. The main goal of this kind of help is to &lt;strong&gt;answer questions&lt;/strong&gt; and &lt;strong&gt;provide a final solution&lt;/strong&gt; to fix a problem. FAQ and technical tutorials are a good example of this kind of help.&lt;/p&gt;

&lt;p&gt;Always ensure that the resources you're providing the user with are detailed, understandable and useful. It's recommended to provide &lt;em&gt;step-by-step&lt;/em&gt; instructions because the user &lt;em&gt;needs to fix something&lt;/em&gt;. They don't read documentation just for fun.&lt;/p&gt;

&lt;p&gt;Don't stick to only providing one source of information: &lt;strong&gt;complement your writing&lt;/strong&gt; with videos, graphics or any other multimedia resource that you consider that may be useful to help your users.&lt;/p&gt;

&lt;p&gt;Structure your information into &lt;strong&gt;categories&lt;/strong&gt; and provide &lt;strong&gt;search&lt;/strong&gt; so users can easily find what they're looking for. &lt;/p&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Documentation should be visible, easy to find and, mostly, easy to search.&lt;/li&gt;
&lt;li&gt;Present the required information in context right at the moment when it's needed.&lt;/li&gt;
&lt;li&gt;Provide a list stating the steps that should be followed to accomplish a task or address an issue.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Tutorials&lt;/li&gt;
&lt;li&gt;Troubleshoot&lt;/li&gt;
&lt;li&gt;Searchable&lt;/li&gt;
&lt;li&gt;Help in context&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;And this is all for the second lecture of the UX 101 series! &lt;/p&gt;

&lt;p&gt;Stay tuned to know more about UX in future episodes of the series.&lt;/p&gt;

&lt;p&gt;A big thanks for reading  🤗  and don't hesitate to reach out to me if you have any questions or doubts about today's lecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" alt='Rachel Green from Friends TV Show behind a desk saying "Ask me anything"'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article useful and I see you all in the next 👋&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt;
 on &lt;a href="https://instagram.com/underscorecode"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode"&gt;Twitter&lt;/a&gt; for more daily webdev content: info, challenges, quizzes &amp;amp; more 💜&lt;/p&gt;




</description>
      <category>uiweekly</category>
      <category>ux</category>
      <category>webdev</category>
      <category>design</category>
    </item>
    <item>
      <title>UX 101 📲: Nielsen's 10 Usability Heuristic Principles for User Interface Design (1-5)</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Sat, 28 Aug 2021 16:59:37 +0000</pubDate>
      <link>https://dev.to/underscorecode/ux-101-nielsen-s-10-usability-heuristic-principles-for-user-interface-design-1-5-1l5d</link>
      <guid>https://dev.to/underscorecode/ux-101-nielsen-s-10-usability-heuristic-principles-for-user-interface-design-1-5-1l5d</guid>
      <description>&lt;p&gt;Hello, everybody! 👋&lt;/p&gt;

&lt;p&gt;And welcome to the first lecture of the &lt;strong&gt;UX 101 series&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;In this series, we will be talking about &lt;strong&gt;UX&lt;/strong&gt; and good practices when it comes to &lt;strong&gt;interface design&lt;/strong&gt; and &lt;strong&gt;user interaction&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;In the first two lessons (this one and the following one), we'll be studying Nielsen's 10 Usability Heuristic Principles for User Interface Design.&lt;/p&gt;

&lt;p&gt;In this first lecture we'll cover &lt;strong&gt;the first five principles&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;👉🏼 Before delving into the matter, remember that we're also on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt;, where you can find daily content about web development, all the related slides to every published article and... quizzes and challenges! 💜&lt;/p&gt;

&lt;p&gt;Nielsen's Principles (1-5) related post  on Instagram 👇🏼&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CTHh--hjqnD/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;


&lt;p&gt;So, with all this said, let's dive into today's lesson 🌊&lt;/p&gt;

&lt;h1&gt;
  
  
  What are &lt;em&gt;heuristics&lt;/em&gt;?
&lt;/h1&gt;

&lt;p&gt;Heuristics are &lt;strong&gt;techniques&lt;/strong&gt; used to improve the usability of a system based on a previous experience. This improvement consists basically on &lt;strong&gt;solving existent problems&lt;/strong&gt; and &lt;strong&gt;identifying the necessities&lt;/strong&gt; of the said system during the iterative design cycle.&lt;/p&gt;

&lt;p&gt;Even though this method is far from being perfect or optimal, it &lt;strong&gt;speeds up the process of development&lt;/strong&gt; and provides a way to start solving issues as soon as they are discovered and identified.&lt;/p&gt;

&lt;p&gt;Let's now turn our attention to the &lt;strong&gt;first five Nielsen's Principles&lt;/strong&gt; for User Interface Design: &lt;/p&gt;

&lt;h1&gt;
  
  
  1. Visibility of system status 🖥
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;The system has to &lt;strong&gt;inform&lt;/strong&gt; the users about the current system status and what is going on &lt;strong&gt;at all times&lt;/strong&gt;, by providing them with &lt;strong&gt;appropriate feedback&lt;/strong&gt; within a &lt;strong&gt;reasonable time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The system status includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where the user is within the navigation tree.&lt;/li&gt;
&lt;li&gt;Where the user is within a process derived from a taken action.&lt;/li&gt;
&lt;li&gt;If the system is stable and everything is working as it should or something went wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This principle is necessary to make the the user capable of deciding which their next steps will be, based on what's happening at that particular moment (&lt;strong&gt;anticipation&lt;/strong&gt;), since they know beforehand where they are and what the current system status is.&lt;/p&gt;

&lt;p&gt;Another advantage of implementing this principle is the &lt;strong&gt;reliability&lt;/strong&gt; we're going to convey to the user. They will end up &lt;strong&gt;trusting&lt;/strong&gt; not only the product or the service we're trying to &lt;em&gt;sell&lt;/em&gt;, but also the brand or the individual behind the service (let's say, for example, a &lt;em&gt;blogger&lt;/em&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make the system &lt;strong&gt;predictable&lt;/strong&gt; and let the users know that they have the &lt;strong&gt;control&lt;/strong&gt;, which, consequently, will send them to think that everything's going to proceed in the way they wish and expect.&lt;br&gt;
The less information they get, the easier it will be that they think that they're not in control of the situation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the user feeling &lt;strong&gt;comfortable&lt;/strong&gt; while they go through a series of steps towards a goal.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create a recurring &lt;em&gt;client&lt;/em&gt; (or visitor) and convey trust and reliability looking to the future.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Always inform the user on what's going on. Always. No matter what. &lt;strong&gt;Communication&lt;/strong&gt; and &lt;strong&gt;transparency&lt;/strong&gt; are key (like in relationships with people in real world). Let them know the result of their actions and don't leave them wondering if they made a mistake after having taken action over something.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Nothing&lt;/strong&gt; that affects the users &lt;strong&gt;should happen without informing&lt;/strong&gt; them beforehand. Let alone something that leads to an error condition or a situation from which they don't know how to recover.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you can avoid this type of situations and they happen at some point, tell the user &lt;strong&gt;immediately&lt;/strong&gt;. Or, at least, as soon as possible. &lt;strong&gt;Quick response&lt;/strong&gt; results in &lt;strong&gt;early recovery from errors&lt;/strong&gt; and &lt;strong&gt;providing enough information&lt;/strong&gt; leads to &lt;strong&gt;better decisions&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Build &lt;strong&gt;trust&lt;/strong&gt; through interacting with your users.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At the end of the day, this principle refers more to &lt;strong&gt;how well you communicate&lt;/strong&gt; with your users than the fact of communicate with them itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  📱 What can we do as UI designers?
&lt;/h3&gt;

&lt;p&gt;A good start would be to implement a series of standard elements that help the user notice the status of the system, like the following:&lt;/p&gt;

&lt;h4&gt;
  
  
  Breadcrumbs
&lt;/h4&gt;

&lt;p&gt;The user should know where they exactly are within the navigation tree at all times.&lt;br&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%2Fuploads%2Farticles%2Fij6sxpnwf2cz6vmht4pu.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%2Fuploads%2Farticles%2Fij6sxpnwf2cz6vmht4pu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Provide feedback of a taken action
&lt;/h4&gt;

&lt;p&gt;For example, by highlighting an element after taking an action on it.&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%2Fuploads%2Farticles%2Fkdd7xk0e49u8wtavao3s.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%2Fuploads%2Farticles%2Fkdd7xk0e49u8wtavao3s.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Progress bars
&lt;/h4&gt;

&lt;p&gt;Always let the user know where they are within a multi-step process and show progress bars when appropriate.&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%2Fuploads%2Farticles%2Fjge58b3psd5nkhz9bw4z.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%2Fuploads%2Farticles%2Fjge58b3psd5nkhz9bw4z.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Spinners
&lt;/h4&gt;

&lt;p&gt;Implement spinners to let the user know that they have to wait for an action to complete. Don't leave them wondering what's going 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%2Fuploads%2Farticles%2F8exl658600kuh35l6z4k.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%2Fuploads%2Farticles%2F8exl658600kuh35l6z4k.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🤖 Keywords to this principle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Communication&lt;/li&gt;
&lt;li&gt;Transparency&lt;/li&gt;
&lt;li&gt;Trust&lt;/li&gt;
&lt;li&gt;Reliability&lt;/li&gt;
&lt;li&gt;Anticipation&lt;/li&gt;
&lt;li&gt;Feedback &lt;/li&gt;
&lt;li&gt;Information&lt;/li&gt;
&lt;li&gt;Decisions&lt;/li&gt;
&lt;li&gt;Predictability&lt;/li&gt;
&lt;li&gt;Control&lt;/li&gt;
&lt;li&gt;Comfort&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  2. Match between the system and the real world 🖥↔️🌎
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;The system should speak the users' language, this is, they have to be capable of easily understand everything they perceive while interacting with the system. &lt;/p&gt;

&lt;p&gt;Human beings find comfort in &lt;strong&gt;familiarity&lt;/strong&gt;, so bear in mind that it's fundamental to use concepts and words that the users already know, have an idea of and find easy to understand. That's what we understand by &lt;em&gt;familiar&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;It's true that every person has a &lt;strong&gt;different understanding and perception&lt;/strong&gt; of the world: some things can be very obvious for you, but not that obvious for, let's say, a friend of yours.&lt;/p&gt;

&lt;p&gt;So, since this is something &lt;strong&gt;unavoidable&lt;/strong&gt; (but manageable), it's important to take this fact into mind, and, as a result, base every concept of the system in &lt;strong&gt;real world conventions&lt;/strong&gt;. &lt;strong&gt;Never assume that your understanding and your particular interpretation of the world match the ones of your final users&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These interpretations are formed based on previous experiences, familiarity with language and objects, beliefs, ideas and values, and are called &lt;strong&gt;mental models&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Each user has its own mental model and they &lt;strong&gt;carry these interpretations with them&lt;/strong&gt; from the real world to the digital world, so it's our work to ease this transition by expressing concepts appropriately.&lt;/p&gt;

&lt;p&gt;Since it's impossible to know what the vision of the world is for every user, the only thing we can do to create a suitable conceptual model for our system is to use &lt;strong&gt;logical statements&lt;/strong&gt; and concepts that are &lt;strong&gt;widely extended within society&lt;/strong&gt;. This will result in users making use of the system &lt;strong&gt;intuitively&lt;/strong&gt; and &lt;strong&gt;comfortably&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Match user's expectations as to their interaction with the system.&lt;/li&gt;
&lt;li&gt;Let them know that you understand their needs and care about them: to show &lt;strong&gt;empathy&lt;/strong&gt; will make them feel important.&lt;/li&gt;
&lt;li&gt;Build &lt;strong&gt;trust&lt;/strong&gt; and set a feeling of &lt;strong&gt;familiarity&lt;/strong&gt; on their side, which will lead to &lt;strong&gt;loyal users&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure your users &lt;strong&gt;understand&lt;/strong&gt; every piece of information they are interacting with and be aware of the importance that this fact has.&lt;br&gt;
Users should always be able to understand the meaning of everything they run into without having to go look it up in a search engine, so &lt;strong&gt;never use jargon or complex words&lt;/strong&gt;. Better use &lt;strong&gt;natural language&lt;/strong&gt; and present information in a &lt;strong&gt;natural and intuitive&lt;/strong&gt; order. Everything &lt;strong&gt;should flow naturally&lt;/strong&gt; to facilitate the user the task of proceeding when using the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never assume&lt;/strong&gt; the way of making use of the system by an user and how will they behave while interacting with it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Do a &lt;strong&gt;research&lt;/strong&gt; on what &lt;strong&gt;kind of user&lt;/strong&gt; will interact with your system to find out what &lt;strong&gt;concepts are familiar&lt;/strong&gt; to them and what &lt;strong&gt;type of language&lt;/strong&gt; you should use, and adapt yours, if necessary.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords to this principle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Familiarity&lt;/li&gt;
&lt;li&gt;Logic&lt;/li&gt;
&lt;li&gt;Real world&lt;/li&gt;
&lt;li&gt;Perception&lt;/li&gt;
&lt;li&gt;Care&lt;/li&gt;
&lt;li&gt;Empathy&lt;/li&gt;
&lt;li&gt;Experience&lt;/li&gt;
&lt;li&gt;Natural&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  3. User control and freedom 👩‍💻👨‍💻
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Users make mistakes, so they have to be provided with emergency exits in case they need to escape or recover from wrongly performed actions.&lt;/p&gt;

&lt;p&gt;But not only when they proceed in a wrong way: they always have to be &lt;strong&gt;allowed to correct mistakes&lt;/strong&gt; and &lt;strong&gt;change their minds&lt;/strong&gt;, especially when they open up a new page, screen or view (usually through clicking a provided link).&lt;/p&gt;

&lt;p&gt;A large amount of users still rely on browser's or device's back buttons instead of using the back links provided by the system, so it's important to pay close attention when leading actions towards new tabs since some users can have trouble trying to go back.&lt;/p&gt;

&lt;h3&gt;
  
  
  ◽️ Types of &lt;em&gt;emergency&lt;/em&gt; exits
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Back link&lt;/strong&gt;: a link that allows the user to go back in a page, screen or view.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cancel link&lt;/strong&gt;: a link that allows the user to interrupt the process of an ongoing action.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Close link&lt;/strong&gt;: a link that allows the user to close an open view (e.g., modals).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Undo link&lt;/strong&gt;: a link that allows the user to reverse a taken action, which should also be ideally accompanied by its corresponding &lt;em&gt;redo&lt;/em&gt; link, to let them know they can change their mind anytime even if they make a mistake in the course of performing an action.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Ensure that the user &lt;strong&gt;feels in control&lt;/strong&gt; of the situation when interacting with the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Give users the &lt;strong&gt;freedom to perform actions&lt;/strong&gt; within the system without leaving them wondering and worried about the actions they are performing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Make the user &lt;strong&gt;feel comfortable&lt;/strong&gt; enough to &lt;strong&gt;explore the system&lt;/strong&gt; without feeling inhibited, which is a direct consequence of them knowing that they can take actions that can be reversed if they make a mistake.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Facilitate the user the task of finding &lt;em&gt;emergency&lt;/em&gt; exits on your system, just as it's easy to find their counterparts in public spaces, like a shopping mall.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Using icons that are &lt;strong&gt;universally recognizable&lt;/strong&gt; by the user can help match their &lt;strong&gt;mental models&lt;/strong&gt; (like using a cross to close a view). You can add a text label to point more clearly where the corresponding action will lead them to.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Allow the user to &lt;strong&gt;cancel&lt;/strong&gt; an action at &lt;strong&gt;any point&lt;/strong&gt; of the process. This is specially important when it comes to a purchase, a money transfer or a download that can take some time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always support the &lt;strong&gt;undo&lt;/strong&gt; of an action by implementing links, toggles or checkboxes and ensure that they are well placed to be easily discoverable by the user.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords to this principle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Control&lt;/li&gt;
&lt;li&gt;Freedom&lt;/li&gt;
&lt;li&gt;Exits&lt;/li&gt;
&lt;li&gt;Mistakes&lt;/li&gt;
&lt;li&gt;Exploration&lt;/li&gt;
&lt;li&gt;Cancel&lt;/li&gt;
&lt;li&gt;Go back&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  4. Consistency and standards ⌚️
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Users have expectations when interacting with a system, which are based on their previous experiences with another systems.&lt;/p&gt;

&lt;p&gt;Jakob's Law states:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"&lt;em&gt;People spend most of their time using products that are not yours, so they expect your product works in the way the others do. Failing to fulfill these expectation may result in user’s cognitive overload and force them to learn something new.&lt;/em&gt;"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So that's important that our system follows already established conventions when it comes to user interaction and interface design, as we mentioned in &lt;em&gt;Principle 2: Match between the system and the real world&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Some examples of these conventions are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Underlined&lt;/strong&gt; text means &lt;em&gt;clickable&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;shopping cart&lt;/strong&gt; / basket icon represents the section where the items you select to buy are stored and from where you will be able to proceed to a checkout process eventually.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Red&lt;/strong&gt; means stop / danger and &lt;strong&gt;green&lt;/strong&gt; means go / safe.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;magnifier&lt;/strong&gt; icon means &lt;em&gt;search&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;While accessing a website or an app on portable devices, an icon representing &lt;strong&gt;three vertically stacked lines&lt;/strong&gt; means that there is a hidden navigation menu.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ◽️ Internal versus external consistency
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Internal consistency&lt;/em&gt; regards &lt;strong&gt;consistency and standards across a product&lt;/strong&gt; or a family of products. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When it comes to a single app, this means that &lt;strong&gt;consistency should remain throughout the platform&lt;/strong&gt;: layout, colors, shapes, typography, visual items treatment...&lt;/p&gt;

&lt;p&gt;On the other hand, while facing the design of a family of related products, not only the conventions above should be met but also have to &lt;strong&gt;keep a coherent relation between them all&lt;/strong&gt; when it comes to layout, icons and functionality, to mention a few.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;External consistency&lt;/em&gt; refers to &lt;strong&gt;consistency and standards that match the industry&lt;/strong&gt; and / or web conventions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As an example, note that all well-known &lt;em&gt;e-Commerce&lt;/em&gt; sites follow &lt;strong&gt;common standards&lt;/strong&gt; in order to make the purchase experience &lt;strong&gt;consistent and efficient&lt;/strong&gt; to the customer. Otherwise, it would lead to them leaving the &lt;em&gt;store&lt;/em&gt; and looking for another one where they understand the steps they need to take towards their goal (the purchase of an arbitrary number of items) and where they feel comfortable with the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  ◽️ Layers of consistency
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Visual
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Colors, typography, icon design, title decoration, etc should be &lt;strong&gt;consistent across the system&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Images should be treated similarly: aspect ratio, borders, size...&lt;/li&gt;
&lt;li&gt;Symbols should be consistent with the &lt;strong&gt;action&lt;/strong&gt; they lead to or the &lt;strong&gt;information&lt;/strong&gt; they're providing: use an icon of a plane for flight search, an icon of a car for car rental, an icon of a cat or a dog when specifying if pets are allowed in an accommodation, a cigarette when pointing out if it's allowed to smoke or not, or a shopping cart to store the items that can be eventually purchased, as mentioned earlier above.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  2. Page layout
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;All items related to page layout &lt;strong&gt;should remain consistent and coherent&lt;/strong&gt; across all the pages of the site.&lt;/li&gt;
&lt;li&gt;It doesn't matter where you decide to locate buttons and other layout items, but &lt;strong&gt;do it consistently&lt;/strong&gt;: don't place the same button in different places when having different screens among the same process, for example.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  3. User-entered data
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;This is especially important when it comes to dates, phone numbers and locations. &lt;strong&gt;Avoid to use an open field&lt;/strong&gt; for this type of data. &lt;/li&gt;
&lt;li&gt;Provide the user with &lt;strong&gt;date pickers&lt;/strong&gt; or &lt;strong&gt;auto-formatting&lt;/strong&gt; so they don't have to think about how to enter the required information and let them know they don't have to insert separators in any case (so you don't have to split the entered information later on).&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  4. Content
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;consistent tone of voice&lt;/strong&gt; across the site is crucial. Otherwise the user can feel confused, which will result in not meeting their expectations, and consequently, leaving and / or not returning.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't mix casual tone with formal tone&lt;/strong&gt; and always present the information in a way that is readable and understandable by the majority of the users that access your platform.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Meet user's expectations, since they come to use your system with a preconceived idea of how it &lt;em&gt;should&lt;/em&gt; work (based on their mental model).&lt;/li&gt;
&lt;li&gt;Build their &lt;strong&gt;confidence&lt;/strong&gt; towards the system.&lt;/li&gt;
&lt;li&gt;Make them &lt;strong&gt;focus entirely on the content&lt;/strong&gt; rather than let them wondering what's the meaning of what they're viewing, reading or listening to.&lt;/li&gt;
&lt;li&gt;Make sure that the user &lt;strong&gt;doesn't have to learn something new&lt;/strong&gt; in order to interact with your system (or at least as less as possible).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Always pay attention and implement &lt;strong&gt;both internal and external consistence&lt;/strong&gt;, to make sure all the standards and conventions are met.&lt;/li&gt;
&lt;li&gt;Follow &lt;strong&gt;industry and web conventions&lt;/strong&gt; to avoid the user have to learn new things or concepts while interacting with your system.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords to this principle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Consistency&lt;/li&gt;
&lt;li&gt;Conventions&lt;/li&gt;
&lt;li&gt;Standards&lt;/li&gt;
&lt;li&gt;Expectations&lt;/li&gt;
&lt;li&gt;Interaction&lt;/li&gt;
&lt;li&gt;Confidence&lt;/li&gt;
&lt;li&gt;Focus&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  5. Error prevention ❌ → ✅
&lt;/h1&gt;

&lt;h3&gt;
  
  
  💡 Main idea
&lt;/h3&gt;

&lt;p&gt;Users, as human beings, make errors. You, as an user, make errors. Everybody does. That's something natural. But, even it's something unavoidable, it can also be alleviated by designing a good interface for our system, in these terms.&lt;/p&gt;

&lt;p&gt;Although alerting the user with an error message is a good practice, it's even better to design a &lt;strong&gt;non error-prone system&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  ◽️ Types of errors
&lt;/h3&gt;

&lt;p&gt;There are two types of errors the users can make: &lt;strong&gt;slips&lt;/strong&gt; (minor errors) and &lt;strong&gt;mistakes&lt;/strong&gt; (conscious errors).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Slips&lt;/strong&gt;: This type of error is often caused by &lt;strong&gt;inattention&lt;/strong&gt; on user's side, like &lt;em&gt;typos&lt;/em&gt;. They are more often made by experienced users, who use the autopilot when interacting with a system: they feel comfortable and rely their confidence on their previous experience with it, while newbies pay more attention to what they're doing since they're &lt;em&gt;learning&lt;/em&gt; how to interact with the system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Mistakes&lt;/strong&gt;: These are caused by a &lt;strong&gt;mismatch&lt;/strong&gt; between the user's mental model and the design of the system. They take the correct steps towards their goal but these can be inappropriate for the situation. &lt;em&gt;Mistakes&lt;/em&gt; are more difficult to prevent than &lt;em&gt;slips&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ◽️ How to prevent &lt;em&gt;slips&lt;/em&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Always include &lt;strong&gt;helpful constraints&lt;/strong&gt; for user input. For example, regarding a form input field where a range of dates should be entered, always compel the user to select a range where the first date comes before the second date.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Offer &lt;strong&gt;suggestions&lt;/strong&gt; as to search, to avoid typos.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose &lt;strong&gt;according default values&lt;/strong&gt;, when needed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use &lt;strong&gt;&lt;em&gt;forgiving&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;formatting&lt;/strong&gt;. This means that, for some input fields, every user can have a different idea on how to enter data, for example, a phone number. So, from here, we have two options: getting rid of the info the user has entered and which is not needed (parentheses or hyphens, for example) or autocompleting the phone number with these special characters while the user is typing. This latter improves their reliability on the system, since they know that they're performing the task correctly, so it's more appropriated than the first one.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  ◽️ How to prevent &lt;em&gt;mistakes&lt;/em&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Collect data&lt;/strong&gt;. While you're still designing the system, you can gather information about what kind of users are going to use it and do a little research, so you can be aware of what you can expect of their actual &lt;strong&gt;mental models&lt;/strong&gt;.&lt;br&gt;
Once you have your system designed, you can run &lt;strong&gt;usability testing&lt;/strong&gt; to know what's wrong with the usage of your system on user's side.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Follow &lt;strong&gt;design conventions&lt;/strong&gt;, as we've mentioned above, in &lt;em&gt;Principle #2: Match between the system and the real world&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Communicate &lt;strong&gt;affordances&lt;/strong&gt;. This means that the user should be able to know when an &lt;strong&gt;element&lt;/strong&gt; of the interface is &lt;strong&gt;available&lt;/strong&gt; and, consequently, that is interactive and that an action can be taken on it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Preview results&lt;/strong&gt;. Let the user know that the action they're going to take may result in changes at scope level within the system, so they can double-check if they really want to proceed and inform them on what's going on from there.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  ◽️ Good practices to prevent both types of errors
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Don't make the user have to &lt;strong&gt;remember&lt;/strong&gt; things or keep information about something within the system. Always provide contextual information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Show a &lt;strong&gt;confirmation dialog&lt;/strong&gt; before they take an action that causes changes, like deleting something.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always support &lt;strong&gt;undo&lt;/strong&gt;, so the user knows that the changes they would do can be revoked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Let the user know that they will &lt;strong&gt;incur an error&lt;/strong&gt; if they proceed when they're actually doing something that is not allowed. For example, if the user surpasses the number of allowed characters as to a text.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  💎 Main goals
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Prevent the majority of mistakes&lt;/strong&gt; a user can make when interacting with our system, rather than waiting for them to perform an action that leads to an error to inform them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make the user comfortable with the system&lt;/strong&gt; by letting them know that if they make a mistake, they can &lt;strong&gt;undo&lt;/strong&gt; the taken action, so their confidence and reliability on the system grow.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Never make the user feel that they're responsible for errors&lt;/strong&gt;, because they're not. The designer of the system is (yes, us 😇). So, it's important to use an appropriate language when communicating with the user when an error occurs and improve the design of the system so they make as less of them as possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Help the user &lt;strong&gt;build a good mental model&lt;/strong&gt; of your system's interface.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔮 Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Always &lt;strong&gt;prevent errors&lt;/strong&gt; to occur.&lt;/li&gt;
&lt;li&gt;Avoid &lt;strong&gt;&lt;em&gt;slips&lt;/em&gt;&lt;/strong&gt; by including constraints, good default values and suggestions.&lt;/li&gt;
&lt;li&gt;Support &lt;strong&gt;&lt;em&gt;undo&lt;/em&gt;&lt;/strong&gt; and let the user know they can recover from their errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Warn&lt;/strong&gt; your users when needed. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🤖 Keywords to this principle
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Error&lt;/li&gt;
&lt;li&gt;Mistake&lt;/li&gt;
&lt;li&gt;Undo&lt;/li&gt;
&lt;li&gt;Prevention&lt;/li&gt;
&lt;li&gt;Revoke&lt;/li&gt;
&lt;li&gt;Confirmation&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;And this is all for the first lecture of the UX 101 series! &lt;/p&gt;

&lt;p&gt;Stay tuned to know more about UX in future episodes of the series.&lt;/p&gt;

&lt;p&gt;A big thanks for reading  🤗  and don't hesitate to reach out to me if you have any questions or doubts about today's lecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" alt="Rachel Green from Friends TV Show behind a desk saying "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article useful and I see you all in the next 👋&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content: info, challenges, quizzes &amp;amp; more 💜&lt;/p&gt;




</description>
      <category>uiweekly</category>
      <category>ux</category>
      <category>webdev</category>
      <category>design</category>
    </item>
    <item>
      <title>Styled Components 101 💅 Lecture 3: SSR with Next.js + Custom Icon Fonts 😍</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Sun, 08 Aug 2021 14:09:13 +0000</pubDate>
      <link>https://dev.to/underscorecode/styled-components-101-lecture-3-ssr-with-next-js-custom-icon-fonts-g6o</link>
      <guid>https://dev.to/underscorecode/styled-components-101-lecture-3-ssr-with-next-js-custom-icon-fonts-g6o</guid>
      <description>&lt;p&gt;Hello, everybody! 👋&lt;br&gt;
And welcome to the 3rd lecture of the &lt;strong&gt;Styled Components 101 series&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;In this lecture, we'll be covering:&lt;/p&gt;

&lt;p&gt;1️⃣  How we can use &lt;strong&gt;Styled Components within a Next.js configuration&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;2️⃣  How to use &lt;strong&gt;custom icon fonts&lt;/strong&gt; within our &lt;em&gt;styled&lt;/em&gt; components.&lt;/p&gt;

&lt;p&gt;If you're new to Styled Components and this lecture is the first one you run into, I suggest taking a look at the previous lectures first, where we covered some basic concepts and examples of Styled Components.&lt;/p&gt;

&lt;p&gt;With all this said, let's move on to today's topic 👇&lt;/p&gt;
&lt;h1&gt;
  
  
  How to get Styled Components to work if we're using Next.js 😺
&lt;/h1&gt;

&lt;p&gt;Let's first see what happens if no configuration for Styled Components has been defined for our Next.js project and we try to use the library.&lt;/p&gt;

&lt;p&gt;To start off, we're going to create a &lt;code&gt;StyledButton&lt;/code&gt; component (already known to all at this point 😜) and render it within the main component of our app.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
    background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
    color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
    border: none;
    border-radius: 5px;
    padding: 20px;
    font-size: 1.5rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;index.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&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;../components/StyledButton&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;Home&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="k"&gt;return&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;StyledButton&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#c64dff"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#fff"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Styled Button in Next.js&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&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;If we run our app, this is the resultant button:&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%2Fuploads%2Farticles%2Frklszwnr3kz3ns1w1ew0.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%2Fuploads%2Farticles%2Frklszwnr3kz3ns1w1ew0.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Where in the world are our styles? 🤔 Let's find out what's going on in here.&lt;/p&gt;

&lt;p&gt;First, if we go to the &lt;strong&gt;Console&lt;/strong&gt; Tab in the browser's &lt;em&gt;dev tools&lt;/em&gt;, we see that something is throwing an &lt;strong&gt;error&lt;/strong&gt;:&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%2Fuploads%2Farticles%2F69hc575gg07q80nx3hre.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%2Fuploads%2Farticles%2F69hc575gg07q80nx3hre.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The error reads:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_Warning: Prop `classname` did not match. Server: "sc-pNWdM kcTaxf" Client: "sc-bdnxRM gSuzZs" at button...
```


It seems like two different classes are being assigned on the server and the client, resulting in an __inconsistency__. 

Let's now have a look at the __Elements__ tab:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/59ux7ot96qsk3n4ntn6n.png)

Our button is there and we can confirm that the class provided by Styled Components has been __assigned correctly__, but the __styles are__ completely __missing__.

##So, what can we do to solve this? 😩

Well, this is neither a bug nor even a big deal. It's just that a __further configuration is required by Next.js__ to get to work Styled Components in our project in order to use it.

So, first, we're going to install the `babel-plugin-styled-components`, which is required for __SSR__ (_Server Side Rendering_).



```bash
npm install babel-plugin-styled-components
```




Now, let's create a `.babelrc` file if we haven't already done so (it's not created by default when creating a Next.js app) and write the following configuration for the newly installed plugin on it:

On the terminal:



```bash
touch .babelrc
```



`.babelrc`



```json
{
   "presets": ["next/babel"],
   "plugins": [["styled-components", {"ssr": true, "preprocess": false}]]
}
```



But we're not done yet, we still need a little bit more of configuration.

Now we need to inject the __server side rendered styles__ in the `&amp;lt;head&amp;gt;` element of our HTML file. For this purpose, we need to override the _Document_ file, which is provided by Next.js.

The _Document_ file is extendable, which means that we can add content to it if needed, and it's mainly used to __add custom content__ to the `&amp;lt;html&amp;gt;` and `&amp;lt;body&amp;gt;` elements of the HTML main file. Note that this file is only rendered on the server.

This _document_ is automatically generated with the creation of the Next.js app, but since we need to extend it, we're going to create another file called `_document.js` to __override the original one__. This new file should be placed within the `/pages` directory and it will look like this 👇

`_document.js`



```jsx
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'

export default class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const sheet = new ServerStyleSheet()
    const originalRenderPage = ctx.renderPage

    try {
      ctx.renderPage = () =&amp;gt;
        originalRenderPage({
          enhanceApp: (App) =&amp;gt; (props) =&amp;gt;
            sheet.collectStyles(&amp;lt;App {...props} /&amp;gt;),
        })

      const initialProps = await Document.getInitialProps(ctx)
      return {
        ...initialProps,
        styles: (
          &amp;lt;&amp;gt;
            {initialProps.styles}
            {sheet.getStyleElement()}
          &amp;lt;/&amp;gt;
        ),
      }
    } finally {
      sheet.seal()
    }
  }
}
```



Note that `renderPage` should only be modified when working with _CSS-in-JS_ libraries, like Styled Components, since they need the app to be __wrapped to work on server side__. Otherwise the default configuration should always remain 👍

If we're not planning to use any of these libraries, the following configuration could be a good starting point if we need to add something to the structure of our HTML document, being able to remove all that we don't need to change (note that we're __overriding__), like `getInitialProps` or even the `render` method:



```jsx
import Document, { Html, Head, Main, NextScript } from 'next/document'

class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const initialProps = await Document.getInitialProps(ctx)
    return { ...initialProps }
  }

  render() {
    return (
      &amp;lt;Html&amp;gt;
        &amp;lt;Head /&amp;gt;
        &amp;lt;body&amp;gt;
          &amp;lt;Main /&amp;gt;
          &amp;lt;NextScript /&amp;gt;
        &amp;lt;/body&amp;gt;
      &amp;lt;/Html&amp;gt;
    )
  }
}

export default MyDocument

```


In any other case, there's no need to extend the original _Document_ and we can forget about it 😜.


Once we've made all of these arrangements, let's re-run our application and see what happens!

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz2kvlnuks7kxza9exkj.png)

There we go! Our Styled Button is finally rendering properly 👏

And that would be all the configuration needed to work with __Styled Components + Next.js__.

Let's now dive into how we can add a __custom icon font__ to a _styled_ component 👇

#Custom Icon Fonts in Styled Components ❤️

This topic is totally separate from the previous one, __since an extra configuration for fonts is no longer required in Next.js__, but anyway, let's extend our _styled_ button by adding an icon from a custom icon font and let's see what we need to do to make it work.

##First of all... What is an icon font? 🐔

Unlike regular fonts, which contain letters and numbers, an icon font is nothing more than a __collection of symbols and glyphs__ that works as a typeface. Its use is widely extended because they are really easy to style with CSS.

The tool we're going to use to get our icon font is ___Icomoon___, but this example works for every downloaded fonts coming from any font resource.

Let's say we have already downloaded our font files after generating the custom set and we're all set and ready to go. 

##Integrating a custom icon font set into our project 🐸

What we're going to do in this section is to __add an icon__ from our custom icon font as an `::after` pseudo-element, to place it after the text of our button.

So, first, we're going to add a new _prop_ to our styled button call and pass it the content value of an icon of our choice.

Note that every icon has a sort of _id_, which is the value we'll pass in to the _prop_ named ___icon___. This content value is always provided by the tool, so you don't need to assign it yourself.

In this case, the content value for our icon is `\e900`.



```jsx
&amp;lt;StyledButton bg="#c64dff" color="#fff" icon="\e900"&amp;gt;Styled Button in Next.js&amp;lt;/StyledButton&amp;gt;
```



Then, we'll just add the `::after` pseudo-element to the _StyledButton_ definition:



```js
import styled from "styled-components";

export default styled.button`
    background-color: ${props =&amp;gt; props.bg};
    color: ${props =&amp;gt; props.color};
    border: none;
    border-radius: 5px;
    padding: 20px;
    font-size: 1.2rem;
    &amp;amp;::after{
        font-family: "icomoon";
        content: "${props =&amp;gt; props.icon}";
        padding-left: 8px;
    }   
`
```



##Time to create a global style ⚡️

In the previous lecture, we had a glimpse on __how to create a global style__, as part of the example where we created a light/ dark theme toggler. So don't hesitate to take a look at it for further reference if needed 😀

But in case you missed it or you don't have the time to read one more article, keep reading: everything's explained ahead ✌️

First, we are going to __create our global styles file__, that will be called `IconFont.js`, and which will __host the CSS definition__ to import custom fonts. It's just plain CSS inside a _styled_ component. Nothing new 😎 And it will look like this: 

`IconFont.js`



```jsx
import { createGlobalStyle } from "styled-components";

export default createGlobalStyle`
@font-face {
   font-family: "icomoon";
   src: url("/fonts/icomoon.eot");
   src: url("/fonts/icomoon.eot?#iefix")
   format("embedded-opentype"),
   url("/fonts/icomoon.svg#icomoon") format("svg"),
   url("/fonts/icomoon.woff") format("woff"),
   url("/fonts/icomoon.ttf") format("truetype");
};
`
```


###Things to consider at this point
1. Pay attention to the __routes__ and the __filenames__: the ones you're seeing above work for the configuration that we're going to see in a minute. __You should always use the actual routes of your project and the names you provided to your font files__. Otherwise, it won't work ❌ 
It may sound obvious but sometimes it happens that we make a mistake in writing this definition and we go nuts for the rest of the day trying to figure out what's going on. Believe me, it happens more often that you may think 😝

2. In case you're using a ___theme___, you're supposed to already have a global styles file. In such case, just add the `@font-face` definition to it and you'd be set and done.

Then, __how do I have to structure my project__ to make the previous `@font-face` definition work?

First, and as mentioned before, you need to use the __actual names of your font files__ and define every possible format you have for that font (you will likely have something like _.ttf_, _.otf_, _.svg_, and/or _.woff_, but there are others, too).

And, second, and __key to this configuration__ 👉 You need to create a `fonts` directory inside the `/public` directory. 

This is necessary because __Next.js serves static files under the `/public` folder__, so since fonts are a static resource, they have to be located in there.

&amp;gt;Note that every resource placed in the `/public` directory should be routed using a slash `/` before its name.

###Making our global theme accessible by the app

As a final step to be able to start using our custom icon font, we just need to __import__ the `IconFont` component into our main app component, `_app.js`, like this:

`_app.jsx`



```jsx
import IconFont from '../components/IconFont';
const MyApp = ({ Component, pageProps }) =&amp;gt; {
  return (
    &amp;lt;&amp;gt;
      &amp;lt;IconFont /&amp;gt;
      &amp;lt;Component {...pageProps} /&amp;gt;
    &amp;lt;/&amp;gt;)
}

export default MyApp;
```


If everything goes as expected, this will be the __result__ of our _styled_ button, to which we have appended a __heart icon__:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xppa5n45y6u9iu7upda1.png)

Otherwise, __if something went wrong__ along the way, this is what we'll see:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36gb38hazu5y4casr6bw.png)

Getting a _square_ instead of the actual icon can mean:
- The icon font has been found but the value for the content you have provided __is not part of the list of values of that font__.
- There's a __problem with the location of the fonts__: the specified font files are not located at the route you have provided.
- Something __wasn't configured properly__.

###Older versions of Next.js
As of Next.js 11, __no extra configuration for Webpack is required__ to _translate_ font file formats. If you're using an older version, it's highly recommended that you __update__ your package version by running the following command:



```bash
npm install next@latest
```



In case you need to use an __outdated version__ for whatever reasons, keep in mind that __a little bit of further configuration__ will be required: you'll need to install the `file-loader` Webpack loader, which will handle font formats appropriately and bundle them up to include them in the final bundle that will be served to the browser, and then, you'll have to add the corresponding configuration in `next.config.js`.

___

And this is all for the third Styled Components 101 lecture! 

Stay tuned to know more about Styled Component in future episodes of the series.

A big thanks for reading  🤗  and don't hesitate to reach out to me if you any questions or doubts about today's lecture.

![Rachel Green from Friends TV Show behind a desk saying "Ask me anything"](https://media.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif)

I hope you found this article useful and I see you all in the next 👋

🎉 Don't forget to follow @underscorecode on [Instagram](https://instagram.com/underscorecode) and [Twitter](https://twitter.com/underscorecode) for more daily webdev content 🖥🖤

____

####And last but not least... A quick friendly reminder before we go 😊
We all know there are million ways to get things done when it comes to programming and development, and we're here to __help and learn__, so, if you know another possible way to do what others are sharing (__not better, not worse, just different__), feel free to share it if you feel like it, but, please, __always be kind and respectful__ with the author and the rest of the community. Thank you and happy coding!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>I made 50+ COLOR PALETTES for you to use in your next projects and designs 🎨</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Sat, 31 Jul 2021 17:18:27 +0000</pubDate>
      <link>https://dev.to/underscorecode/i-made-50-color-palettes-for-you-to-use-in-your-next-projects-and-designs-33f7</link>
      <guid>https://dev.to/underscorecode/i-made-50-color-palettes-for-you-to-use-in-your-next-projects-and-designs-33f7</guid>
      <description>&lt;p&gt;Hi, everybody! 👋&lt;/p&gt;

&lt;p&gt;Today, I bring you &lt;strong&gt;50+ color palettes&lt;/strong&gt; to use in your upcoming projects or to just get some inspiration out of them.&lt;/p&gt;

&lt;p&gt;I've given every palette a name to make it easier to identify them (I've tried my best, promise 😅).&lt;/p&gt;

&lt;p&gt;Let me know if you like this kind of content and if you'd like to see more articles like this in the future (about colors, gradients, fonts, design resources, etc). I'd be glad to hear from you in comments! &lt;/p&gt;

&lt;p&gt;And now, let's have a look at those color schemes 👇&lt;/p&gt;

&lt;h1&gt;
  
  
  Package 1
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Sunset in Arizona
&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%2Farticles%2F6mss1kgc88a4co5dm9ar.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Pink Fall Vibes
&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%2Farticles%2F68ktbji1dsmzihj58ezu.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Desert Adventures
&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%2Farticles%2Fl6aa67y4gjdxkfacjdyj.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Chic Garden
&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%2Farticles%2Fypqk17ba1cqj64bxzgqa.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Neon Lights
&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%2Farticles%2Fkil3v8tbh23t7o1sc587.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Pastel Cake
&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%2Farticles%2Fskm8ce3kzrzi6g96wxce.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Acid Tangerine
&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%2Farticles%2Ffvwe7u5bh0houhxy8org.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Frozen Winter
&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%2Farticles%2F2u5fkvkekaihr5ut1z5y.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Vibing Summer
&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%2Farticles%2F9s1hys7wzszugy3podlx.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Drops of Summer
&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%2Farticles%2F2pjw4urrqxwjy9sm64g9.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Package 2
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt; Pink Mandarin
&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%2Farticles%2F2djprisez1l9rc29irgu.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Nomadic Dreams
&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%2Farticles%2F26uooxhg8cmuw151r0i2.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Circus Acrobat
&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%2Farticles%2Fdi4d00yxtnkxgmchd345.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Coffee By The Sea
&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%2Farticles%2F54v9hvq3wtx440wng2hh.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Strawberry Nights
&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%2Farticles%2Fbiutwpnl4j3te1nqcy0w.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Dans La Fôret
&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%2Farticles%2Fte2wgybwbow7s1uk291j.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Easter Vibes
&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%2Farticles%2Fsmkmadp9v1ic999rxroc.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Salty Waters
&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%2Farticles%2Fkwtb32gpcib4dswzihde.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Fresh Berries
&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%2Farticles%2Fgw45h9aw3i0t23hfjzjf.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Skeptical Minds
&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%2Farticles%2Fcjgufokwb8jko0kz1cty.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Package 3
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Dry Landscape
&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%2Farticles%2Fsi03oijh0ni1abcm4yub.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Dark Sunset
&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%2Farticles%2Fv55z8atbid4e10cn7rg3.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Antartic Sun
&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%2Farticles%2Fxvjt11svzxdy44t6tn2a.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Velvet Fall
&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%2Farticles%2Fhv5wehj9bchohug6xgi2.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Water Park
&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%2Farticles%2Fwhbgycbtq19zk7ymui7p.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Origami
&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%2Farticles%2Frvz3jubkdynpp7zwo2z3.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Nights In The City
&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%2Farticles%2Fqo4q59faa2ieog9yr7u7.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Vintage Vineyards
&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%2Farticles%2Fxjne94c9pu7wmoas7aqj.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Fun &amp;amp; Games
&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%2Farticles%2Ffwgy7vakxhyo6dzq8kts.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Aquamarina
&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%2Farticles%2Fwxvbqmxs6kp27vm7k652.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Package 4
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Cold Pastels
&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%2Farticles%2Fmk5ughr0m60rb7wb5bpg.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Sober Twilight
&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%2Farticles%2Fhyklze9q9ywn52118fwj.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Sandy Cocoa
&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%2Farticles%2Ff3d9t1xr6q38ty5deknv.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Tokyo Streets
&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%2Farticles%2F2bkeoy2pconjds7d5awh.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Tireless Traveler 
&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%2Farticles%2F2i9kmab68etkw119jwa8.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Candy Dreams
&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%2Farticles%2Fc4jiy6zn1lza7qka9b6k.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Roses &amp;amp; Wood
&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%2Farticles%2Fr9igsye7tir515k3xh0a.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Downtown LA
&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%2Farticles%2F0c84s9qv9ken61suauxp.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Pumpkin Spice Latte
&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%2Farticles%2Ft5m1nkt8vpttzw1wt3nl.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Honey Hearts
&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%2Farticles%2F2013mpyd71umuh0uwwfh.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Package 5
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Orange Muffin
&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%2Farticles%2F21fvo7sierr55v9lot76.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Self-love
&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%2Farticles%2F6gjbmeeco645f2c7yunh.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Trip to Paris
&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%2Farticles%2Foc2f80enqhe6gtrld89e.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Perfect Getaway
&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%2Farticles%2Fidjbf2pcgu8f418x764k.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Eclipse Solstice
&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%2Farticles%2F7aj6dk0tgom222zcno2b.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Muddy Feelings
&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%2Farticles%2Foltrsrzp9imodojvtwzr.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Watermelon Party
&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%2Farticles%2Fgejnodd9pz8swzlui6fn.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Golden Hour
&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%2Farticles%2Fum91ixfwl1wmzqpjo37u.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Sun, Sand &amp;amp; Tan
&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%2Farticles%2Fnf7gvgbmwet1com7gjgx.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Soft Skies
&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%2Farticles%2F6zo0kpx6mxemj2no6eu2.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  Bonus
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Vibrant Neon
&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%2Farticles%2Fqvim0skks1gpbu0dmbc3.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Sweet Surrender
&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%2Farticles%2Fqghjp3npsfyj1qvcvjo4.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;90s Child
&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%2Farticles%2F2y0quualy5yzwiccwrzw.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Pomegranate Paradise
&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%2Farticles%2Ffidhd5wkgvpkgxkj4kd2.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;li&gt;Brown Eyed Soul
&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%2Farticles%2Fpovee5n8owd7tyfy97s8.png" alt="Alt Text"&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;And this is all for today! &lt;/p&gt;

&lt;p&gt;I hope you liked the article and see you all in the next 👋&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/hFtVHPDcrVubS/source.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/hFtVHPDcrVubS/source.gif" alt="Woman saying bye"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;




</description>
      <category>webdev</category>
      <category>css</category>
      <category>design</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Styled Components 101 💅 Lecture 2: Creating a theme + Light/Dark theme toggler example ☀️🌙</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Sun, 25 Jul 2021 12:49:22 +0000</pubDate>
      <link>https://dev.to/underscorecode/styled-components-101-lecture-2-creating-a-theme-light-dark-theme-toggler-example-13dp</link>
      <guid>https://dev.to/underscorecode/styled-components-101-lecture-2-creating-a-theme-light-dark-theme-toggler-example-13dp</guid>
      <description>&lt;p&gt;Hello, everybody! 👋&lt;br&gt;
And welcome to the 2nd lecture of the &lt;strong&gt;Styled Components 101 series&lt;/strong&gt; 🙌&lt;/p&gt;

&lt;p&gt;In this lecture, we'll be covering the &lt;strong&gt;creation of a custom theme&lt;/strong&gt; with Styled Components.&lt;/p&gt;

&lt;p&gt;If you're new to Styled Components and this lecture is the first one you run into, I suggest taking a look at the previous lecture first, where we covered some basic concepts and examples of Styled Components.&lt;/p&gt;

&lt;p&gt;With all this said, let's move on to today's topic 👇&lt;/p&gt;
&lt;h1&gt;
  
  
  Creating the theme file 🔮
&lt;/h1&gt;

&lt;p&gt;First things first. Before start generating components and other component-related stuff, what we need to do is &lt;strong&gt;create the file&lt;/strong&gt; that will host our &lt;strong&gt;app's theme&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This theme file will be just a regular JavaScript file with &lt;em&gt;js&lt;/em&gt; extension that will contain an object called &lt;em&gt;theme&lt;/em&gt; with properties and values that we'll be using to style our components.&lt;/p&gt;

&lt;p&gt;As easy as that 💁‍♂️&lt;/p&gt;

&lt;p&gt;Let's have a look at how this file looks like:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;theme.js&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;plum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#52314b&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;rose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#c3537d&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;dryrose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#dd7f9a&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;primrose&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#e8babf&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;white&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#fff&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For now, we'll be working only with colors, but every property/value you can imagine that is used for styling will also be set in this file: values regarding fonts, padding, margin, etc. In short, every value that you'd set up in a CSS file.&lt;/p&gt;

&lt;p&gt;Don't forget to export your theme object. Otherwise, there's no way for it to be found by the app 👍&lt;/p&gt;

&lt;p&gt;And that's all for the theme file. We're now set to head on to the next step 😼&lt;/p&gt;
&lt;h1&gt;
  
  
  Making the theme file reachable by the app 🕵️
&lt;/h1&gt;

&lt;p&gt;In order for the theme file to be able to be accessed, we need to provide it to the app. To do this, we'll import the component &lt;em&gt;ThemeProvider&lt;/em&gt; from &lt;em&gt;styled-components&lt;/em&gt; and will wrap our app with it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;theme&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;./theme&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;App&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="k"&gt;return&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;
         //your code here  
      &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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now, our theme is recognized by the app and can be accessed and used from anywhere throughout it.&lt;/p&gt;
&lt;h1&gt;
  
  
  Using the theme inside a &lt;em&gt;styled&lt;/em&gt; component 💅
&lt;/h1&gt;

&lt;p&gt;Retrieving theme values from within a &lt;em&gt;styled&lt;/em&gt; component is a really easy process, since the theme is &lt;strong&gt;implicit&lt;/strong&gt; to the component props. &lt;/p&gt;

&lt;p&gt;Let's see how to style a &lt;em&gt;styled&lt;/em&gt; component making use of a couple values from our custom theme:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;BasicThemedButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;primrose&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;white&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   font-size: 1.25rem;
   border: none;
   border-radius: 5px;
   padding: 10px;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Our custom theme is implicitly passed-in as a prop and it's easily accessed because the component is also wrapped by the provider:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;theme&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;./theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BasicThemedButton&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;./components/BasicThemedButton&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;App&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="k"&gt;return&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;BasicThemedButton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a basic themed button! 🤗&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;BasicThemedButton&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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fuploads%2Farticles%2F1ptnhmydwx9fp1qsyqr5.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%2Fuploads%2Farticles%2F1ptnhmydwx9fp1qsyqr5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Using the theme inside a custom React component ⚛️
&lt;/h1&gt;

&lt;p&gt;To use our theme inside a custom React component, we need to write a little bit more code, but not a big deal at all.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ThemedButton.js&lt;/code&gt; ≡ React 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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useContext&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&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;./StyledButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeContext&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;styled-components&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;ThemedButton&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="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ThemeContext&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt; &lt;span class="na"&gt;bgColor&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="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;plum&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;color&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="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;white&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a themed button 😜&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;ThemedButton&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;StyledButton.js&lt;/code&gt; ≡ Styled component&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;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bgColor&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   padding: 10px;
   border: none;
   border-radius: 5px;
   font-size: 1.25rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This time, the values from the theme are passed to the &lt;em&gt;styled&lt;/em&gt; component &lt;strong&gt;via props&lt;/strong&gt;, which have been previously retrieved in the React component by making use of the &lt;strong&gt;&lt;em&gt;useContext&lt;/em&gt;&lt;/strong&gt; hook and the &lt;strong&gt;&lt;em&gt;ThemeContext&lt;/em&gt;&lt;/strong&gt; component from &lt;em&gt;styled-components&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Note that we'll be calling our React component as we regularly do:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;theme&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;./theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ThemedButton&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;./components/ThemedButton&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;App&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="k"&gt;return&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;ThemedButton&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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fuploads%2Farticles%2F2blqu53pmdr6gzzslo2o.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%2Fuploads%2Farticles%2F2blqu53pmdr6gzzslo2o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  The &lt;em&gt;theme&lt;/em&gt; prop 🤖
&lt;/h1&gt;

&lt;p&gt;The &lt;em&gt;theme&lt;/em&gt; prop is used to pass in an inline object that contains the specification for the theme to a styled component. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&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;./components/StyledButton&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;theme&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;./theme&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;App&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="k"&gt;return&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;StyledButton&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="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;primrose&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;white&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a button with a theme prop! 😎&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;StyledButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   padding: 10px;
   border: none;
   border-radius: 5px;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fuploads%2Farticles%2Fmmtme1uroaum58rgmdj9.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%2Fuploads%2Farticles%2Fmmtme1uroaum58rgmdj9.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method can be useful if we don't have many properties, but, when we have a robust application with several properties and values for styling, this method becomes difficult to maintain and tricky to deal with ❌&lt;/p&gt;
&lt;h1&gt;
  
  
  Using JavaScript objects to write our styles rather than CSS 🤹‍♀️
&lt;/h1&gt;

&lt;p&gt;Did you know that is also possible to write custom styles using &lt;strong&gt;JS instead of CSS&lt;/strong&gt; in Styled Components? And it's easier than you may think.&lt;/p&gt;

&lt;p&gt;Let's have a look at the following snippet:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;JSStyledButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
   &lt;span class="na"&gt;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bgColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;fontSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1.5rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;theme&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;./theme&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;JSStyledButton&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;./components/JSStyledButton&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;App&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="k"&gt;return&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;JSStyledButton&lt;/span&gt; &lt;span class="na"&gt;bgColor&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="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;plum&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;color&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="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;white&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a JS Styled Button 🤠&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;JSStyledButton&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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fuploads%2Farticles%2Fxa3cp7u3luuyoue7x2m3.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%2Fuploads%2Farticles%2Fxa3cp7u3luuyoue7x2m3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that property names are written in &lt;strong&gt;camelcase&lt;/strong&gt; notation, as we're using a JavaScript object, but it's also accepted to write them within &lt;strong&gt;double quotes&lt;/strong&gt;, 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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;button&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;background-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;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bgColor&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;font-size&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;1.5rem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;
&lt;span class="p"&gt;}));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Also note that the used method to specify the styles is similar to the one we use when &lt;strong&gt;extending styles from a supercomponent&lt;/strong&gt; (&lt;em&gt;Lecture 1 - Inheriting styles from another component&lt;/em&gt; section):&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;button&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;h1&gt;
  
  
  And now... 👑 The jewel in the crown: Let's create a Light/Dark theme toggler with Styled Components
&lt;/h1&gt;

&lt;p&gt;Theory is cool but, but let's get our hands dirty and let's create something interesting using themes 👏&lt;/p&gt;
&lt;h3&gt;
  
  
  Excuse me, but... what exactly is a &lt;em&gt;theme toggler&lt;/em&gt;? 🤔
&lt;/h3&gt;

&lt;p&gt;We can say that a theme toggler is a &lt;em&gt;system&lt;/em&gt; that allows to &lt;strong&gt;switch between a light and a dark theme&lt;/strong&gt; with just one click by using a button or an emoji. Cool, right?&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll implement a styled button that will perform this task really fast and efficiently.&lt;/p&gt;

&lt;p&gt;And now, let's get it started 👉&lt;/p&gt;
&lt;h2&gt;
  
  
  The components and files 🎬
&lt;/h2&gt;

&lt;p&gt;These are the components and files that will make up our app:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Button.js&lt;/code&gt;: the button that will switch between themes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;GlobalStyles.js&lt;/code&gt;: a component that will inject global styles into the app.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ThemeToggler.js&lt;/code&gt;: the component that will receive the theme as a prop, which, in turn, will be passed in to the &lt;em&gt;Button&lt;/em&gt; component.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useDarkTheme.js&lt;/code&gt;: a custom hook that will contain the business logic. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;: the main app. It will wrap everything up with the theme provider and will include the global styles.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;themes.js&lt;/code&gt;: the file that will host our themes (we already know how to do this at this point 😺).&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's first create our &lt;em&gt;themes&lt;/em&gt; file 📝
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;themes.js&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lightTheme&lt;/span&gt; &lt;span class="o"&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="s1"&gt;#fff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#1d1f28&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;buttonBg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#c5718d&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;darkTheme&lt;/span&gt; &lt;span class="o"&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="s1"&gt;#1d1f28&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#fafafa&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;buttonBg&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#515d90&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;Not a lot to remark here: we have defined both themes with their respective style properties. Don't forget to export them both 👍&lt;/p&gt;
&lt;h2&gt;
  
  
  Now let's go with the &lt;em&gt;switch&lt;/em&gt; button 🔵
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Button.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   font-family: "Monaco", monospace;
   cursor: pointer;
   border: none;
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${({&lt;/span&gt; &lt;span class="nx"&gt;theme&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;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonBg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   color: #fff;
   padding: 10px;
   border-radius: 5px;
   font-size: 1.5rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A regular &lt;em&gt;styled&lt;/em&gt; button. You can style it as you like best.&lt;/p&gt;

&lt;p&gt;Note that the value for &lt;code&gt;background-color&lt;/code&gt; will be set depending on the selected theme. The rest is up to you 😇&lt;/p&gt;
&lt;h2&gt;
  
  
  Time for global styles 😼
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;GlobalStyles.js&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;createGlobalStyle&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;styled-components&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;GlobalStyles&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 {
     font-family: "Monaco", monospace;
     background: &lt;/span&gt;&lt;span class="p"&gt;${({&lt;/span&gt; &lt;span class="nx"&gt;theme&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;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;background&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
     color: &lt;/span&gt;&lt;span class="p"&gt;${({&lt;/span&gt; &lt;span class="nx"&gt;theme&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;theme&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
     transition: all 0.50s linear; 
  }
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;&lt;em&gt;GlobalStyles&lt;/em&gt;&lt;/strong&gt; defines the global styles for our app. They will be injected into our app by in &lt;code&gt;App.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Note that for this purpose, we'll import the &lt;strong&gt;&lt;em&gt;createGlobalStyle&lt;/em&gt;&lt;/strong&gt; helper from &lt;em&gt;styled-components&lt;/em&gt;, which will create a new &lt;em&gt;styled&lt;/em&gt; component that will handle global styles.&lt;/p&gt;

&lt;p&gt;Regarding the properties, background and text colors will be retrieved from the theme. We'll also add a &lt;em&gt;transition&lt;/em&gt; property to make the switch effect smoother.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating the theme toggler 💁
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ThemeToggler.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&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;./Button&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;ThemeToggler&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;themeToggler&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;themeToggler&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Switch Theme ☀️ 🌙&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;ThemeToggler&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;&lt;em&gt;ThemeToggler&lt;/em&gt;&lt;/strong&gt; renders the Button component and provides it with the style properties that correspond to the passed-in theme.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;useDarkTheme.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&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="s1"&gt;react&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;THEMES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;LIGHT&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;DARK&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dark&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;useDarkTheme&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;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setTheme&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;THEMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LIGHT&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;themeToggler&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="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;THEMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LIGHT&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;setTheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;THEMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DARK&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;setTheme&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;THEMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;LIGHT&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="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;themeToggler&lt;/span&gt;&lt;span class="p"&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="nx"&gt;useDarkTheme&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;&lt;em&gt;useDarkTheme&lt;/em&gt;&lt;/strong&gt; is a custom hook that contains the logic for our toggler. We're using a hook to abstract our app as much as possible.&lt;/p&gt;

&lt;p&gt;The switching procedure is as easy as follows: if the passed-in theme is &lt;em&gt;light&lt;/em&gt;, the &lt;em&gt;dark&lt;/em&gt; theme will be set up, and vice versa.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building the main &lt;em&gt;app&lt;/em&gt; 😈
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;App.js&lt;/code&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ThemeProvider&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;GlobalStyles&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;./components/GlobalStyles&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;lightTheme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;darkTheme&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;./themes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ThemeToggler&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;./components/ThemeToggler&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;useDarkTheme&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;./hooks/useDarkTheme&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;App&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;theme&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;themeToggler&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; 
   &lt;span class="nf"&gt;useDarkTheme&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;selectedTheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;lightTheme&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;darkTheme&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;&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;selectedTheme&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;&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;GlobalStyles&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;ThemeToggler&lt;/span&gt; &lt;span class="na"&gt;themeToggler&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;themeToggler&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="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Trying out light and dark themes! 😍&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
         &lt;span class="p"&gt;&amp;lt;/&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="p"&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="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;First, we're calling the &lt;em&gt;useDarkTheme&lt;/em&gt; hook, that will handle the &lt;em&gt;switch&lt;/em&gt; logic.&lt;/p&gt;

&lt;p&gt;Then, we also need to have a function &lt;em&gt;selectedTheme&lt;/em&gt;, that decides which theme is going to be used.&lt;/p&gt;

&lt;p&gt;And now, what's only left is to wrap up &lt;strong&gt;&lt;em&gt;ThemeToggler&lt;/em&gt;&lt;/strong&gt; with &lt;strong&gt;&lt;em&gt;ThemeProvider&lt;/em&gt;&lt;/strong&gt; and include &lt;strong&gt;&lt;em&gt;GlobalStyles&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  The result ☀️ ➡️ 🌙
&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%2Fuploads%2Farticles%2Fh5zwv6yfcb4c5q9pgbqh.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%2Fuploads%2Farticles%2Fh5zwv6yfcb4c5q9pgbqh.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;And this is all for the second Styled Components 101 lecture! &lt;/p&gt;

&lt;p&gt;Stay tuned to know more about Styled Component in future episodes of the series.&lt;/p&gt;

&lt;p&gt;A big thanks for reading  🤗  and don't hesitate to reach out to me if you any questions or doubts about today's lecture.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/XFuQ4InwtXBE4DDPHM/giphy.gif" alt="Rachel Green from Friends TV Show behind a desk saying "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article useful and I see you all in the next 👋&lt;/p&gt;



&lt;p&gt;👉 You can also check out the &lt;strong&gt;related slides&lt;/strong&gt; for this article on Instagram 👈&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CRv7A4HDUEV/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;






&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;




&lt;h4&gt;
  
  
  And last but not least... A quick friendly reminder before we go 😊
&lt;/h4&gt;

&lt;p&gt;We all know there are million ways to get things done when it comes to programming and development, and we're here to &lt;strong&gt;help and learn&lt;/strong&gt;, so, if you know another possible way to do what others are sharing (&lt;strong&gt;not better, not worse, just different&lt;/strong&gt;), feel free to share it if you feel like it, but, please, &lt;strong&gt;always be kind and respectful&lt;/strong&gt; with the author and the rest of the community. Thank you and happy coding! &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Styled Components 101 💅 Lecture 1: Introduction + Setup in a React Environment ⚛️</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Wed, 14 Jul 2021 13:36:15 +0000</pubDate>
      <link>https://dev.to/underscorecode/styled-components-101-lecture-1-introduction-setup-in-a-react-environment-476c</link>
      <guid>https://dev.to/underscorecode/styled-components-101-lecture-1-introduction-setup-in-a-react-environment-476c</guid>
      <description>&lt;p&gt;Hello, everybody! 👋&lt;br&gt;
And welcome to the first lecture of the &lt;strong&gt;Styled Components 101 series&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In this series, we will be thoroughly covering different topics related with Styled Components.&lt;/p&gt;

&lt;p&gt;Still don't know what Styled Components are? It seems like you're in luck because we start with the first lesson right now! 👇&lt;/p&gt;
&lt;h1&gt;
  
  
  What are Styled Components? 💅
&lt;/h1&gt;

&lt;p&gt;Styled Components is a &lt;strong&gt;modern tool used to generate components&lt;/strong&gt; out of the most basic HTML elements, which also allows you to &lt;strong&gt;write your custom CSS styles&lt;/strong&gt; for them in JavaScript by making use of the &lt;em&gt;tagged template literals&lt;/em&gt; feature.&lt;/p&gt;

&lt;p&gt;Styled Components &lt;strong&gt;gets rid of the mapping between components and styles&lt;/strong&gt;, so, when declaring your CSS, what you're actually doing is creating a regular React component that has its own styles attached.&lt;/p&gt;
&lt;h1&gt;
  
  
  Installation 🖥
&lt;/h1&gt;

&lt;p&gt;If you use &lt;strong&gt;&lt;em&gt;npm&lt;/em&gt;&lt;/strong&gt;:&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;styled-components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you use &lt;strong&gt;&lt;em&gt;yarn&lt;/em&gt;&lt;/strong&gt;:&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 styled-components
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Getting Styled Components ready to work with React ⚛️
&lt;/h1&gt;

&lt;p&gt;This is the best part: &lt;strong&gt;no extra configuration is needed to start using Styled Components with React&lt;/strong&gt;. In next lectures, we'll see how to configure Styled Components to get it to work with frameworks like Next.js and how to integrate them with SSR (&lt;em&gt;Server Side Rendering&lt;/em&gt;). But, for now, everything's ready on React side. Keep tuned to this series of Styled Components if you want to learn further 😺&lt;/p&gt;

&lt;h1&gt;
  
  
  Creating our first &lt;em&gt;styled&lt;/em&gt; component 🐣
&lt;/h1&gt;

&lt;p&gt;There are a couple ways to define a &lt;em&gt;styled&lt;/em&gt; component. Personally, my favorite is to &lt;strong&gt;keep the component independent&lt;/strong&gt;, defined in its own file, as we regularly do with React components. But, although conceptually speaking, this is the best way of &lt;strong&gt;keeping an app properly modularized and making a good use of abstraction&lt;/strong&gt;, the approach of declaring a styled component within another component is widely extended as well. Not my favorite, but also valid. &lt;/p&gt;

&lt;p&gt;Our first &lt;em&gt;styled&lt;/em&gt; component will be a &lt;strong&gt;Button&lt;/strong&gt;. Let's see how we can define it using the Styled Components syntax:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: #7b4cd8;
   color: #fff;
   padding: 10px;
   border: none;
   border-radius: 5px;
   font-size: 1.25rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see in the example above, we're using plain CSS syntax inside of &lt;em&gt;backticks&lt;/em&gt; to make our styles understandable to JavaScript.&lt;/p&gt;

&lt;p&gt;And then, we just have to import our component wherever we want it to be rendered:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&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;./components/StyledButton&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a styled button! 😼&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our first &lt;em&gt;styled&lt;/em&gt; button will look 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%2Fuploads%2Farticles%2Fniao7kcx4r2e25f1vruo.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%2Fuploads%2Farticles%2Fniao7kcx4r2e25f1vruo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Styling our component through &lt;em&gt;props&lt;/em&gt; 💁‍♂️
&lt;/h1&gt;

&lt;p&gt;In the previous example, all the styles have been predefined by us and every rendered &lt;code&gt;StyledButton&lt;/code&gt; will have the exact same appearance. &lt;/p&gt;

&lt;p&gt;But, &lt;strong&gt;can we render the same type of component multiple times to create different components and apply different styles to them?&lt;/strong&gt; The answer is yes and what we're going to do to get this behavior is &lt;strong&gt;passing props&lt;/strong&gt; with custom values to our &lt;em&gt;styled&lt;/em&gt; button.&lt;/p&gt;

&lt;p&gt;Let's say we want to have three buttons with different background and text colors, but with the same padding, border radius and font size.&lt;/p&gt;

&lt;p&gt;Then, we're going to do something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledButtonWithProps.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   padding: 10px;
   border: none;
   border-radius: 5px;
   font-size: 1.25rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's now call our three buttons:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButtonWithProps&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;./components/StyledButtonWithProps&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledButtonWithProps&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#ffc3c3"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#b6201e"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Button 🍓&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButtonWithProps&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;StyledButtonWithProps&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#ffdaca"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#d85d16"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Button 🍑&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButtonWithProps&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;StyledButtonWithProps&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#fff4c7"&lt;/span&gt; &lt;span class="na"&gt;color&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"#bb9922"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Button 🍋&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButtonWithProps&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is the result:&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%2Fuploads%2Farticles%2Fxj7jv428wwt4s4m2aj0l.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%2Fuploads%2Farticles%2Fxj7jv428wwt4s4m2aj0l.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Styling our component conditionally 💁
&lt;/h1&gt;

&lt;p&gt;Let's now have a look at how we can style our button component by adding some conditions.&lt;/p&gt;

&lt;p&gt;This time, let's say we want to have a different background color for our button depending on its type value, which will be passed in to the component through the &lt;em&gt;prop&lt;/em&gt; &lt;strong&gt;&lt;em&gt;buttonType&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Then we should do the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonType&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonType&lt;/span&gt;&lt;span class="o"&gt;===&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt;
   &lt;span class="s2"&gt;`background-color: #7b4cd8; color: #fff; font-size: 1.25rem;`&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;`background-color: #ff31ca; color: #ffe6f9; font-size: 0.95rem;`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
   padding: 10px;
   border: none;
   border-radius: 5px;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the prop &lt;em&gt;buttonType&lt;/em&gt; exists and has a value of &lt;em&gt;primary&lt;/em&gt;, then the component will get the first set of style properties. Otherwise, the second.&lt;/p&gt;

&lt;p&gt;Note that the style properties defined outside the condition block, &lt;strong&gt;remain the same for all components&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's now call our buttons:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledButton&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;./components/StyledButton&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt; &lt;span class="na"&gt;buttonType&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a Primary Button! 👆&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&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;StyledButton&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I am a different kind of button! 👇&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledButton&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And there we are:&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%2Fuploads%2Farticles%2Fnl38wif2w5qtw4ztnpfs.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%2Fuploads%2Farticles%2Fnl38wif2w5qtw4ztnpfs.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Inheriting styles from another component 👨‍👧‍👦
&lt;/h1&gt;

&lt;p&gt;Even though the aforementioned method of passing style properties by using component props works well in every scenario, if our app starts to grow, we can find the process of creating components tedious and repetitive.&lt;/p&gt;

&lt;p&gt;And now's when &lt;strong&gt;&lt;em&gt;constructors&lt;/em&gt;&lt;/strong&gt; come to rescue: we can have a &lt;em&gt;supercomponent&lt;/em&gt;  (like a &lt;em&gt;superclass&lt;/em&gt;, making reference to inheritance in OOP 🤓), whose styles can be inherited by other components.&lt;/p&gt;

&lt;p&gt;This means that every &lt;em&gt;children&lt;/em&gt; component that inherits from the &lt;em&gt;supercomponent&lt;/em&gt; will have the supercomponent styles in addition to its own custom styles. &lt;/p&gt;

&lt;p&gt;Let's see how we can &lt;em&gt;connect&lt;/em&gt; them:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SuperButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="s2"&gt;`
   color: #fff;
   width: 200px;
   height: 50px;
   border: none;
   border-radius: 5px;
   font-size: 1.25rem;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ChildrenButton.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;SuperButton&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;./SuperButton&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="nf"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;SuperButton&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;`
   background-color: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;;
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's now call them all:&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ChildrenButton&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;./components/ChildrenButton&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ChildrenButton&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"deeppink"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello! 👋 &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ChildrenButton&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;ChildrenButton&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"hotpink"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello! 👋 &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ChildrenButton&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;ChildrenButton&lt;/span&gt; &lt;span class="na"&gt;bg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"coral"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello! 👋 &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ChildrenButton&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is the result:&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%2Fuploads%2Farticles%2Fo74t82cubwt62d71qmr3.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%2Fuploads%2Farticles%2Fo74t82cubwt62d71qmr3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Can I use CSS preprocessors like SASS or LESS to write my styles instead of plain CSS?
&lt;/h1&gt;

&lt;p&gt;Not really. But you can still make use of their most common features. &lt;/p&gt;

&lt;p&gt;Styled Components is based on the paradigm &lt;strong&gt;&lt;em&gt;CSS-in-JS&lt;/em&gt;&lt;/strong&gt;, so, technically, we need to use plain CSS to define them. However, we can kinda &lt;em&gt;emulate&lt;/em&gt; the behavior of a preprocessor: Styled Components allows us to define variables and nest selectors, for example.&lt;/p&gt;

&lt;p&gt;The following snippet would be far correct in Styled Components:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledDiv.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="s2"&gt;`
   p{
      font-family: 'Arial', sans-serif;
      font-size: 1.5rem;
      color: deeppink;
      &amp;amp;.primary{
         font-weight: bold;
      }
   }
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And by calling it like this...&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledDiv&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;./components/StyledDiv&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledDiv&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="nt"&gt;p&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"primary"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;Hello from a Styled Div!&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&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;StyledDiv&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...this is what we get: &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%2Fuploads%2Farticles%2Fdsbcvd06qpg9ff9ex0kf.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%2Fuploads%2Farticles%2Fdsbcvd06qpg9ff9ex0kf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This behavior is doable because Styled Components uses a preprocessor, called &lt;strong&gt;&lt;em&gt;stylis&lt;/em&gt;&lt;/strong&gt;, under the hood, so it supports &lt;strong&gt;scss-like syntax&lt;/strong&gt;, which is really cool for nesting and using pseudo-elements and pseudo-classes out of the box.&lt;/p&gt;

&lt;h1&gt;
  
  
  So, that means I can also add a nested pseudo-element to my &lt;em&gt;styled&lt;/em&gt; component, right? 🤔
&lt;/h1&gt;

&lt;p&gt;Absolutely yes.&lt;/p&gt;

&lt;p&gt;This time, we're going to define a &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element to append some content to it. Let's take a step further and let's add that content based on a condition.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;StyledP.js&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;styled&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;styled-components&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="nx"&gt;styled&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="s2"&gt;`
   {$props =&amp;gt; props.before ? `&lt;/span&gt;
   &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="nx"&gt;b4cd8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nx"&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;${props.before}&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="s2"&gt;` : 
   `&lt;/span&gt;&lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="nx"&gt;ff31ca&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="s2"&gt;`
   }
`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;StyledP&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;./components/StyledP&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;MyApp&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StyledP&lt;/span&gt; &lt;span class="na"&gt;before&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"_"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;CODE&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledP&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;StyledP&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;I don't have a ::before 😢&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StyledP&lt;/span&gt;&lt;span class="p"&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="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="nx"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Et &lt;em&gt;voilà&lt;/em&gt;:&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%2Fuploads%2Farticles%2Fdpnbau749jnumwwmmksm.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%2Fuploads%2Farticles%2Fdpnbau749jnumwwmmksm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If a &lt;em&gt;prop&lt;/em&gt; called &lt;em&gt;before&lt;/em&gt; is found, its value will be appended in front of the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element and the component will receive the specified text color. Otherwise, since the condition would never be satisfied, the only style property the component would get would be the color.&lt;/p&gt;




&lt;p&gt;And this is all for this first Styled Components 101 lecture! &lt;/p&gt;

&lt;p&gt;In next episodes, we'll keep delving into all the amazing features of Styled Components and how we can integrate them into our projects.&lt;/p&gt;

&lt;p&gt;I hope you found this article useful and I see you all in the next 👋&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;




&lt;h4&gt;
  
  
  And last but not least... A quick friendly reminder before we go 😊
&lt;/h4&gt;

&lt;p&gt;We all know there are million ways to get things done when it comes to programming and development, and we're here to &lt;strong&gt;help and learn&lt;/strong&gt;, so, if you know another possible way to do what others are sharing (&lt;strong&gt;not better, not worse, just different&lt;/strong&gt;), feel free to share it if you feel like it, but, please, &lt;strong&gt;always be kind and respectful&lt;/strong&gt; with the author and the rest of the community. Thank you and happy coding!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>css</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>JavaScript Bundlers: An in-depth comparative 👍👎 Is Webpack still the best bundler in 2021? 📦</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Fri, 09 Jul 2021 15:15:54 +0000</pubDate>
      <link>https://dev.to/underscorecode/javascript-bundlers-an-in-depth-comparative-is-webpack-still-the-best-bundler-in-2021-59jk</link>
      <guid>https://dev.to/underscorecode/javascript-bundlers-an-in-depth-comparative-is-webpack-still-the-best-bundler-in-2021-59jk</guid>
      <description>&lt;p&gt;Hello, everybody! 🚀&lt;/p&gt;

&lt;p&gt;For the last few days, I've been doing some research on the currently available &lt;strong&gt;JavaScript bundlers&lt;/strong&gt; to try to draw my own conclusions about them and figure out which one would be more appropriate for my projects. And, of course, to find out if it's all about popularity and we developers are overrating some of them and underrating the others 😇&lt;/p&gt;

&lt;p&gt;Since the only bundler I've been working with for the last few years is &lt;strong&gt;Webpack&lt;/strong&gt;, I decided to take a look at &lt;strong&gt;npm trends&lt;/strong&gt; to find out &lt;strong&gt;which the most popular JS bundlers are in 2021&lt;/strong&gt; and give them a try.&lt;/p&gt;

&lt;p&gt;And this is what I got: &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%2Fuploads%2Farticles%2F9ispe7ysyot47gsnid67.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%2Fuploads%2Farticles%2F9ispe7ysyot47gsnid67.png" alt="Comparative chart from npm-trends showing the top 5 JS bundlers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So today, we'll be making a comparison between the &lt;strong&gt;5 most popular bundlers&lt;/strong&gt; according to &lt;strong&gt;&lt;em&gt;npm trends&lt;/em&gt;&lt;/strong&gt;: Webpack, Rollup, Browserify, ESbuild and Parcel.&lt;/p&gt;

&lt;p&gt;In this comparative, we will create a &lt;strong&gt;really basic scenario&lt;/strong&gt; for each of them with a couple of the most used resources/tools these days, and we'll be talking about their &lt;strong&gt;pros and cons&lt;/strong&gt; and comparing them all based on &lt;strong&gt;a few parameters&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  First things first. What is a &lt;strong&gt;&lt;em&gt;bundler&lt;/em&gt;&lt;/strong&gt;? 🤔
&lt;/h1&gt;

&lt;p&gt;A &lt;strong&gt;bundler&lt;/strong&gt; is a tool that &lt;strong&gt;puts together all your JavaScript code and its dependencies&lt;/strong&gt; and throws a &lt;strong&gt;new JavaScript output file&lt;/strong&gt; with everything merged, ready for the web, commonly known as &lt;em&gt;the bundle file&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;These &lt;em&gt;bundlers&lt;/em&gt; can work with &lt;strong&gt;other types of files&lt;/strong&gt; as well apart from JavaScript, but &lt;strong&gt;&lt;em&gt;they need a little help&lt;/em&gt;&lt;/strong&gt; to perform their &lt;em&gt;bundles&lt;/em&gt;. We'll talk about this more in depth in each of the examples below.&lt;/p&gt;

&lt;p&gt;None of them require a &lt;em&gt;config&lt;/em&gt; file, what perfectly works for the most basic bundle. This means you have a &lt;em&gt;.js&lt;/em&gt; file converted into another &lt;em&gt;.js&lt;/em&gt; file with minimal setup. But, once you start having &lt;strong&gt;more and more kinds of files that need to be transpiled&lt;/strong&gt; and, consequently, configured, it's time to add a &lt;strong&gt;&lt;em&gt;config&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;file&lt;/strong&gt; because, otherwise, you'll find yourself immersed in &lt;strong&gt;chaos&lt;/strong&gt; 😰&lt;/p&gt;

&lt;h1&gt;
  
  
  The scenario 🖥
&lt;/h1&gt;

&lt;p&gt;To try out these bundlers, &lt;strong&gt;we don't need a specific complex structure&lt;/strong&gt; for our project, so let's propose a really basic scenario: &lt;strong&gt;an HTML file&lt;/strong&gt;, with &lt;strong&gt;some styles&lt;/strong&gt; (we'll slightly complicate it by using a &lt;strong&gt;preprocessor&lt;/strong&gt; like SASS) and &lt;strong&gt;ready to use ES6&lt;/strong&gt;, which means we will include &lt;em&gt;Babel&lt;/em&gt; even though we're not using React, Vue or any library/framework that rely on it in this comparative. But let's get it setup anyway.&lt;/p&gt;

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

/dist
   bundle.js
   [styles.css]
/src
   index.js
/styles
   styles.scss
index.html
package.json
[*.config.js]


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

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;/dist&lt;/strong&gt; will be &lt;strong&gt;the folder created after the bundle process&lt;/strong&gt; and will &lt;strong&gt;contain all the bundled files&lt;/strong&gt;. The bundled file for the styles is &lt;strong&gt;optional&lt;/strong&gt; because we can choose either to inject the styles directly in the HTML or generate a new &lt;em&gt;transpiled&lt;/em&gt; file containing the styles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/src&lt;/strong&gt; is the folder containing the &lt;strong&gt;entry point&lt;/strong&gt; from which the bundler will &lt;strong&gt;start the bundle process&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;/styles&lt;/strong&gt; is the folder containing the &lt;strong&gt;original styles file&lt;/strong&gt;, before the bundle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;index.html&lt;/strong&gt; is the file containing what we'll see in the &lt;strong&gt;browser&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;package.json&lt;/strong&gt; is the file where all the &lt;strong&gt;dependencies&lt;/strong&gt;, &lt;strong&gt;scripts&lt;/strong&gt; and &lt;strong&gt;some configurations&lt;/strong&gt; are stored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;*.config.js&lt;/strong&gt; is the file where all the &lt;strong&gt;config for the bundler&lt;/strong&gt; is defined. This file is &lt;strong&gt;optional&lt;/strong&gt; for every bundler in this list, &lt;strong&gt;but highly recommended&lt;/strong&gt;. * will be replaced accordingly by the name of the bundler.&lt;/p&gt;




&lt;p&gt;Having said all this, let's see what each of these 5 bundlers can offer us.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Webpack
&lt;/h1&gt;

&lt;p&gt;Loved by many, hated by some, known to all. And still &lt;strong&gt;the most popular bundler in 2021&lt;/strong&gt;. With &lt;strong&gt;more than 15 million weekly downloads&lt;/strong&gt; (at the time of writing this post), there's no doubt that &lt;strong&gt;Webpack is still the bundler&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;par excellence&lt;/em&gt;&lt;/strong&gt; in 2021. But, is it the easiest to use, configure and understand how it works?&lt;/p&gt;

&lt;p&gt;Let's have a look at how we should configure it to have it ready to work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach used by Webpack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;build&lt;/em&gt; script&lt;/li&gt;
&lt;li&gt;A &lt;em&gt;config&lt;/em&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Loaders&lt;/em&gt; used to &lt;em&gt;transform&lt;/em&gt; files&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Plugins&lt;/em&gt; for more complex stuff&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; webpack --mode development"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Really really easy. There's no need to do anything else for a basic configuration. Actually, if you don't want to use a different name for your configuration file, you don't even need to specify a configuration in the build script. If you want to use a different one, you should add &lt;em&gt;--config your_config_file.js&lt;/em&gt; to the command.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that we'll be adding the command &lt;em&gt;rm -rf dist&lt;/em&gt; to every build of every bundler. What this does is removing the &lt;em&gt;dist&lt;/em&gt; folder every time a new &lt;em&gt;build&lt;/em&gt; script is executed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;code&gt;webpack.config.js&lt;/code&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dist&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;module&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;rules&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="na"&gt;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.(&lt;/span&gt;&lt;span class="sr"&gt;js|jsx&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/node-modules/&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;babel-loader&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;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.&lt;/span&gt;&lt;span class="sr"&gt;html$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;use&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;html-loader&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;test&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\.(&lt;/span&gt;&lt;span class="sr"&gt;scss|sass&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="na"&gt;use&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;style-loader&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;css-loader&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;sass-loader&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="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;Maybe a little bit more tricky and difficult to understand at first than the other bundlers, but really &lt;strong&gt;easy once you get the sense of how everything works together&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is happening in this &lt;em&gt;config&lt;/em&gt; file? 🙃
&lt;/h2&gt;

&lt;p&gt;Well, first, we need an &lt;strong&gt;entry point&lt;/strong&gt; for our bundler to start merging everything. That is specified in the &lt;em&gt;entry&lt;/em&gt; attribute and the file will be our file &lt;em&gt;index.js&lt;/em&gt; in the folder &lt;em&gt;src&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Same for the &lt;strong&gt;output file&lt;/strong&gt;, we'll tell Webpack our file will be called &lt;em&gt;bundle.js&lt;/em&gt; and it should be stored in the folder &lt;em&gt;dist&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;And now, what's only left is to &lt;strong&gt;handle the files that are not JavaScript (ES5)&lt;/strong&gt;. Webpack takes care of these files using &lt;strong&gt;loaders&lt;/strong&gt;. To &lt;em&gt;transform&lt;/em&gt; these files, we just need to indicate the file format and which loader(s) will deal with them.&lt;/p&gt;

&lt;p&gt;So that's what we need: a few loaders to take care of our styles, our HTML and our JS (ES6 - remember that we're getting it ready for formats like &lt;em&gt;.jsx&lt;/em&gt;): &lt;code&gt;style-loader&lt;/code&gt;, &lt;code&gt;css-loader&lt;/code&gt; and &lt;code&gt;sass-loader&lt;/code&gt; for the styles, &lt;code&gt;html-loader&lt;/code&gt; for the HTML files and &lt;code&gt;babel-loader&lt;/code&gt; for ES6.&lt;/p&gt;

&lt;p&gt;Notice that we're also &lt;em&gt;transforming&lt;/em&gt; the HTML file (this loader will be useful if we want to add resources that are loaded directly in the HTML file, such as images). This loader is really useful in bigger projects, but not necessary in this case (due to its simple structure), we'll skip this step for the rest of the bundlers.&lt;/p&gt;

&lt;p&gt;And this is it. Everything will be bundled once we run the &lt;em&gt;build&lt;/em&gt; command.&lt;/p&gt;

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

&lt;p&gt;Since we're using &lt;code&gt;style-loader&lt;/code&gt; to bundle the styles, instead of a plugin to minify CSS and generate a new file (&lt;code&gt;MiniCSSExtractPlugin&lt;/code&gt;), the styles are injected into the HTML file inside a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag, so the only output file is &lt;code&gt;bundle.js&lt;/code&gt;, which needs to be added to &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do I think about Webpack? 👇
&lt;/h2&gt;

&lt;p&gt;I have to admit that first time I had to face Webpack I thought the configuration would be impossible. It was my first time using a bundler and I was barely able to understand the overall concept. Let alone all the loaders and more complex related stuff because it was a bigger project.&lt;/p&gt;

&lt;p&gt;But after a few from-scratch configurations on my part, I have to say that now &lt;strong&gt;I find it more intuitive and easier to set up&lt;/strong&gt; if I compare it to what it felt like to get to know the rest of them.&lt;/p&gt;

&lt;p&gt;Let's take a look at the others and you'll understand why! &lt;/p&gt;

&lt;h1&gt;
  
  
  2. Rollup
&lt;/h1&gt;

&lt;p&gt;Let's now turn our attention to &lt;strong&gt;Rollup&lt;/strong&gt;. As well as the rest of the loaders, this has been my first time trying it out, so I'll also provide my first impressions about it 🤓&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach used by Rollup
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;build&lt;/em&gt; command.&lt;/li&gt;
&lt;li&gt;An &lt;em&gt;optional&lt;/em&gt; &lt;em&gt;config&lt;/em&gt; file.&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Plugins&lt;/em&gt; used to &lt;em&gt;transform&lt;/em&gt; files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Basic bundle with no &lt;em&gt;config&lt;/em&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; rollup src/index.js --file dist/bundle.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Using a &lt;em&gt;config&lt;/em&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; rollup -c"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;A really easy command for building, as well, so nothing else to point out here.&lt;/p&gt;

&lt;p&gt;Let's now check the &lt;em&gt;config&lt;/em&gt; file, that is &lt;strong&gt;optional&lt;/strong&gt; but &lt;strong&gt;recommended&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rollup.config.js&lt;/code&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;babel&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;@rollup/plugin-babel&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;scss&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;rollup-plugin-scss&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="p"&gt;{&lt;/span&gt;
   &lt;span class="na"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/index.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./dist/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;format&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;cjs&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;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
      &lt;span class="nf"&gt;babel&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;exclude&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;node_modules/**&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="nf"&gt;scss&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;styles.css&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;What Webpack defines as &lt;em&gt;loaders&lt;/em&gt;, here in Rollup are called just &lt;em&gt;plugins&lt;/em&gt;. This time we just need a couple of them: the one for transpiling ES6 into ES5 (Babel) and the one for SCSS: &lt;code&gt;@rollup/plugin-babel&lt;/code&gt; and &lt;code&gt;rollup-plugin-scss&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;These plugins have also &lt;strong&gt;their own optional configuration&lt;/strong&gt;. In this case, for Babel, we're excluding the folder &lt;em&gt;node_modules&lt;/em&gt; and for SCSS we're giving the output file a different name. Otherwise, it will remain &lt;em&gt;output.css&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For configurations with &lt;strong&gt;plain CSS&lt;/strong&gt;, there's a plugin called &lt;code&gt;rollup-plugin-css-only&lt;/code&gt; that works in the exact same way as the plugin we're using for SCSS.&lt;/p&gt;

&lt;p&gt;Note that we need to specify the entry and the output points exactly as we did before with Webpack. &lt;/p&gt;

&lt;p&gt;And that would be it.&lt;/p&gt;

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

&lt;p&gt;The Rollup bundle comprises two files: &lt;code&gt;bundle.js&lt;/code&gt; and &lt;code&gt;styles.css&lt;/code&gt;. It's necessary to import the original styles files in the entry point &lt;code&gt;index.js&lt;/code&gt; for the bundler to be able to find the file (there's no other place where we can reference it).&lt;/p&gt;

&lt;p&gt;Also both &lt;em&gt;bundles&lt;/em&gt; need to be added to the HTML index file.&lt;/p&gt;

&lt;h2&gt;
  
  
  My first impressions about Rollup 👇
&lt;/h2&gt;

&lt;p&gt;To be honest, I wasn't expecting much of these other &lt;em&gt;easier slash light-weight&lt;/em&gt; bundlers since Webpack has always worked for me, and I have to say that Rollup has surprised me in a good way.&lt;/p&gt;

&lt;p&gt;I find it &lt;strong&gt;pretty similar with Webpack&lt;/strong&gt; (&lt;em&gt;config&lt;/em&gt; file with almost the same structure, &lt;em&gt;plugins&lt;/em&gt; work in the same way as &lt;em&gt;loaders&lt;/em&gt; to translate &lt;em&gt;no-js&lt;/em&gt; files, the easy build command...), which means familiarity, usage recall and, consequently,  ease of use. &lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;only drawback&lt;/strong&gt; I've been able to find so far is &lt;strong&gt;the large number of dependencies it relies on&lt;/strong&gt;, and consequently, the &lt;strong&gt;huge size&lt;/strong&gt; of the project (3x a project bundled with Webpack). We'll be focusing on this more in depth at the end of the post 🔜&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Browserify
&lt;/h1&gt;

&lt;p&gt;Let's now talk about &lt;strong&gt;Browserify&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Approach used by Browserify
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;No &lt;em&gt;config&lt;/em&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Transforms&lt;/em&gt; used to &lt;em&gt;transform&lt;/em&gt; files&lt;/li&gt;
&lt;li&gt;Everything you need to configure -&amp;gt; &lt;code&gt;package.json&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The method used by Browserify has nothing to do with the &lt;em&gt;traditional&lt;/em&gt; approach of a &lt;em&gt;build&lt;/em&gt; command and a &lt;em&gt;config&lt;/em&gt; file. With this bundler, &lt;strong&gt;every possible configuration&lt;/strong&gt; is allocated in &lt;code&gt;package.json&lt;/code&gt; and &lt;strong&gt;the build command can get a little bit tedious&lt;/strong&gt; if we don't have the concepts clear.&lt;/p&gt;

&lt;p&gt;It also needs &lt;strong&gt;plugins&lt;/strong&gt; (or &lt;em&gt;transforms&lt;/em&gt;, as they are also called) to &lt;em&gt;transform&lt;/em&gt; everything into something &lt;em&gt;readable&lt;/em&gt; by the browser.&lt;/p&gt;

&lt;p&gt;Let's have a glance at how we can configure it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; browserify -o dist/bundle.js src/index.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;A very basic use of this bundler could be something like the code snippet above. We only have defined the input and output files (no configuration for styles or anything more complex).&lt;/p&gt;

&lt;p&gt;Note the &lt;strong&gt;length of the build command&lt;/strong&gt; having only declared the input source and the output.&lt;/p&gt;

&lt;p&gt;Let me show you how it would look like if we add the suitable plugin for handling plain CSS.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; browserify -t [browserify-css --output dist/styles.css] -o dist/bundle.js src/index.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Then, if we wanted to add some configuration to the plugin, we would do something like the following down below in the same file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"browserify"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"browserify-css"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"autoInject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"minify"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"rootDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;It starts getting not &lt;em&gt;that maintainable&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;And now, let's complicate it a little bit more by adding plugins for SCSS and Babel. We need a couple of &lt;em&gt;plugins&lt;/em&gt; called &lt;code&gt;Babelify&lt;/code&gt; and &lt;code&gt;scssify&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  Something to take into account
&lt;/h3&gt;

&lt;p&gt;I've been trying out this bundler with &lt;strong&gt;the last released version of Node&lt;/strong&gt; (v16.4.2) and the command line throws multiple errors when trying to install any dependencies that rely on &lt;code&gt;node-sass&lt;/code&gt; (&lt;code&gt;scssify&lt;/code&gt; and &lt;code&gt;sassify&lt;/code&gt;, more specifically). A very negative point.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We could do this in two different ways: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;By saturating the build script with more content 😅&lt;/li&gt;
&lt;li&gt;By adding a &lt;em&gt;transform&lt;/em&gt; property&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Via the build script
&lt;/h3&gt;

&lt;p&gt;For specifying several &lt;em&gt;transforms&lt;/em&gt; in the &lt;em&gt;build&lt;/em&gt; script using Browserify, we should add as many as &lt;em&gt;-t&lt;/em&gt; [ &lt;em&gt;transform options&lt;/em&gt; ] as needed, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; browserify -t [ scssify --output dist/styles.css ] -t [ babelify --presets [ @babel/preset-env ] ] -o dist/bundle.js src/index.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;



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

&lt;/div&gt;

&lt;p&gt;If you're using this method, pay close attention to the &lt;strong&gt;white spaces&lt;/strong&gt; inside the arrays. &lt;strong&gt;They matter&lt;/strong&gt; ✌️&lt;/p&gt;

&lt;p&gt;I find this method &lt;strong&gt;tedious&lt;/strong&gt; and &lt;strong&gt;difficult to understand&lt;/strong&gt;, and above all, &lt;strong&gt;difficult to maintain&lt;/strong&gt;. And we're only using two plugins. All said.&lt;/p&gt;

&lt;h3&gt;
  
  
  Via the transform property
&lt;/h3&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"browserify"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"transform"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"babelify"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"presets"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
               &lt;/span&gt;&lt;span class="s2"&gt;"@babel/preset-env"&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"scssify"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"autoInject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;By using this method, the &lt;em&gt;build&lt;/em&gt; script will look like it was originally, when it just performed the simple bundle of the input js file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; browserify -o dist/bundle.js src/index.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Much better 😊&lt;/p&gt;

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

&lt;p&gt;The Browserify bundle consists of the &lt;code&gt;bundle.js&lt;/code&gt; file and, only &lt;strong&gt;if we set an output file for the styles&lt;/strong&gt; in the plugin that takes care of them, &lt;strong&gt;we'll get a&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;styles.css&lt;/em&gt;&lt;/strong&gt; file. &lt;strong&gt;Otherwise&lt;/strong&gt;, the styles will be injected at the bottom of the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element in the HTML file &lt;strong&gt;inside a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Take a look at this two different config examples for &lt;code&gt;browserify-css&lt;/code&gt;: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"browserify-css"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"autoInject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"minify"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"rootDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"output"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/styles.css"&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;This config above will create a separate &lt;em&gt;.css&lt;/em&gt; file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"browserify-css"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"autoInject"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"minify"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"rootDir"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;And this other config will inject the code into a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag in the head of &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  My first impressions about Browserify 👇
&lt;/h2&gt;

&lt;p&gt;My less favorite so far. &lt;strong&gt;I don't find it&lt;/strong&gt; as &lt;strong&gt;intuitive&lt;/strong&gt; as the other two, and the &lt;strong&gt;approach&lt;/strong&gt; it uses is totally &lt;strong&gt;different&lt;/strong&gt; from what we are &lt;em&gt;regularly&lt;/em&gt; used to. Also, I think the &lt;strong&gt;configuration is more tedious&lt;/strong&gt; if at first you don't know how and where to handle the required plugins.&lt;/p&gt;

&lt;p&gt;Also, &lt;strong&gt;blank spaces matter&lt;/strong&gt;, and if you don't know that beforehand, you can perfectly spend 2 hours trying to figure out what's wrong with your code 👎&lt;/p&gt;

&lt;h1&gt;
  
  
  4. ESBuild
&lt;/h1&gt;

&lt;p&gt;Time to talk about &lt;strong&gt;ESBuild&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach used by ESBuild
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;em&gt;build&lt;/em&gt; command (encourages the use of the terminal)&lt;/li&gt;
&lt;li&gt;An &lt;em&gt;optional&lt;/em&gt; &lt;em&gt;config&lt;/em&gt; file&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;Plugins&lt;/em&gt; used to transform files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With ESBuild you can use &lt;strong&gt;either the command line or a&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;config&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;file&lt;/strong&gt; as well as the others, even for more complex configurations. It's totally up to you, but specifying a &lt;em&gt;config&lt;/em&gt; file is always recommended for &lt;strong&gt;maintainability, scalability, readability and productivity&lt;/strong&gt; reasons.&lt;/p&gt;

&lt;p&gt;We're going to create a &lt;em&gt;config&lt;/em&gt; file called &lt;code&gt;esbuild.config.js&lt;/code&gt; and we'll execute it from the &lt;em&gt;build&lt;/em&gt; script by running the command &lt;code&gt;node&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;But first, let's have a look at the simplest way to start bundling our files with ESBuild (no &lt;em&gt;config&lt;/em&gt; file is required this time):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; esbuild --bundle src/index.js --outfile=dist/bundle.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;As usual, we declare the entry point and the output file. And that's it. But what happens when we need to &lt;strong&gt;keep bundling more different kind of files&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;Let's then take a look at the following example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; esbuild --bundle src/index.js --outfile=dist/bundle.js &amp;amp;&amp;amp; esbuild --bundle styles/styles.css --outfile=dist/bundle.css"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;We are now bundling the styles as well, and adding a little more information to the &lt;em&gt;build&lt;/em&gt; script (mess alert again!) by defining two different bundlers. We could (and definitely will) have more filetypes that would need to get bundled and this could become a total mess.&lt;/p&gt;

&lt;p&gt;So, let's put aside this approach and let's create a &lt;em&gt;config&lt;/em&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;esbuild.config.js&lt;/code&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;esbuild&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;esbuild&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;sassPlugin&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;esbuild-sass-plugin&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;babel&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;esbuild-plugin-babel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;esbuild&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;build&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
   &lt;span class="na"&gt;entryPoints&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;src/index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
   &lt;span class="na"&gt;bundle&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;outfile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;dist/bundle.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;sassPlugin&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="nf"&gt;babel&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And here comes what I found (let me say) &lt;em&gt;weird&lt;/em&gt; and what took me some time to figure out.&lt;/p&gt;

&lt;p&gt;Maybe because I was expecting to run this &lt;em&gt;config&lt;/em&gt; file in the same way as Webpack and Rollup do (they run their &lt;em&gt;config&lt;/em&gt; file by default if it exists and has the default name), I had some trouble trying to tell ESBuild to take it as an input for configuration.&lt;/p&gt;

&lt;p&gt;Finally, I realized that &lt;strong&gt;it should be called via the node command&lt;/strong&gt; to just run the script 😬&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; node esbuild.config.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;And that was all. &lt;/p&gt;




&lt;p&gt;Something I want to mention here is that, the fact that &lt;strong&gt;there aren't so many plugins from where to pick&lt;/strong&gt; and also &lt;strong&gt;most of them are way outdated&lt;/strong&gt;, doesn't make me particularly happy. And, if you allow me some advice, &lt;strong&gt;try to pick plugins which use either CommonJS&lt;/strong&gt; (which inserts modules through &lt;em&gt;require&lt;/em&gt;) &lt;strong&gt;or ES Modules&lt;/strong&gt; (which does the same using &lt;em&gt;import&lt;/em&gt;),  because if you mix them up... the only things you'll get will be errors and mess everywhere! 😖&lt;/p&gt;

&lt;p&gt;Just make sure you &lt;strong&gt;change the type attribute&lt;/strong&gt; in &lt;code&gt;package.json&lt;/code&gt; &lt;strong&gt;if you're using ES Modules&lt;/strong&gt; (&lt;em&gt;import&lt;/em&gt;) to load your plugins into the &lt;em&gt;config&lt;/em&gt; file:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"module"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Practically all plugins have been created by the community (if not all). For this example, I've chosen &lt;code&gt;esbuild-sass-plugin&lt;/code&gt; for SASS/SCSS and &lt;code&gt;esbuild-plugin-babel&lt;/code&gt; for Babel. Both of them work with &lt;em&gt;import&lt;/em&gt;, so no extra problems.&lt;/p&gt;

&lt;p&gt;A great point to mention: ESBuild is really &lt;strong&gt;fast compared with the others&lt;/strong&gt;. At least in this scenario.&lt;/p&gt;

&lt;h2&gt;
  
  
  My first impressions about ESBuild 👇
&lt;/h2&gt;

&lt;p&gt;Mixed emotions. At first, I thought it would be very easy to configure (it is if you only intend to perform a regular bundle) but then I started to &lt;strong&gt;struggle a bit&lt;/strong&gt; with the &lt;em&gt;config&lt;/em&gt; file, &lt;strong&gt;not because of the syntax&lt;/strong&gt; but because of the &lt;strong&gt;multiple errors thrown&lt;/strong&gt; on the terminal &lt;strong&gt;regarding Node&lt;/strong&gt;. &lt;/p&gt;

&lt;h1&gt;
  
  
  5. Parcel
&lt;/h1&gt;

&lt;p&gt;Let's now have a look at the last bundler in this list: the &lt;em&gt;famous&lt;/em&gt; Parcel. Hi to the huge community of Parcel fans out there 👋&lt;/p&gt;

&lt;h2&gt;
  
  
  Approach used by Parcel
&lt;/h2&gt;

&lt;p&gt;The Parcel approach is mainly based on a &lt;strong&gt;&lt;em&gt;zero&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;configuration&lt;/strong&gt; environment 😱 I was reluctant to believe it at first (that's the main reason why I wanted to try it out so bad), but, yes, it's possible to bundle a project like the one we're testing in this post by writing the bare minimum configuration, in a few minutes and without racking your brains 🙌&lt;/p&gt;

&lt;h2&gt;
  
  
  Zero configuration? Are you sure? 😪
&lt;/h2&gt;

&lt;p&gt;By zero they mean &lt;strong&gt;very little and precise&lt;/strong&gt;. Let me show you the configuration I used for this basic project:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
   &lt;/span&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"rm -rf dist &amp;amp;&amp;amp; rm -rf  &amp;amp;&amp;amp; parcel build src/index.js --no-scope-hoist --no-source-maps"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;The procedure is pretty much the same: we need to indicate where the &lt;strong&gt;entry point&lt;/strong&gt; for our app is located. And I also added the flags &lt;code&gt;--no-scope-hoist&lt;/code&gt; &lt;strong&gt;to avoid odd behaviors&lt;/strong&gt; regarding &lt;code&gt;require&lt;/code&gt; when running &lt;em&gt;js&lt;/em&gt; scripts and &lt;code&gt;--no-source-maps&lt;/code&gt; &lt;strong&gt;to avoid the creation of&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;sourcemaps&lt;/em&gt;&lt;/strong&gt;. Otherwise, Parcel will create one for every bundle file by default.&lt;/p&gt;

&lt;p&gt;Now, if we want &lt;strong&gt;to change the location and the name of the output&lt;/strong&gt; bundle file, we need to change the value of the &lt;em&gt;main&lt;/em&gt; property attribute in &lt;code&gt;package.json&lt;/code&gt;, like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nl"&gt;"main"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dist/bundle.js"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;Otherwise, the bundle will be generated at root level and will be called with the name that is stored in &lt;em&gt;main&lt;/em&gt;, in most cases &lt;em&gt;index.js&lt;/em&gt; (if we didn't change it when running &lt;code&gt;npm init&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Now, let's &lt;em&gt;(zero)configure&lt;/em&gt; the styles and Babel
&lt;/h2&gt;

&lt;p&gt;Since we're using SCSS, we need to use SASS as a preprocessor. So, what was my surprise when I read that &lt;strong&gt;SASS is already included with Parcel installation&lt;/strong&gt;. But not only &lt;em&gt;SASS&lt;/em&gt;, also &lt;em&gt;LESS&lt;/em&gt;, &lt;em&gt;Stylus&lt;/em&gt;, and... &lt;em&gt;Babel&lt;/em&gt;! 😧&lt;/p&gt;

&lt;p&gt;So the only step to take here is to create a couple of config files for SASS and Babel.&lt;/p&gt;

&lt;p&gt;Our SASS config file will be named &lt;code&gt;.sassrc&lt;/code&gt; and will contain the following code inside:&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;includePaths&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;node_modules&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;And when we run the &lt;em&gt;build&lt;/em&gt; command, Parcel will automatically install the plugin &lt;code&gt;@parcel/transformer-sass&lt;/code&gt; as a dependency and will create a &lt;code&gt;bundle.css&lt;/code&gt; file in the same specified directory for the bundle, and that's all the configuration. Pretty cool, right? &lt;/p&gt;

&lt;p&gt;Now don't forget to link this file to your HTML 🤗  And remember that your &lt;em&gt;.scss&lt;/em&gt; file should has been previously &lt;strong&gt;imported on your entry point&lt;/strong&gt; file in order for the bundler to know what file it has to transform.&lt;/p&gt;

&lt;p&gt;On Babel side, we need to create a &lt;code&gt;.babelrc&lt;/code&gt;config file to specify the needed presets (let's say we want to get it ready for using React in the future): &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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;presets&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;@babel/preset-env&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;@babel/preset-react&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;Parcel will automatically call &lt;code&gt;@parcel/transformer-babel&lt;/code&gt; and will do the job for us.&lt;/p&gt;

&lt;p&gt;Don't forget to previously install &lt;code&gt;@babel/preset-env&lt;/code&gt;, &lt;code&gt;@babel/preset-react&lt;/code&gt; and all the dependencies needed by React. &lt;/p&gt;

&lt;p&gt;And that's... it. We're all set and ready to rock 😁 &lt;/p&gt;

&lt;h2&gt;
  
  
  My first impressions about Parcel 👇
&lt;/h2&gt;

&lt;p&gt;The first thing I want to point out is that Parcel wasn't that easy for me at the beginning since I had a really (really) hard time trying to get it ready to work, and it seemed like it wouldn't stop throwing errors regarding the OS and creating more trouble out of outdated versions of some dependencies 😥 So, to be honest, Parcel wasn't going to be in this list because I didn't want to talk about it if I couldn't try it out myself. &lt;/p&gt;

&lt;p&gt;But, &lt;em&gt;magically&lt;/em&gt; ✨ (and due to my tireless perseverance 😅), I finally could make it and set everything up to get it ready 🙌&lt;/p&gt;

&lt;p&gt;And after that, it was really easy compared to the rest of the bundlers. So let's draw a veil over the setbacks and let's give it a chance.&lt;/p&gt;

&lt;p&gt;Parcel is also pretty &lt;strong&gt;fast&lt;/strong&gt;, because it uses &lt;strong&gt;&lt;em&gt;cache&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But... something I don't like at all is the &lt;strong&gt;several security vulnerabilities that appear after installing it&lt;/strong&gt; (around 12, some of them high risk) 😖 That doesn't speak well of you, Parcel. Not to mention the &lt;strong&gt;huge size of the project&lt;/strong&gt;. &lt;strong&gt;The heaviest&lt;/strong&gt; in this comparative.&lt;/p&gt;

&lt;h1&gt;
  
  
  The comparison 📈
&lt;/h1&gt;

&lt;p&gt;Here you have the highlights of this comparative summed up in a table:&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%2Fuploads%2Farticles%2Fnaipfc68z6u3looyvidm.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%2Fuploads%2Farticles%2Fnaipfc68z6u3looyvidm.png" alt="Table that compares different features of the 5 mentioned bundlers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What is my final verdict? 😼
&lt;/h1&gt;

&lt;p&gt;Well, I think some of &lt;strong&gt;these other bundlers apart from Webpack can be cool to use for small or side projects&lt;/strong&gt;, but in reality, I personally think that &lt;strong&gt;Webpack&lt;/strong&gt; is still the &lt;strong&gt;best option for robust projects&lt;/strong&gt; (we just have to look at the huge number of downloads per week compared to the rest). &lt;/p&gt;

&lt;p&gt;Also, I find it the &lt;strong&gt;easiest to manage&lt;/strong&gt; since once you get the sense of how it deals with configuration, it's easier to keep adding values to that configuration. But it's not something that obvious. You have to take your time playing with it to get a very basic idea at first.&lt;/p&gt;

&lt;p&gt;Moreover, you have the majority of resources you need (loaders, plugins...) available &lt;strong&gt;from the creators&lt;/strong&gt;, so you make sure you're using &lt;strong&gt;a real source of truth&lt;/strong&gt;. And they are updated really frequently, so you can use it without worry with newer versions of Node and other packages.&lt;/p&gt;

&lt;p&gt;So, yes, &lt;strong&gt;I will keep choosing Webpack&lt;/strong&gt; as my first option over the others.&lt;/p&gt;




&lt;p&gt;My second choice would be &lt;strong&gt;Rollup&lt;/strong&gt; for sure, and I truly think &lt;strong&gt;I will definitely use it in some of my side projects&lt;/strong&gt; since I found it &lt;strong&gt;intuitive to configure&lt;/strong&gt; and it &lt;strong&gt;seems like it works properly on robust projects&lt;/strong&gt; as well. &lt;/p&gt;

&lt;p&gt;And about their &lt;em&gt;plugins&lt;/em&gt;, most of them are also available &lt;strong&gt;from the creators&lt;/strong&gt;, so, again, a real source of truth and many more advantages.&lt;/p&gt;




&lt;p&gt;I also think &lt;strong&gt;Parcel&lt;/strong&gt; is &lt;strong&gt;a very interesting option&lt;/strong&gt; and I'd like to try it with larger projects and check if it really doesn't need further configuration. Definitely a great find.&lt;/p&gt;

&lt;p&gt;And a big plus to the fact that &lt;strong&gt;plugins&lt;/strong&gt; like &lt;em&gt;Babel&lt;/em&gt;, &lt;em&gt;SASS&lt;/em&gt;, &lt;em&gt;LESS&lt;/em&gt; and some more are &lt;strong&gt;built-in and ready to use&lt;/strong&gt; out of the box.&lt;/p&gt;




&lt;p&gt;What about &lt;strong&gt;Browserify&lt;/strong&gt; and &lt;strong&gt;ESBuild&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;These two have been &lt;strong&gt;the ones with which I have struggled more&lt;/strong&gt;, especially Browserify. The fact that it doesn't require a &lt;em&gt;config&lt;/em&gt; file and everything should be declared in &lt;em&gt;package.json&lt;/em&gt; kinda forces you to &lt;strong&gt;change the way you think of how bundlers&lt;/strong&gt; are &lt;strong&gt;&lt;em&gt;traditionally&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;configured&lt;/strong&gt;. Not to mention you end up &lt;em&gt;saturating&lt;/em&gt; the file with &lt;strong&gt;way a lot tricky configurations&lt;/strong&gt;, which makes it &lt;strong&gt;difficult to read and maintain&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Also, when it comes to &lt;em&gt;plugins&lt;/em&gt;, &lt;strong&gt;most of them are not developed and maintained by the creators&lt;/strong&gt; (especially the most common) and are &lt;strong&gt;really outdated&lt;/strong&gt; (many of them haven't been updated in the last 4 years) and this fact &lt;strong&gt;leads to problems with newer Node/other packages versions&lt;/strong&gt; and compatibility in general.&lt;/p&gt;




&lt;p&gt;And on &lt;strong&gt;ESBuild&lt;/strong&gt; side, I didn't especially like it either. The first impression was good but then, since the &lt;em&gt;config&lt;/em&gt; file caused me some trouble, it mainly &lt;strong&gt;ended up in confusion about how to manage configuration&lt;/strong&gt; with and without this file. So I found it quite &lt;strong&gt;ambiguous&lt;/strong&gt; and took me a bit to realize &lt;strong&gt;how to set up both scenarios&lt;/strong&gt; in different ways.&lt;/p&gt;

&lt;p&gt;About their &lt;em&gt;plugins&lt;/em&gt;, same as Browserify, &lt;strong&gt;practically all of them has been created by the community&lt;/strong&gt;, not the author, so you have to use them at your own risk. But as a plus point, &lt;strong&gt;they are often updated and maintained&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Now it's your turn! 🔥
&lt;/h1&gt;

&lt;p&gt;What do you think of this comparative? Do you agree? Which one is your preferred bundler? Do you know some other bundler that is not on the list? Would you like to suggest different bundlers for future comparative posts? Comment below!&lt;/p&gt;

&lt;h1&gt;
  
  
  Disclaimer 👇
&lt;/h1&gt;

&lt;p&gt;Remember this is just a post showing &lt;strong&gt;my impressions about something I tried for the first time&lt;/strong&gt;. I have decided to share the process with you and my opinion about what I experienced. &lt;strong&gt;The opinions expressed in this post don't mean that some bundlers are better over others&lt;/strong&gt;. My advice is to try them all out and draw your own conclusions, like I did. And based on that, use the ones you like best and fit your needs.&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;




&lt;h4&gt;
  
  
  And last but not least... A quick friendly reminder before we go 😊
&lt;/h4&gt;

&lt;p&gt;We all know there are million ways to get things done when it comes to programming and development, and we're here to &lt;strong&gt;help and learn&lt;/strong&gt;, so, if you know another possible way to do what others are sharing (&lt;strong&gt;not better, not worse, just different&lt;/strong&gt;), feel free to share it if you feel like it, but, please, &lt;strong&gt;always be kind and respectful&lt;/strong&gt; with the author and the rest of the community. Thank you and happy coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webpack</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Let's create an iOS Calculator Clone in React [+ detailed explanations]</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Sat, 03 Jul 2021 15:36:25 +0000</pubDate>
      <link>https://dev.to/underscorecode/let-s-create-an-ios-calculator-clone-in-react-detailed-explanations-1h85</link>
      <guid>https://dev.to/underscorecode/let-s-create-an-ios-calculator-clone-in-react-detailed-explanations-1h85</guid>
      <description>&lt;p&gt;Hello everybody! 🚀&lt;/p&gt;

&lt;p&gt;Today we will be creating an &lt;strong&gt;iOS calculator clone using React&lt;/strong&gt;.&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%2Fuploads%2Farticles%2F061tj2jsax27mlq4nbpk.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%2Fuploads%2Farticles%2F061tj2jsax27mlq4nbpk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;tutorial&lt;/strong&gt; comprises &lt;strong&gt;3 parts&lt;/strong&gt;: the components structure, the calculator's interface and the functionality.&lt;/p&gt;

&lt;p&gt;Let's dive into it and &lt;strong&gt;start by creating the components and their structures&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. The components
&lt;/h1&gt;

&lt;p&gt;Since we're using a &lt;strong&gt;component-based approach&lt;/strong&gt;, we're going to try to &lt;strong&gt;modularize our app as much as we can&lt;/strong&gt;, so with that vision in mind, we'll split it up into &lt;strong&gt;4 components&lt;/strong&gt;, namely, the following: &lt;/p&gt;

&lt;h3&gt;
  
  
  · Calculator.js
&lt;/h3&gt;

&lt;p&gt;This will be the &lt;strong&gt;main component&lt;/strong&gt;. The one who will hold all the &lt;strong&gt;logic&lt;/strong&gt; and &lt;strong&gt;functionality&lt;/strong&gt;, and will &lt;strong&gt;interact&lt;/strong&gt; with the rest of the component through &lt;strong&gt;props&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  · Display.js
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;screen&lt;/strong&gt; of the calculator. It will receive a &lt;strong&gt;value&lt;/strong&gt; that will be &lt;strong&gt;displayed&lt;/strong&gt; on screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  · Keypad.js
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;keypad&lt;/strong&gt; of the calculator. It will be divided into a few sections, depending on the functionality of every specific &lt;strong&gt;set of buttons&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  · Button.js
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;reusable&lt;/strong&gt; component &lt;strong&gt;for every button&lt;/strong&gt; in the calculator. &lt;/p&gt;




&lt;p&gt;Now that we've learned about the components we're going to work with, let's turn our attention to the structure of each of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1.1. Calculator.js
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;parent component&lt;/strong&gt;,  which will be in charge of all the &lt;strong&gt;functionality&lt;/strong&gt; and the one &lt;strong&gt;managing the state&lt;/strong&gt; of the whole calculator app.&lt;/p&gt;

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

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Display&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;./Display&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Keypad&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;./Keypad&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;Calculator&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="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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"calculator-view"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex column jc-center ai-center&lt;/span&gt;&lt;span class="dl"&gt;"&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="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex column jc-sp-between ai-center&lt;/span&gt;&lt;span class="dl"&gt;"&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;Display&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;screenValue&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;Keypad&lt;/span&gt; &lt;span class="na"&gt;actionToPerform&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleActionToPerform&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;allClear&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;isScreenClear&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="nt"&gt;div&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="nt"&gt;div&lt;/span&gt; &lt;span class="p"&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;This main component is going to call a couple of different custom components: &lt;strong&gt;Display&lt;/strong&gt; and &lt;strong&gt;Keypad&lt;/strong&gt;, so they need to be imported up above.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that the ellipsis (...) in this code snippet means that we'll be injecting some &lt;strong&gt;state&lt;/strong&gt; and &lt;strong&gt;functionality&lt;/strong&gt; for the component soon later.&lt;/p&gt;

&lt;p&gt;For now, let's just focus on the structure of the components themselves.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1.2. Display.js
&lt;/h2&gt;

&lt;p&gt;A very simple component that just &lt;strong&gt;receives a value&lt;/strong&gt; and shows it on screen, as mentioned earlier above.&lt;/p&gt;

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

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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&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;Display&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;value&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"display"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex"&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="nt"&gt;input&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;tabIndex&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"-1"&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&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="nt"&gt;div&lt;/span&gt;&lt;span class="p"&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Display&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  1.3. Keypad.js
&lt;/h2&gt;

&lt;p&gt;Keypad is a component whose function is to &lt;strong&gt;serve as a gateway between the calculator and the buttons&lt;/strong&gt;.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Button&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;./Button&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;Keypad&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;actionToPerform&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;allClear&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&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;handleClickButton&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;keyType&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;actionToPerform&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;keyType&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"keypad"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex row jc-sp-around"&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="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"grid"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;functionKeys&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;functionKey&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;functionKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;functionKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;functionKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                            &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"fx-key"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClickButton&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"fx"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
             &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;numericKeys&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;numericKey&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;numericKey&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;numericKey&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;numericKey&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                            &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"numeric-key"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClickButton&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"numeric"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
             &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKeys&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;lastRowKey&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                            &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;buttonStyle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClickButton&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;lastRowKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&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;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; 
         &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&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="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"flex column jc-sp-btw"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;operatorKeys&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;operatorKey&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
                        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="na"&gt;key&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;operatorKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;label&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;operatorKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;operatorKey&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
                            &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"op-key"&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleClickButton&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"operator"&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
             &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
         &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&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="nt"&gt;div&lt;/span&gt;&lt;span class="p"&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Keypad&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;This component contains a bunch of buttons (don't forget to import the &lt;em&gt;Button&lt;/em&gt; component 🙂), which when pressed, &lt;strong&gt;send back some information about their functionality and type&lt;/strong&gt;. The keypad, in turn, will send this data to the Calculator component.&lt;/p&gt;

&lt;p&gt;Since it's a good practice to &lt;strong&gt;abstract&lt;/strong&gt; your data as much as you can (always in a moderate way), we'll be using &lt;strong&gt;arrays to define every set of buttons&lt;/strong&gt; instead of defining a button component every time we need to create one. This is useful for many reasons.&lt;/p&gt;

&lt;p&gt;One of them, among others: Let's say that you wish to &lt;strong&gt;change the name&lt;/strong&gt; of the &lt;em&gt;Button&lt;/em&gt; component to &lt;em&gt;Key&lt;/em&gt;. If you're calling the component 10 times, you'd have to change the name of the component 10 times. However, if you map through an array that creates a &lt;em&gt;Button&lt;/em&gt; component in every iteration, you'd just have to &lt;strong&gt;make the change once&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's have a look at how these arrays are defined and structured:&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;numericKeys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&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="mi"&gt;6&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;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&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;operatorKeys&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;÷&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;×&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;x&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;=&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;functionKeys&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allClear&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AC&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;C&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;allClear&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AC&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;C&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;±&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+/-&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lastRowKeys&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;label&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&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&lt;/span&gt;&lt;span class="dl"&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;numeric&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;numeric-key special&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;label&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;·&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&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;fx&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;numeric-key&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;For &lt;strong&gt;numeric keys&lt;/strong&gt;, we just have an &lt;strong&gt;array of&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;integers&lt;/em&gt;&lt;/strong&gt;, ordered by the order of occurrence of each of them.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;operator&lt;/strong&gt; and &lt;strong&gt;function keys&lt;/strong&gt;, we have an &lt;strong&gt;array of objects&lt;/strong&gt;, each of them containing a &lt;em&gt;label&lt;/em&gt; and a &lt;em&gt;value&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For &lt;strong&gt;last row keys&lt;/strong&gt; (they receive this name because they appear at the bottom but have different functionalities as to organize them based on that), we have as well an &lt;strong&gt;array of objects&lt;/strong&gt;, each of them comprising a &lt;em&gt;label&lt;/em&gt;, a &lt;em&gt;value&lt;/em&gt;, a &lt;em&gt;type&lt;/em&gt; and a &lt;em&gt;buttonStyle&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  1.4. Button.js
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;reusable&lt;/strong&gt; component to &lt;strong&gt;define buttons&lt;/strong&gt;.&lt;/p&gt;

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

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&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&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;Button&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;buttonStyle&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;props&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;handleButtonClick&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;onClick&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;type&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="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;buttonStyle&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;onClick&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleButtonClick&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="p"&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="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;This component just renders &lt;strong&gt;a regular HTML button element&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. The interface
&lt;/h1&gt;

&lt;p&gt;In this tutorial, we're cloning an existent app, so our &lt;strong&gt;replica&lt;/strong&gt; should be &lt;strong&gt;the most faithful possible to the original interface&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For styling the interface, we'll be using &lt;strong&gt;SCSS&lt;/strong&gt;. But of course you can use whichever styling language / tool / resource of your choice: &lt;strong&gt;CSS&lt;/strong&gt;, &lt;strong&gt;SASS&lt;/strong&gt;, &lt;strong&gt;LESS&lt;/strong&gt;, &lt;strong&gt;PostCSS&lt;/strong&gt;, &lt;strong&gt;Styled Components&lt;/strong&gt;...&lt;/p&gt;

&lt;p&gt;Here's the code:&lt;/p&gt;

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

&lt;span class="c1"&gt;//color variables&lt;/span&gt;
&lt;span class="nv"&gt;$white&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$black&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$dark-gray&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$medium-gray&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$gray&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#a5a5a5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$light-gray&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#c4c4c4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$orange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ff9d20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;$light-orange&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#ffb657&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Source Sans Pro"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;200&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="nv"&gt;$white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.flex&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;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.row&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="nb"&gt;nowrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.column&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;flex-flow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.flex-end&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex-end&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.jc-sp-btw&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-between&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.jc-sp-around&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-around&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.jc-center&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;justify-content&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="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.ai-center&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;align-items&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="p"&gt;}&lt;/span&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="na"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="na"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;9px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nn"&gt;#calculator-view&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;385px&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;775px&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="nv"&gt;$black&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;70px&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;10px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="nv"&gt;$dark-gray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nn"&gt;#viewport&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;90%&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;70%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nn"&gt;#display&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
         &lt;span class="nt"&gt;input&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="nb"&gt;none&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="nb"&gt;none&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;6rem&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="nv"&gt;$black&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;100%&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;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;padding-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&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="nn"&gt;#keypad&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;97%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
         &lt;span class="nt"&gt;button&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="nb"&gt;none&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;50px&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;75px&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;75px&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;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;.fx-key&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="nv"&gt;$gray&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="nv"&gt;$black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
               &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;:hover&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="nv"&gt;$light-gray&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;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;.numeric-key&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="nv"&gt;$dark-gray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
               &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;:hover&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="nv"&gt;$medium-gray&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;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;.op-key&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="nv"&gt;$orange&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;3rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
               &lt;span class="k"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nd"&gt;:hover&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="nv"&gt;$light-orange&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;&amp;amp;&lt;/span&gt;&lt;span class="nc"&gt;.special&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;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
               &lt;span class="na"&gt;grid-column-start&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="na"&gt;grid-column-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;span&lt;/span&gt; &lt;span class="m"&gt;2&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;left&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
               &lt;span class="nl"&gt;padding-left&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="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;There's not really much to explain here. We're just simulating the interface of the iOS calculator and this snippet of code would be it! 😇&lt;/p&gt;

&lt;h1&gt;
  
  
  3. The functionality
&lt;/h1&gt;

&lt;p&gt;Let's start by defining &lt;strong&gt;the overall state&lt;/strong&gt; for the calculator (specified and managed in the calculator component).&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;Calculator&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;accValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setAccValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&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;screenValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&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&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;currentOperator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setCurrentOperator&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&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;expectsOperand&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setExpectsOperand&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&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="p"&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="nx"&gt;Calculator&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  What's the main idea in here?
&lt;/h2&gt;

&lt;p&gt;Well, we need to divide our component state into &lt;strong&gt;four&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;chunks&lt;/em&gt;&lt;/strong&gt; (the minimum required &lt;strong&gt;for our calculator to behave as a calculator&lt;/strong&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;accValue&lt;/strong&gt;: the accumulated value in the calculator. It starts off as &lt;em&gt;null&lt;/em&gt; because there's no accumulated value initially.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;screenValue&lt;/strong&gt;: the value that is going to be shown on screen. Initially, its value is &lt;em&gt;"0"&lt;/em&gt;. Note that we're defining it as a &lt;strong&gt;string&lt;/strong&gt;, not a &lt;strong&gt;number&lt;/strong&gt;. We'll talk about this later. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;currentOperator&lt;/strong&gt;: the ongoing operator. As well as &lt;em&gt;accValue&lt;/em&gt;, it starts off as &lt;em&gt;null&lt;/em&gt; for the same reason.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;expectsOperand&lt;/strong&gt;: a &lt;strong&gt;boolean&lt;/strong&gt; that lets the calculator know &lt;strong&gt;if a new operand should be entered&lt;/strong&gt; after pressing a button or if, on the contrary, a result, which is &lt;strong&gt;final itself&lt;/strong&gt;, has been already calculated.&lt;br&gt;
It will become &lt;strong&gt;true&lt;/strong&gt; when an &lt;strong&gt;operator key&lt;/strong&gt; is pressed, and &lt;strong&gt;false otherwise&lt;/strong&gt; (&lt;strong&gt;only operations wait for a second operand&lt;/strong&gt;. Neither numbers nor functions that apply to a single operand). It starts off as &lt;em&gt;false&lt;/em&gt;, since the initial state itself is &lt;em&gt;stable&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's now take a look at the &lt;strong&gt;different types of functionality that our calculator will implement&lt;/strong&gt; and their &lt;strong&gt;associated keys/buttons&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But first, let me show you the &lt;strong&gt;handler&lt;/strong&gt; that will be called every time a key (&lt;em&gt;Button&lt;/em&gt; component) is pressed. It receives the &lt;strong&gt;value of the key&lt;/strong&gt; and the &lt;strong&gt;key type&lt;/strong&gt; (function, numeric or operator) as parameters. The handler itself will call a &lt;strong&gt;different function&lt;/strong&gt; depending on the value of &lt;em&gt;keyType&lt;/em&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;handleActionToPerform&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;keyType&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;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;keyType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fx&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;handleClickFunctionKey&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="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;numeric&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;handleClickNumericKey&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="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;operator&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;handleClickOperator&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="k"&gt;break&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;h2&gt;
  
  
  3.1. Function keys
&lt;/h2&gt;

&lt;p&gt;The function keys are those who &lt;strong&gt;implement a function over a single operand&lt;/strong&gt; or functions &lt;strong&gt;related to the screen&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is what happens when we click on a function button:&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;handleClickFunctionKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&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;switch &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="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;AC&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;allClear&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;C&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;clearScreen&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+/-&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;reverseSign&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;percentage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;addDecimalPoint&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="k"&gt;break&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;We have implemented a &lt;em&gt;switch&lt;/em&gt; statement that &lt;strong&gt;decides which function is executed next&lt;/strong&gt; based on the passed in value.&lt;/p&gt;

&lt;p&gt;The few different &lt;strong&gt;function keys&lt;/strong&gt; in our calculator &lt;strong&gt;implement the following actions&lt;/strong&gt;:&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1.1. All clear and clear screen functions: AC/C
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;allClear&lt;/strong&gt; function (AC) &lt;strong&gt;clears everything&lt;/strong&gt; and &lt;strong&gt;resets every value&lt;/strong&gt; to their initial state.&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;allClear&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;setAccValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nf"&gt;setScreenValue&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&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nf"&gt;setCurrentOperator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nf"&gt;setExpectsOperand&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="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The &lt;strong&gt;clearScreen&lt;/strong&gt; function (C) &lt;strong&gt;clears the value of the current screen&lt;/strong&gt;, but the &lt;strong&gt;rest of the state remains the same&lt;/strong&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;clearScreen&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;setScreenValue&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&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;These two functions are available &lt;strong&gt;through the same button&lt;/strong&gt;, so we need to have a &lt;strong&gt;boolean variable who manages&lt;/strong&gt; the current &lt;em&gt;state&lt;/em&gt; of the screen (clear or not) at all times, to be able to know &lt;strong&gt;which one of them should be shown as the label&lt;/strong&gt; of the button. That's the reason why this variable is passed to the &lt;em&gt;Keypad&lt;/em&gt; component as a &lt;em&gt;prop&lt;/em&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;isScreenClear&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;screenValue&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&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;h3&gt;
  
  
  3.1.2. Reverse sign function: +/-
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;reverseSign&lt;/strong&gt; function, as its name indicates, &lt;strong&gt;reverses the sign of the screen value&lt;/strong&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;reverseSign&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;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nf"&gt;parseFloat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&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;h4&gt;
  
  
  String? parseFloat?
&lt;/h4&gt;

&lt;p&gt;Well, it's time to mention &lt;strong&gt;how the data is displayed and stored&lt;/strong&gt; in the calculator. Let's bear in mind the following fact:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What we see on &lt;strong&gt;screen&lt;/strong&gt; is a &lt;strong&gt;value&lt;/strong&gt; stored as a &lt;strong&gt;&lt;em&gt;string&lt;/em&gt;&lt;/strong&gt; and the &lt;strong&gt;values with which we operate&lt;/strong&gt; are stored as &lt;strong&gt;&lt;em&gt;float numbers&lt;/em&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You may be wondering why we don't use floats directly on the screen. The answer is because &lt;strong&gt;we could never see something like&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;0.&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;using a float&lt;/strong&gt;. That's only possible by using a &lt;strong&gt;&lt;em&gt;string&lt;/em&gt;&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;As easy as that :) &lt;/p&gt;

&lt;p&gt;So, in this particular case, we are &lt;strong&gt;parsing the screen value&lt;/strong&gt; (currently a &lt;em&gt;string&lt;/em&gt;) into a &lt;strong&gt;&lt;em&gt;float&lt;/em&gt;&lt;/strong&gt; value, then we &lt;strong&gt;reverse its sign&lt;/strong&gt;, and then we &lt;strong&gt;reconvert&lt;/strong&gt; it to &lt;strong&gt;&lt;em&gt;string&lt;/em&gt;&lt;/strong&gt; to show it on screen.&lt;/p&gt;
&lt;h3&gt;
  
  
  3.1.3. Percentage function: %
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;percentage&lt;/strong&gt; function &lt;strong&gt;divides the screen value by 100&lt;/strong&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;percentage&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;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;parseFloat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We're applying the same method to set the new screen value (&lt;strong&gt;retrieve&lt;/strong&gt; the current screen value, &lt;strong&gt;parse&lt;/strong&gt; it to &lt;em&gt;float&lt;/em&gt;, &lt;strong&gt;operate&lt;/strong&gt; with it and &lt;strong&gt;reconvert&lt;/strong&gt; it to &lt;em&gt;string&lt;/em&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1.4. Decimal point function: .
&lt;/h3&gt;

&lt;p&gt;The &lt;strong&gt;addDecimalPoint&lt;/strong&gt; function adds a &lt;em&gt;dot&lt;/em&gt; to &lt;em&gt;visually transform&lt;/em&gt; the current screen number into a float-like number (we're actually operating with &lt;em&gt;floats&lt;/em&gt;, but remember that the screen value is a &lt;em&gt;string&lt;/em&gt; and if we were using a &lt;em&gt;float&lt;/em&gt; value directly, we could never see something like &lt;em&gt;0.&lt;/em&gt; or &lt;em&gt;3.&lt;/em&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;addDecimalPoint&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expectsOperand&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setScreenValue&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.&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="k"&gt;else&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
         &lt;span class="nf"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.&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="nf"&gt;setExpectsOperand&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="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Let's stop for a minute to understand the idea of this function.&lt;/p&gt;

&lt;p&gt;When adding a dot (to let the user know that they can add decimals to the number shown on screen), we need to be a little bit &lt;strong&gt;more cautious than with the rest&lt;/strong&gt; of operations.&lt;/p&gt;

&lt;p&gt;Let's propose these scenarios: &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the calculator is waiting for an operand&lt;/strong&gt;, that is, the next step is adding a second operand (let's say we want the second operand to be &lt;strong&gt;0.5&lt;/strong&gt;), and we &lt;strong&gt;directly press&lt;/strong&gt; on the decimal point key (without pressing a numeric key before), &lt;strong&gt;a 0 should be appended in front of that dot&lt;/strong&gt;. The calculator must not in any case show an operand starting by a dot (&lt;em&gt;.5&lt;/em&gt;, for example).&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;if the calculator isn't waiting for anything else&lt;/strong&gt;, that is, the current state is stable (the screen value is a full operand and makes sense by itself, although we still have the possibility of adding more digits), &lt;strong&gt;a dot will be concatenated&lt;/strong&gt; to the screen value &lt;strong&gt;if and only if there's no other dot in it&lt;/strong&gt;. &lt;strong&gt;Otherwise&lt;/strong&gt;, the screen number will &lt;strong&gt;remain the same&lt;/strong&gt;. A number can't have two decimal parts 😰&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1.5. Delete last digit function: &amp;lt;-
&lt;/h3&gt;

&lt;p&gt;In this calculator prototype, a &lt;strong&gt;button for removing the last digit is not provided&lt;/strong&gt;, so we're going to &lt;strong&gt;emulate such behavior&lt;/strong&gt; by using the &lt;strong&gt;backspace key&lt;/strong&gt; of the keyboard.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that this is &lt;strong&gt;the only one functionality&lt;/strong&gt; that we're going to implement to be used &lt;strong&gt;through the keyboard&lt;/strong&gt;, not number, operator or function keys. For those, we'll be using the &lt;strong&gt;keypad buttons&lt;/strong&gt;, not the keyboard.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This case works quite differently and we need to add &lt;strong&gt;an event listener&lt;/strong&gt; for such purpose. An &lt;strong&gt;event listener is an object&lt;/strong&gt; that listens for an event to happen and &lt;strong&gt;triggers a function&lt;/strong&gt; every time it occurs.&lt;/p&gt;

&lt;p&gt;Let's see the code before going on any further:&lt;/p&gt;

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

&lt;span class="nf"&gt;useEffect&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="nb"&gt;document&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;keydown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;handleKeyDown&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;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;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;keydown&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nx"&gt;handleKeyDown&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="nx"&gt;screenValue&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The event for which the listener waits is a &lt;strong&gt;keyboard key being pressed&lt;/strong&gt;. To specify that behavior, we're passing in the &lt;strong&gt;&lt;em&gt;keydown&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;event type&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When this event occurs, the function &lt;code&gt;handleKeyDown&lt;/code&gt; will be called and its code will be executed.&lt;/p&gt;

&lt;p&gt;Note that we're specifying this event listener within the &lt;strong&gt;&lt;em&gt;useEffect&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;hook&lt;/strong&gt;, which, in addition, is being called &lt;strong&gt;conditionally&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ok, but... Why?&lt;/strong&gt; Well, because we need this function &lt;strong&gt;to be triggered&lt;/strong&gt; every time the &lt;strong&gt;screen value changes&lt;/strong&gt;. That's it 🙂&lt;/p&gt;

&lt;p&gt;Oh, and &lt;strong&gt;don't forget to remove the event listener to avoid odd behaviors&lt;/strong&gt; in your code.&lt;/p&gt;

&lt;p&gt;Let's now take a look at handler for the event:&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;handleKeyDown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&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;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Backspace&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;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nf"&gt;clearLastDigit&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;Note that the handler itself calls another function, which is the one executed to &lt;strong&gt;delete the last entered digit&lt;/strong&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;clearLastDigit&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&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;screenValue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
         &lt;span class="nf"&gt;setScreenValue&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&lt;/span&gt;&lt;span class="dl"&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="nf"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;substring&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="nx"&gt;screenValue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&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;This function, as mentioned right up above, &lt;strong&gt;deletes the last entered digit of the screen value&lt;/strong&gt; if its length is &lt;strong&gt;greater than 1&lt;/strong&gt;. &lt;strong&gt;Otherwise&lt;/strong&gt;, the screen value becomes &lt;strong&gt;zero&lt;/strong&gt; (the screen value &lt;strong&gt;must never be empty&lt;/strong&gt;).&lt;/p&gt;

&lt;p&gt;To carry out this deletion, we'll be calling &lt;strong&gt;the substring method&lt;/strong&gt; from 0 to the &lt;strong&gt;current screen value length minus 1&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.2. Numeric keys
&lt;/h2&gt;

&lt;p&gt;The numeric keys are those keys &lt;strong&gt;containing numbers to operate&lt;/strong&gt; with.&lt;/p&gt;

&lt;p&gt;Every time a numeric key is clicked, the following function is called:&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;handleClickNumericKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;value&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;expectsOperand&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&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="nf"&gt;setExpectsOperand&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="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;else&lt;/span&gt;
      &lt;span class="nf"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nc"&gt;String&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="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;screenValue&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;value&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 done before, let's distinguish between these two scenarios:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the calculator is waiting for an operand&lt;/strong&gt; (this means that there's an ongoing operation), the value we're introducing &lt;strong&gt;will become the current screen value&lt;/strong&gt; and we'll tell the calculator that &lt;strong&gt;it doesn't need to wait for another operand&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If the calculator isn't waiting for a new operand&lt;/strong&gt; (this means there is an ongoing operand which we can keep adding digits to), it just &lt;strong&gt;appends the new digit to the current screen value if&lt;/strong&gt; this one is &lt;strong&gt;not zero&lt;/strong&gt;. &lt;strong&gt;Otherwise&lt;/strong&gt;, the screen value &lt;strong&gt;will be overwritten&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;And, in which cases can the &lt;strong&gt;screen value&lt;/strong&gt; be &lt;strong&gt;zero&lt;/strong&gt;? Well, when the calculator is &lt;strong&gt;at initial state&lt;/strong&gt;, or &lt;strong&gt;after cleaning&lt;/strong&gt; the screen or the stored values, for example.&lt;/p&gt;

&lt;h2&gt;
  
  
  3.3. Operator keys
&lt;/h2&gt;

&lt;p&gt;The operator keys are those that represent &lt;strong&gt;arithmetic operations&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is what happens when we click on an arbitrary operator:&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;handleClickOperator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;operator&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;inputValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseFloat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;screenValue&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;accValue&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setAccValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputValue&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentOperator&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;resultValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;operate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentOperator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;accValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inputValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setAccValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resultValue&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nf"&gt;setScreenValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resultValue&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="nf"&gt;setExpectsOperand&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="nf"&gt;setCurrentOperator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;operator&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;
  
  
  How this function works?
&lt;/h3&gt;

&lt;p&gt;First things first. We need to &lt;strong&gt;store the current screen value parsed to float&lt;/strong&gt; in a constant so we can &lt;strong&gt;operate&lt;/strong&gt; with it.&lt;/p&gt;

&lt;p&gt;Then, we'll check if we &lt;strong&gt;already&lt;/strong&gt; have an &lt;strong&gt;accumulated value&lt;/strong&gt; or not.&lt;/p&gt;

&lt;p&gt;If there's &lt;strong&gt;no accumulated value&lt;/strong&gt; (we just entered the first operand), we'll &lt;strong&gt;set the state&lt;/strong&gt; for it to this new &lt;strong&gt;input value&lt;/strong&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Bear in mind that the &lt;strong&gt;accumulated value is only stored&lt;/strong&gt; when an &lt;strong&gt;operator&lt;/strong&gt; is pressed, not when a &lt;strong&gt;numeric key&lt;/strong&gt; is pressed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Else, if we &lt;strong&gt;already&lt;/strong&gt; have and &lt;strong&gt;accumulated value&lt;/strong&gt; and there's also an &lt;strong&gt;operation going on&lt;/strong&gt; (we just entered the second operand), then we can &lt;strong&gt;operate&lt;/strong&gt;. After the proper operation is done, we'll &lt;strong&gt;assign the result value to the accumulated value and the screen value&lt;/strong&gt; (previously parsed to &lt;em&gt;string&lt;/em&gt; in this case).&lt;/p&gt;

&lt;p&gt;In any case, we need to &lt;strong&gt;store the new operator clicked&lt;/strong&gt; for later and also &lt;strong&gt;tell the calculator to wait for another operand&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;There you have the &lt;strong&gt;operate function&lt;/strong&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;operate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;accValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;inputValue&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;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;operator&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;+&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="nx"&gt;accValue&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;inputValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;-&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="nx"&gt;accValue&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;inputValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;x&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="nx"&gt;accValue&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;inputValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;/&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="nx"&gt;accValue&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nx"&gt;inputValue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;=&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="nx"&gt;inputValue&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;This function receives the &lt;strong&gt;stored operator&lt;/strong&gt;, the &lt;strong&gt;accumulated value&lt;/strong&gt; and the &lt;strong&gt;last screen value&lt;/strong&gt; as parameters and, based on the operator value, a different &lt;strong&gt;operation, which includes the other two values, is performed&lt;/strong&gt; .&lt;/p&gt;

&lt;p&gt;Really easy, right?&lt;/p&gt;




&lt;p&gt;And that's pretty much it! I hope you found this tutorial useful and &lt;strong&gt;don't hesitate to pose any doubts or questions you could have&lt;/strong&gt; related to the tutorial and/or examples above.&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;




&lt;h4&gt;
  
  
  And last but not least... A quick friendly reminder before we go 😊
&lt;/h4&gt;

&lt;p&gt;We all know there are million ways to get things done when it comes to programming and development, and we're here to &lt;strong&gt;help and learn&lt;/strong&gt;, so, if you know another possible way to do what others are sharing (&lt;strong&gt;not better, not worse, just different&lt;/strong&gt;), feel free to share it if you feel like it, but, please, &lt;strong&gt;always be kind and respectful&lt;/strong&gt; with the author and the rest of the community. Thank you!&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>CSS Selectors: The Full Reference Guide 🚀</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Wed, 23 Jun 2021 13:35:26 +0000</pubDate>
      <link>https://dev.to/underscorecode/css-selectors-the-full-reference-guide-3cbf</link>
      <guid>https://dev.to/underscorecode/css-selectors-the-full-reference-guide-3cbf</guid>
      <description>&lt;p&gt;Hello, everybody! 🚀&lt;/p&gt;

&lt;p&gt;Today we'll be covering CSS selectors in depth.&lt;/p&gt;




&lt;h1&gt;
  
  
  Table of contents
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;What is a selector in CSS?&lt;/li&gt;
&lt;li&gt;
Types of selectors

&lt;ul&gt;
&lt;li&gt;Universal selector&lt;/li&gt;
&lt;li&gt;Type selector&lt;/li&gt;
&lt;li&gt;Class selector&lt;/li&gt;
&lt;li&gt;ID selector&lt;/li&gt;
&lt;li&gt;Attribute selector&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Grouping selectors

&lt;ul&gt;
&lt;li&gt;Group selector&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

Combining selectors

&lt;ul&gt;
&lt;li&gt;Descendant combinator&lt;/li&gt;
&lt;li&gt;Child combinator&lt;/li&gt;
&lt;li&gt;General sibling combinator&lt;/li&gt;
&lt;li&gt;Adjacent sibling combinator&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Pseudo-classes&lt;/li&gt;

&lt;li&gt;Pseudo-elements&lt;/li&gt;

&lt;/ul&gt;




&lt;h1&gt;
  
  
  What is a selector in CSS? &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;A CSS selector is a &lt;strong&gt;pattern&lt;/strong&gt; used to &lt;strong&gt;choose the HTML elements&lt;/strong&gt; that we want to &lt;strong&gt;style&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Speaking more technically, CSS selectors are able to &lt;strong&gt;select those HTML elements to which a style ruleset will be applied&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Types of selectors &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Universal selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;*&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by an &lt;strong&gt;asterisk&lt;/strong&gt; (*) and matches &lt;strong&gt;all the elements&lt;/strong&gt; in the HTML document.&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;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Computer Science Eng.&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Mathematics&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Physics&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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="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;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;coral&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 will apply a 1px solid coral border to all elements in the document.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Fpljk80n8hmj0ihv68wdk.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%2Fuploads%2Farticles%2Fpljk80n8hmj0ihv68wdk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The border property shows very well the behavior of this selector. As you can observe in the image above, every element is now surrounded by a border, including the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element and the &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; element. &lt;/p&gt;



&lt;p&gt;The universal selector is also used to &lt;strong&gt;avoid confusion&lt;/strong&gt; and make your code &lt;strong&gt;easier to read&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Let's take a look at the following examples:&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="nd"&gt;:first-child&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="no"&gt;maroon&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;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="nd"&gt;:first-child&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="no"&gt;maroon&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;These two code snippets look both pretty much the same, right?&lt;/p&gt;

&lt;p&gt;Well, we only need to notice the &lt;strong&gt;blank space&lt;/strong&gt; between the type selector and the pseudo-class to realize that they're not exactly the same: the first one selects the first child of every &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element and the second one selects the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; elements that are first children themselves of another element.&lt;/p&gt;

&lt;p&gt;Don't panic yet, we'll be talking more in detail about &lt;strong&gt;pseudo-classes&lt;/strong&gt; and &lt;strong&gt;how selectors work&lt;/strong&gt; later on 🙂&lt;/p&gt;

&lt;p&gt;For now, just keep in mind that in this example there are two different element selectors working together to apply a styling rule. Everything will make sense later. Promise.&lt;/p&gt;

&lt;p&gt;In any case, to distinguish one from the other and being able to see the blank space more clearly, &lt;strong&gt;we can make use of the universal selector&lt;/strong&gt;, as shown below:&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="o"&gt;*&lt;/span&gt;&lt;span class="nd"&gt;:first-child&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="no"&gt;maroon&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;Speaking in terms of functionality, adding an asterisk symbol &lt;strong&gt;does nothing&lt;/strong&gt;, but it's useful to quickly &lt;strong&gt;identify the elements that are going to be targeted&lt;/strong&gt; and to keep your code &lt;strong&gt;neat and tidy&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Type selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elemType&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector matches &lt;strong&gt;all elements that belong to the specified type&lt;/strong&gt;.&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;p&amp;gt;&lt;/span&gt;A paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Another paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;One more paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5rem&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="no"&gt;deeppink&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 will apply a font size of 1.5rem and a deep pink color to all &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements. Easy and direct.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Flajufuf1sxcuqf7qh7v1.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%2Fuploads%2Farticles%2Flajufuf1sxcuqf7qh7v1.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Class selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;.classname&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by a &lt;strong&gt;period&lt;/strong&gt; (.) and matches &lt;strong&gt;all elements that contain the specified class&lt;/strong&gt;.&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&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"deeppink"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a deep pink paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hotpink"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a hot pink paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pink"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a regular pink paragraph&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"deeppink-bg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a paragraph with a deep pink background&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"hotpink-bg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a paragraph with a hot pink background&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pink-bg"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;This is a paragraph with a regular pink background&lt;span class="nt"&gt;&amp;lt;/p&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.deeppink&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="no"&gt;deeppink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.hotpink&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="no"&gt;hotpink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.pink&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="no"&gt;pink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.deeppink-bg&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="no"&gt;deeppink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.hotpink-bg&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="no"&gt;hotpink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.pink-bg&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="no"&gt;pink&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Group selector - Stay until the end to understand its
 behavior 😉 */&lt;/span&gt;
&lt;span class="nc"&gt;.deeppink-bg&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.hotpink-bg&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.pink-bg&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="no"&gt;white&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 will apply a different pink color variant to every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element depending on the class they contain, styling either their text or their background.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Fjcqh7jakxg9aibe7jep4.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%2Fuploads%2Farticles%2Fjcqh7jakxg9aibe7jep4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;Another way to specify a class selector is &lt;strong&gt;by appending the type of the element that contains the classname&lt;/strong&gt; in front of the regular class selector.&lt;/p&gt;

&lt;p&gt;Take a look at this example of a regular list:&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;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"list-item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We could style every &lt;em&gt;list item&lt;/em&gt; 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="nc"&gt;.list-item&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;5px&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;Or 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;li&lt;/span&gt;&lt;span class="nc"&gt;.list-item&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;5px&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;Note that in this specific case it wouldn't be necessary to use this method because all the elements that contain the &lt;em&gt;list-item&lt;/em&gt; class are &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements, so appending the element type wouldn't make any difference .&lt;/p&gt;

&lt;p&gt;But let's have a look at this other example below:&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;section&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;List of animals&lt;span class="nt"&gt;&amp;lt;/h1&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;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Cat&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Dog&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Monkey&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Dolphin&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Frog&lt;span class="nt"&gt;&amp;lt;/p&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;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this example, we have different types of elements referencing the same class, so, in order to apply &lt;strong&gt;different styling rules&lt;/strong&gt; to each of them, &lt;strong&gt;we need to specify the type of the elements&lt;/strong&gt; that contain that class. Otherwise, the elements won't be targeted properly and, consequently, the styles we're trying to apply won't be displayed as expected.&lt;/p&gt;

&lt;p&gt;So we should do something like the following to apply different rules depending on if the element is a heading or a paragraph:&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;h1&lt;/span&gt;&lt;span class="nc"&gt;.big&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;3rem&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="no"&gt;coral&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="nc"&gt;.big&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;2rem&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="no"&gt;orange&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;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Fit9a9k8vsyosjziprhbv.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%2Fuploads%2Farticles%2Fit9a9k8vsyosjziprhbv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. ID selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;#idname&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by a &lt;strong&gt;hash&lt;/strong&gt; symbol (#) and matches &lt;strong&gt;the unique element that contains the specified id&lt;/strong&gt;.&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&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"users-table"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Users&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;John Doe&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Jane Doe&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;table&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"staff-table"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;Staff&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Hannah Legend&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;td&amp;gt;&lt;/span&gt;Daniel Oaks&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/table&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Type selector */&lt;/span&gt;
&lt;span class="nt"&gt;table&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;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* ID selectors */&lt;/span&gt;
&lt;span class="nf"&gt;#users-table&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="no"&gt;black&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="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;#staff-table&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;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&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 will apply a black background color and a white text color to the table that matches the id &lt;em&gt;users-table&lt;/em&gt;, and a 1px solid black border to the table that matches the id &lt;em&gt;staff-table&lt;/em&gt;. Both of them receive a padding of 20px based on their type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Flxf6mgk56mc7bz7xwfc6.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%2Fuploads%2Farticles%2Flxf6mgk56mc7bz7xwfc6.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Even though HTML allows you to assign the same id value to several elements, &lt;strong&gt;you shouldn't ever do it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If you need to apply the same style to a bunch of different elements, &lt;strong&gt;always use the class attribute&lt;/strong&gt;. You'll keep your code clean and will get rid of a possible confusion.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  5. Attribute selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The attribute selector is more complex than the rest of the selectors and has &lt;strong&gt;several syntaxes&lt;/strong&gt; that can be applied to our HTML elements based on which &lt;strong&gt;condition&lt;/strong&gt; should be satisfied by them.&lt;/p&gt;

&lt;p&gt;In other words, it matches &lt;strong&gt;all the HTML elements which contain a specified attribute&lt;/strong&gt; and whose value for that attribute &lt;strong&gt;satisfies a given condition&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Attribute selector syntaxes
&lt;/h3&gt;
&lt;h3&gt;
  
  
  Syntax 1
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements with the &lt;strong&gt;specified attribute&lt;/strong&gt;.&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;nav&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;Home&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;"/blog"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Blog&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;"/contact"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Contact&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;"/about"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;About&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;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Type selector */&lt;/span&gt;
&lt;span class="nt"&gt;nav&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="no"&gt;darkslategray&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;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Attribute selector */&lt;/span&gt;
&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;href&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-decoration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&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 will apply a white color to every &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element that contains the &lt;code&gt;href&lt;/code&gt; attribute, regardless of its value, and removes the underline.&lt;/p&gt;

&lt;p&gt;We're also styling the &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; element with a background color and some padding by making use of the type selector.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Fgv6kb7j9gqb0bshhrft3.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%2Fuploads%2Farticles%2Fgv6kb7j9gqb0bshhrft3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax 2
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; is exactly&lt;/strong&gt;  &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;.&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;form&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Username&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&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;"username"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Username"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Password&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&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;"password"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"password"&lt;/span&gt; &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Password"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"text"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;chocolate&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 will apply a chocolate text color to every &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; element that has the &lt;code&gt;type&lt;/code&gt; attribute with an exact value of &lt;em&gt;text&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2F98clr2noel3w93i126t4.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%2Fuploads%2Farticles%2F98clr2noel3w93i126t4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;We could as well use this syntax to &lt;strong&gt;emulate the ID selector&lt;/strong&gt; (remember the example in section 4):&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="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"users-table"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;black&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="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;"staff-table"&lt;/span&gt;&lt;span class="o"&gt;]&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;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&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;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; By using this attribute selector syntax, we are targeting elements that contain an &lt;em&gt;id&lt;/em&gt; attribute whose value is exactly &lt;em&gt;users-table&lt;/em&gt; or &lt;em&gt;staff-table&lt;/em&gt;. We're using this one syntax because an element can only have one &lt;em&gt;idname&lt;/em&gt;, so the value needs to be exact (=).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Syntax 3
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr~=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; is a list of words separated by blanks and one of them is exactly&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;.&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;p&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en-gb en-us en-ca en-au en-nz"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Welcome!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"fr-fr fr-ca fr-be"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Bienvenue!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;~=&lt;/span&gt;&lt;span class="s1"&gt;"en-us"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;navy&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;~=&lt;/span&gt;&lt;span class="s1"&gt;"fr-fr"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;red&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 will apply a navy color to every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element whose value for &lt;code&gt;lang&lt;/code&gt; is a list that contains the exact string &lt;em&gt;en-us&lt;/em&gt;. Same for all &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements whose value for &lt;code&gt;lang&lt;/code&gt; contains &lt;em&gt;fr-fr&lt;/em&gt;, applying a red color in this case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2F0qn0t4xfsmcp08kgjcwq.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%2Fuploads%2Farticles%2F0qn0t4xfsmcp08kgjcwq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;As well as the previous syntax, through which we could emulate the ID selector behavior, we can also use this one attribute syntax to &lt;strong&gt;emulate the behavior of the class selector&lt;/strong&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="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;~=&lt;/span&gt;&lt;span class="s1"&gt;"list-item"&lt;/span&gt;&lt;span class="o"&gt;]&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;5px&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;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt; By using this attribute selector syntax, we are targeting elements that have a &lt;em&gt;class&lt;/em&gt; attribute whose value is a list that contains the string &lt;em&gt;list-item&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;We're using this specific syntax because an element can contain several classes and we're aiming at just one of them (~=). But even though the element had just one class, &lt;strong&gt;the value for the class attribute always acts like a list of values&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Syntax 4
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr|=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; is exactly&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;or starts with&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;followed by a hyphen&lt;/strong&gt;.&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;p&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en-us"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en-gb"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;|=&lt;/span&gt;&lt;span class="s1"&gt;"en"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;cornflowerblue&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="no"&gt;antiquewhite&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 will apply a cornflower blue background color and an antique white text color to every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element that has a &lt;code&gt;lang&lt;/code&gt; attribute whose value is exactly &lt;em&gt;en&lt;/em&gt; or starts with &lt;em&gt;en-&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2F4hs7uwkhop6l34ae1ibe.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%2Fuploads%2Farticles%2F4hs7uwkhop6l34ae1ibe.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax 5
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr^=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; starts with&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;.&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;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#list1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Go to list 1&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#list2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Go to list 2&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Lists&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"list1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;List 1&lt;span class="nt"&gt;&amp;lt;/h1&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;Milk&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Butter&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Eggs&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Sugar&lt;span class="nt"&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;/div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"list2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;List 2&lt;span class="nt"&gt;&amp;lt;/h1&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;Oranges&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Lemons&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Strawberries&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Apples&lt;span class="nt"&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;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;href&lt;/span&gt;&lt;span class="o"&gt;^=&lt;/span&gt;&lt;span class="s1"&gt;"#"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;crimson&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;2rem&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 will apply a crimson color and a font size of 2rem to every &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element that has a &lt;code&gt;href&lt;/code&gt; attribute whose value starts with &lt;em&gt;#&lt;/em&gt;.&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Fej7ue7fvtvm7ml5cojma.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%2Fuploads%2Farticles%2Fej7ue7fvtvm7ml5cojma.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax 6
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr$=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; ends with&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;.&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;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"css-selectors-guide.pdf"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;CSS Selectors Guide&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;href&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;".pdf"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;slateblue&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 will apply a slate blue color to every &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element that has a &lt;code&gt;href&lt;/code&gt; attribute whose value ends with &lt;em&gt;.pdf&lt;/em&gt;.&lt;br&gt;
&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Fvemqc0qkwnfbeacap4xr.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%2Fuploads%2Farticles%2Fvemqc0qkwnfbeacap4xr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Syntax 7
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;[attr*=value]&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;Matches elements whose &lt;strong&gt;value for &lt;em&gt;attr&lt;/em&gt; contains at least one occurrence of&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;value&lt;/em&gt;&lt;/strong&gt;.&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;"small-box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a small box&lt;span class="nt"&gt;&amp;lt;/p&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&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"big-box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a big box&lt;span class="nt"&gt;&amp;lt;/p&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;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="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;class&lt;/span&gt;&lt;span class="o"&gt;*=&lt;/span&gt;&lt;span class="s1"&gt;"box"&lt;/span&gt;&lt;span class="o"&gt;]&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="no"&gt;burlywood&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 will apply a burlywood background color to every &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; element that contains a &lt;code&gt;class&lt;/code&gt; attribute whose value has at least one occurrence of the string &lt;em&gt;box&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Fv9ocd7x3jzxr5hc15chv.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%2Fuploads%2Farticles%2Fv9ocd7x3jzxr5hc15chv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Grouping selectors &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;Grouping selectors in CSS is basically used to &lt;strong&gt;put together&lt;/strong&gt; those elements of different type or with different id/classes that we want to apply the &lt;strong&gt;same style properties&lt;/strong&gt; to.&lt;/p&gt;

&lt;p&gt;Additionally, by using this technique, we'll get rid of redundancy and our code will be &lt;strong&gt;clean&lt;/strong&gt;, &lt;strong&gt;concise&lt;/strong&gt; and &lt;strong&gt;organized&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Group selector &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem1, ..., elemN&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by a &lt;strong&gt;comma&lt;/strong&gt; (,) and matches &lt;strong&gt;all the elements stated in the list&lt;/strong&gt; and applies the same ruleset to all of them.&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;h1&amp;gt;&lt;/span&gt;Computer Science Engineering&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;List of courses&lt;span class="nt"&gt;&amp;lt;/h2&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;Algebra&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Calculus&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Physics&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Discrete Mathematics&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Introduction to Programming&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;li&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="no"&gt;darkred&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 will apply a dark red color to every &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2F3hvbszl13m7vfy7f1uvm.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%2Fuploads%2Farticles%2F3hvbszl13m7vfy7f1uvm.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Combining selectors &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;CSS selectors can also be combined. By combining selectors, then we can define &lt;strong&gt;CSS combinators&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;CSS combinators are used to &lt;strong&gt;establish a relationship between different selectors&lt;/strong&gt; and are very useful to make your element selection &lt;strong&gt;more targeted&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Descendant combinator &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem1 elem2&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This combinator is represented by a &lt;strong&gt;single space&lt;/strong&gt; ( ) and matches &lt;strong&gt;all &lt;em&gt;elem2&lt;/em&gt; that are descendants of&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;elem1&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Consider the following navigation:&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;nav&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&amp;gt;&lt;/span&gt;Home&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;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;a&amp;gt;&lt;/span&gt;People&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&amp;gt;&lt;/span&gt;Students&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;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;a&amp;gt;&lt;/span&gt;Faculty members&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;a&amp;gt;&lt;/span&gt;Discrete Mathematics&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&amp;gt;&lt;/span&gt;Programming&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&amp;gt;&lt;/span&gt;Physics&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;a&amp;gt;&lt;/span&gt;Algorithms&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;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&amp;gt;&lt;/span&gt;Staff members&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;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&amp;gt;&lt;/span&gt;About&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&amp;gt;&lt;/span&gt;Contact&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;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="nt"&gt;a&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;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;crimson&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="no"&gt;darkslateblue&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;1.5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;bold&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 will apply a 1px solid crimson border, a dark slate blue color, a font size of 1.5rem and a bold font weight to every &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; element that is descendant of a &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt; element, &lt;strong&gt;regardless of how nested they are&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2F2p6xm0nqrlni7anhvark.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%2Fuploads%2Farticles%2F2p6xm0nqrlni7anhvark.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  2. Child combinator &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem1 &amp;gt; elem2&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This combinator is represented by a &lt;strong&gt;prompt&lt;/strong&gt; (&amp;gt;) and matches &lt;strong&gt;all &lt;em&gt;elem2&lt;/em&gt; that are direct children of&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;elem1&lt;/em&gt;&lt;/strong&gt;.&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;"box"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;This is a direct child of .box&lt;span class="nt"&gt;&amp;lt;/p&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;p&amp;gt;&lt;/span&gt;This is not a direct child of .box&lt;span class="nt"&gt;&amp;lt;/p&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;p&amp;gt;&lt;/span&gt;This is another direct child of .box&lt;span class="nt"&gt;&amp;lt;/p&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.box&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&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="no"&gt;darkgoldenrod&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 will apply a dark golden color to every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element that is a direct child of any element that has the class &lt;em&gt;box&lt;/em&gt;, so, in this HTML example, the first and last &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements will be selected, but not the one in the middle.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&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%2Fuploads%2Farticles%2Fhpmqn5iqgv3iob6w0bds.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%2Fuploads%2Farticles%2Fhpmqn5iqgv3iob6w0bds.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3. General sibling combinator &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem1 ~ elem2&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This combinator is represented by a &lt;strong&gt;tilde&lt;/strong&gt; (~) and matches &lt;strong&gt;all &lt;em&gt;elem2&lt;/em&gt; that are siblings to&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;elem1&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;and come after it&lt;/strong&gt;.&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;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"blue-mug.jpeg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"a regular blue coffee mug"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Blue mug&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Price: $15&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="o"&gt;~&lt;/span&gt; &lt;span class="nt"&gt;p&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="no"&gt;darkblue&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 will apply a dark blue color to every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element which is a sibling of any &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element and comes after it. In this example, both &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements will be selected.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Ffzd07tw58z4i6dwq725o.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%2Fuploads%2Farticles%2Ffzd07tw58z4i6dwq725o.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  4. Adjacent sibling combinator &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem1 + elem2&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This combinator is represented by a &lt;strong&gt;plus&lt;/strong&gt; symbol (+) and matches &lt;strong&gt;all &lt;em&gt;elem2&lt;/em&gt; that are siblings to&lt;/strong&gt; &lt;strong&gt;&lt;em&gt;elem1&lt;/em&gt;&lt;/strong&gt; &lt;strong&gt;and appear immediately after it&lt;/strong&gt;.&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;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"blue-mug.jpeg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"a regular blue coffee mug"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Blue mug&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;Price: $15&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nt"&gt;p&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="no"&gt;darkblue&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;In this case, only the first &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element will be selected, since the second one doesn't appear immediately after the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2F6he4xnv2xj565trggu7p.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%2Fuploads%2Farticles%2F6he4xnv2xj565trggu7p.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Pseudo-classes &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;A CSS pseudo-class is a keyword that is added to a selector and &lt;strong&gt;defines a special state&lt;/strong&gt; of the selected elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem:pseudo-class&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by a &lt;strong&gt;colon&lt;/strong&gt; (:).&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;h1&amp;gt;&lt;/span&gt;Shopping list&lt;span class="nt"&gt;&amp;lt;/h1&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;Milk&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Butter&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Eggs&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Sugar&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;li&lt;/span&gt;&lt;span class="nd"&gt;:hover&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="no"&gt;black&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="no"&gt;white&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;In this example, we're applying a black background color and a white text color to every &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element when the cursor hovers over it.&lt;/p&gt;

&lt;p&gt;Take a look at what happens when we hover over the &lt;em&gt;Butter&lt;/em&gt; element:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2Fkadphf9gvfhu0hab6vlc.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%2Fuploads%2Farticles%2Fkadphf9gvfhu0hab6vlc.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of the &lt;strong&gt;most common CSS pseudo-classes&lt;/strong&gt; are:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:active&lt;/code&gt;, &lt;code&gt;:hover&lt;/code&gt;, &lt;code&gt;:focus&lt;/code&gt;, &lt;code&gt;:disabled&lt;/code&gt;, &lt;code&gt;:checked&lt;/code&gt;, &lt;code&gt;:first-child&lt;/code&gt;, &lt;code&gt;:nth-child&lt;/code&gt;, &lt;code&gt;:first-of-type&lt;/code&gt;.&lt;/p&gt;
&lt;h1&gt;
  
  
  Pseudo-elements &lt;a&gt;&lt;/a&gt;
&lt;/h1&gt;

&lt;p&gt;A CSS pseudo-element is a keyword that is added to a selector to &lt;strong&gt;style a specific part&lt;/strong&gt; of the selected elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax:&lt;/strong&gt; &lt;em&gt;elem:pseudo-element&lt;/em&gt; { style properties }&lt;/p&gt;

&lt;p&gt;This selector is represented by a &lt;strong&gt;double colon&lt;/strong&gt; (::).&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;p&amp;gt;&lt;/span&gt;CODE&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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="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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In this example, we're appending an underscore symbol in front of every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Output:&lt;/strong&gt;&lt;br&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%2Fuploads%2Farticles%2F7p6dm0v4obsehzpedvf8.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%2Fuploads%2Farticles%2F7p6dm0v4obsehzpedvf8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of the &lt;strong&gt;most common CSS pseudo-elements&lt;/strong&gt; are:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;::after&lt;/code&gt; (can also be written as &lt;code&gt;:after&lt;/code&gt;), &lt;code&gt;::before&lt;/code&gt; (can also be written as &lt;code&gt;:before&lt;/code&gt;), &lt;code&gt;::marker&lt;/code&gt;, &lt;code&gt;::placeholder&lt;/code&gt;, &lt;code&gt;::first-letter&lt;/code&gt;.&lt;/p&gt;



&lt;p&gt;And that's pretty much it 🙂&lt;/p&gt;

&lt;p&gt;I hope this reference guide has been helpful for you.&lt;/p&gt;

&lt;p&gt;You can also check out the following related posts about CSS selectors on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;@underscorecode&lt;/a&gt; Instagram account:&lt;/p&gt;


&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CP8znDHsMmV/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;

&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CQErX0PMe1I/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;

&lt;div class="instagram-position"&gt;
  &lt;iframe id="instagram-liquid-tag" src="https://www.instagram.com/p/CQWagoQsEdV/embed/captioned/"&gt;
  &lt;/iframe&gt;
  
&lt;/div&gt;






&lt;p&gt;🎉 Don't forget to follow &lt;a class="mentioned-user" href="https://dev.to/underscorecode"&gt;@underscorecode&lt;/a&gt; on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more daily webdev content 🖥🖤&lt;/p&gt;

</description>
      <category>css</category>
      <category>webdev</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What's new in Next.js 11?</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Fri, 18 Jun 2021 12:35:29 +0000</pubDate>
      <link>https://dev.to/underscorecode/what-s-new-in-next-js-11-405n</link>
      <guid>https://dev.to/underscorecode/what-s-new-in-next-js-11-405n</guid>
      <description>&lt;p&gt;On June 15, the Next.js Conf 2021 was held and brought with it the introduction of &lt;strong&gt;Next.js 11&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This new version of the framework brings associated some new features that we'll be discussing in this article.&lt;/p&gt;

&lt;p&gt;Worth to mention that the team put a lot of emphasis on the balance &lt;strong&gt;DX-UX&lt;/strong&gt; (developer experience-end user experience) and also the great performance results they're achieving with every new version of Next.js.&lt;/p&gt;

&lt;p&gt;After this brief intro, let's dive into the new features of Next.js 11:&lt;/p&gt;

&lt;h1&gt;
  
  
  Conformance
&lt;/h1&gt;

&lt;p&gt;Conformance is a new system added to Next.js 11 that provides developers with &lt;strong&gt;guidance and standards&lt;/strong&gt; to implement &lt;strong&gt;best optimization practices&lt;/strong&gt; when coding.&lt;/p&gt;

&lt;p&gt;This is really useful to avoid having to memorize every single rule for optimal loading performance of your code.&lt;/p&gt;

&lt;p&gt;Also, Next.js 11 now supports &lt;strong&gt;ESLint&lt;/strong&gt; for framework-related issues, contributing to a better developer experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx next lint
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Script optimization
&lt;/h1&gt;

&lt;p&gt;For script optimization purposes, in this new version of Next.js, a new type of component has been released: &lt;strong&gt;the script component&lt;/strong&gt;, which allows developers to &lt;strong&gt;prioritize&lt;/strong&gt; the loading of &lt;strong&gt;third party scripts&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, we developers struggle deciding where to place our scripts in order for them to be loaded and executed properly.&lt;/p&gt;

&lt;p&gt;With this new script component, we can set the priority of scripts through the prop &lt;strong&gt;&lt;em&gt;strategy&lt;/em&gt;&lt;/strong&gt;, to which we can pass three different values for three different kinds of strategies:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;beforeInteractive&lt;/code&gt;: For scripts that need to be retrieved and executed &lt;strong&gt;before&lt;/strong&gt; the page is interactive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;afterInteractive&lt;/code&gt;: For scripts that can be retrieved and executed &lt;strong&gt;after&lt;/strong&gt; the page is interactive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;lazyOnload&lt;/code&gt;: For scripts that &lt;strong&gt;can wait&lt;/strong&gt; to load &lt;strong&gt;at&lt;/strong&gt; idle time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Script&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;next/script&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Script&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;auth.js&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;strategy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;beforeInteractive&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Image improvements
&lt;/h1&gt;

&lt;p&gt;With Next.js 10, a new component for image optimization was introduced, since images traditionally take up a lot of space on web apps and this often results in poor performance.&lt;/p&gt;

&lt;p&gt;The  component has now &lt;strong&gt;a couple of new functionalities&lt;/strong&gt; for even a better image optimization.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using &lt;em&gt;import&lt;/em&gt; to add images
&lt;/h3&gt;

&lt;p&gt;This method automatically calculates and assigns &lt;strong&gt;width and height&lt;/strong&gt; values to static images that are part of our project repository. This helps reduce the &lt;strong&gt;cumulative layout shift&lt;/strong&gt;, a measure that sums all &lt;strong&gt;layout shifts&lt;/strong&gt; on a webpage, that is, those changes in visible elements that aren't caused by user interaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&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="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;landscape&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;../public/images/landscape.png&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Image&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;landscape&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Beautiful landscape of mountains&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Placeholder
&lt;/h3&gt;

&lt;p&gt;When a user visits a webpage for the very first time, large images can take a while to load (especially when using a slow internet connection). This can result in a temporary blank space until the image appears.&lt;/p&gt;

&lt;p&gt;To avoid this behavior, a new &lt;strong&gt;&lt;em&gt;placeholder&lt;/em&gt;&lt;/strong&gt; prop for the image component has been introduced in this new version of Next.js. We can use this prop to ease the transition, which will show a blurry version of the image until this is fully loaded.&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%2Fuploads%2Farticles%2Fp6o5z6snfta6o65u2qi7.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%2Fuploads%2Farticles%2Fp6o5z6snfta6o65u2qi7.gif" alt="Black t-shirt on a blue background going from blur to clear"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Image source: nextjs.org&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&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;Image&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;landscape&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"blur"&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"Beautiful landscape of mountains"&lt;/span&gt;  &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Webpack 5
&lt;/h1&gt;

&lt;p&gt;As of version 10.2, Webpack 5 became the &lt;strong&gt;default bundler&lt;/strong&gt; for Next.js applications, but in order to use it, it was necessary to add a flag in &lt;code&gt;next.config.js&lt;/code&gt; to specify the version of Webpack we were going to work with.&lt;/p&gt;

&lt;p&gt;With Next.js 11, you &lt;strong&gt;don't need any extra configuration&lt;/strong&gt; to set Webpack 5 as your application bundler. It is automatically ready to use right out of the box.&lt;/p&gt;

&lt;h1&gt;
  
  
  Next Live
&lt;/h1&gt;

&lt;p&gt;Definitely one of the most important features of Next.js 11. Next Live basically means &lt;strong&gt;team collaboration in real time&lt;/strong&gt;. It allows collaborators to share, comment and edit code within the browser itself from anywhere in the world, by just sharing a URL, without a previous build step, which makes the process fast and efficient.&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%2Fuploads%2Farticles%2Fylhu72z265suqs49u7ku.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%2Fuploads%2Farticles%2Fylhu72z265suqs49u7ku.png" alt="Browser window that shows the new Next.js collaborative environment with the code editor on the left and the rendered page on the right, in addition to all members that are collaborating in real time"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another point in favor is that it also provides &lt;strong&gt;offline access&lt;/strong&gt; to let the team work on the project when they don't have internet connection.&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%2Fuploads%2Farticles%2F157yuncnol7sdi7qt7f2.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%2Fuploads%2Farticles%2F157yuncnol7sdi7qt7f2.png" alt="Collaborative bar that shows connected team members with different colors and buttons for code, draw and chat actions"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Images source: nextjs.org&lt;/em&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  CRA Migration
&lt;/h1&gt;

&lt;p&gt;With this new feature, every &lt;strong&gt;Create React App application is now Next.js compatible&lt;/strong&gt; by just running the tool &lt;code&gt;@next/codemod&lt;/code&gt;. By doing this, a &lt;strong&gt;/pages&lt;/strong&gt; directory is automatically created within the project and &lt;strong&gt;CSS imports&lt;/strong&gt; are relocated to their proper location.&lt;/p&gt;

&lt;p&gt;This feature is &lt;strong&gt;still experimental&lt;/strong&gt; and it wasn't mentioned in the conference, but it appears on the Next.js related docs.&lt;/p&gt;
&lt;h1&gt;
  
  
  Improved performance
&lt;/h1&gt;

&lt;p&gt;The performance of the framework was also highly emphasized: the &lt;strong&gt;startup time&lt;/strong&gt; has been improved &lt;strong&gt;by up to 24%&lt;/strong&gt; and &lt;strong&gt;processing time for changes&lt;/strong&gt; has been cut off &lt;strong&gt;by up to 40%&lt;/strong&gt; as of Next.js 10.&lt;/p&gt;

&lt;p&gt;Besides, Next.js 11 also includes a new implementation of Webpack's Babel loader to keep reducing the startup time.&lt;/p&gt;



&lt;p&gt;To take advantage of all these new features, we just have to keep Next.js updated, by running 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 i next@latest react@latest react-dom@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;And that's all for today 🙂&lt;/p&gt;

&lt;p&gt;I hope this article has been helpful for you and I'll see you all in the next.&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow me on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more related content.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>60+ VSCode themes you definitely need to try (dark + light)</title>
      <dc:creator>_CODE</dc:creator>
      <pubDate>Tue, 15 Jun 2021 13:42:15 +0000</pubDate>
      <link>https://dev.to/underscorecode/60-vscode-themes-you-definitely-need-to-try-dark-light-3mg5</link>
      <guid>https://dev.to/underscorecode/60-vscode-themes-you-definitely-need-to-try-dark-light-3mg5</guid>
      <description>&lt;p&gt;Hello, everybody!&lt;/p&gt;

&lt;p&gt;I don't know about you, but I'm personally a huge fan of changing my VSCode theme every once in a while, mainly for productivity reasons.&lt;/p&gt;

&lt;p&gt;So today I bring a list of &lt;strong&gt;more than 60 themes&lt;/strong&gt; for you to try and test.&lt;/p&gt;

&lt;p&gt;Check them out and tell me about your favorites in comments below 🙂&lt;/p&gt;




&lt;h2&gt;
  
  
  1. &lt;a href="https://marketplace.visualstudio.com/items?itemName=Endormi.2077-theme" rel="noopener noreferrer"&gt;2077&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F55mrtvbn340nbu417rnp.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%2Fuploads%2Farticles%2F55mrtvbn340nbu417rnp.png" alt="React code snippet with the 2077 theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=mrpbennett.atlantic-night" rel="noopener noreferrer"&gt;Atlantic Night&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  2. Atlantic Night
&lt;/h2&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%2Fuploads%2Farticles%2Foqcucr65os6g0x1vxmqa.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%2Fuploads%2Farticles%2Foqcucr65os6g0x1vxmqa.png" alt="React code snippet with the Atlantic Night theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Atlantic Night Abyss
&lt;/h2&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%2Fuploads%2Farticles%2Fxyma18vsxp6jzinxwwe5.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%2Fuploads%2Farticles%2Fxyma18vsxp6jzinxwwe5.png" alt="React code snippet with the Atlantic Night Abyss theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=inci-august.august-themes" rel="noopener noreferrer"&gt;August&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  4. August - Ariake Dark
&lt;/h2&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%2Fuploads%2Farticles%2Fuhrwwjkcq2ybr8fppbao.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%2Fuploads%2Farticles%2Fuhrwwjkcq2ybr8fppbao.png" alt="React code snippet with the August - Ariake Dark theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. August - City Lights Darker
&lt;/h2&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%2Fuploads%2Farticles%2Fvuapnukqlf7rhqbbqrga.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%2Fuploads%2Farticles%2Fvuapnukqlf7rhqbbqrga.png" alt="React code snippet with the August - City Lights Darker theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. August - Dark
&lt;/h2&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%2Fuploads%2Farticles%2Fq2fvzmyczmorb89x40j1.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%2Fuploads%2Farticles%2Fq2fvzmyczmorb89x40j1.png" alt="React code snippet with the August - Dark theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. August - Dawbridge
&lt;/h2&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%2Fuploads%2Farticles%2Fmn5rhbnin6b0kb8glmpz.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%2Fuploads%2Farticles%2Fmn5rhbnin6b0kb8glmpz.png" alt="React code snippet with the August - Dawbridge theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. August - In Bed By 7pm
&lt;/h2&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%2Fuploads%2Farticles%2Fcx7z3e2pxyij74s6ff9r.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%2Fuploads%2Farticles%2Fcx7z3e2pxyij74s6ff9r.png" alt="React code snippet with the August - In Bed By 7pm theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. August - In Bed By 7pm Darker
&lt;/h2&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%2Fuploads%2Farticles%2Fmwlrlv3gsqla8z5dx9bm.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%2Fuploads%2Farticles%2Fmwlrlv3gsqla8z5dx9bm.png" alt="React code snippet with the August - In Bed By 7pm Darker theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. August - Night Owl
&lt;/h2&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%2Fuploads%2Farticles%2F6bb2ujcbi3zs08xzcrsf.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%2Fuploads%2Farticles%2F6bb2ujcbi3zs08xzcrsf.png" alt="React code snippet with the August - Night Owl theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  11. August - Nord (Darker)
&lt;/h2&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%2Fuploads%2Farticles%2F36wvb62e1432394sqn9r.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%2Fuploads%2Farticles%2F36wvb62e1432394sqn9r.png" alt="React code snippet with the August - Nord (Darker)theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  12. &lt;a href="https://marketplace.visualstudio.com/items?itemName=marqu3s.aurora-x" rel="noopener noreferrer"&gt;Aurora X&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F1k98bagzgn4l2qazlnsv.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%2Fuploads%2Farticles%2F1k98bagzgn4l2qazlnsv.png" alt="React code snippet with the Aurora X theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=teabyii.ayu" rel="noopener noreferrer"&gt;Ayu&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  13. Ayu - Mirage
&lt;/h2&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%2Fuploads%2Farticles%2F1tvaprgboq89yv2rh017.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%2Fuploads%2Farticles%2F1tvaprgboq89yv2rh017.png" alt="React code snippet with the Ayu - Mirage theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  14. Ayu - Light
&lt;/h2&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%2Fuploads%2Farticles%2Fu25wbawcgpdjr9r9ooyp.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%2Fuploads%2Farticles%2Fu25wbawcgpdjr9r9ooyp.png" alt="React code snippet with the Ayu - Light theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=AndrsDC.base16-themes" rel="noopener noreferrer"&gt;Base16&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  15. Base 16 - Dark Ashes
&lt;/h2&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%2Fuploads%2Farticles%2Fcbi9g2z9tqn7go8wyzm4.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%2Fuploads%2Farticles%2Fcbi9g2z9tqn7go8wyzm4.png" alt="React code snippet with the Base16 - Dark Ashes theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  16. Base 16 - Dark Mocha
&lt;/h2&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%2Fuploads%2Farticles%2Fzaj1r774a6oc93975dqv.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%2Fuploads%2Farticles%2Fzaj1r774a6oc93975dqv.png" alt="React code snippet with the Base16 - Dark Mocha theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  17. Base 16 - Dark Ocean
&lt;/h2&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%2Fuploads%2Farticles%2Fopjk6z8dynat77admomy.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%2Fuploads%2Farticles%2Fopjk6z8dynat77admomy.png" alt="React code snippet with the Base16 - Dark Ocean theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  18. Base 16 - Dark Twilight
&lt;/h2&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%2Fuploads%2Farticles%2Fwjmu390f6vivso5nm9ri.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%2Fuploads%2Farticles%2Fwjmu390f6vivso5nm9ri.png" alt="React code snippet with the Base16 - Dark Twilight theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  19. Base 16 - Unikitty
&lt;/h2&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%2Fuploads%2Farticles%2Fsn3krfz4xkpsx3uizgcl.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%2Fuploads%2Farticles%2Fsn3krfz4xkpsx3uizgcl.png" alt="React code snippet with the Base16 - Unikitty theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  20. Base 16 - Light Mocha
&lt;/h2&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%2Fuploads%2Farticles%2Feeqwutevhczf99w0505v.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%2Fuploads%2Farticles%2Feeqwutevhczf99w0505v.png" alt="React code snippet with the Base16 - Light Mocha theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  21. Base 16 - Light Pop
&lt;/h2&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%2Fuploads%2Farticles%2F39zu5z3leg2pufaum3xa.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%2Fuploads%2Farticles%2F39zu5z3leg2pufaum3xa.png" alt="React code snippet with the Base16 - Light Pop theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  22. Base 16 - Light Tomorrow
&lt;/h2&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%2Fuploads%2Farticles%2Fay4x5v3ovmvfqd7vit7l.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%2Fuploads%2Farticles%2Fay4x5v3ovmvfqd7vit7l.png" alt="React code snippet with the Base16 - Light Tomorrow theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  23. &lt;a href="https://marketplace.visualstudio.com/items?itemName=dahong.theme-bear" rel="noopener noreferrer"&gt;Bear Theme&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F2spil373ovjx3l78jja0.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%2Fuploads%2Farticles%2F2spil373ovjx3l78jja0.png" alt="React code snippet with the Bear theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=BeardedBear.beardedtheme" rel="noopener noreferrer"&gt;Bearded theme&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  24. Bearded Theme - Arc Blueberry
&lt;/h2&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%2Fuploads%2Farticles%2Fs4i3ckural89fa1sn8yi.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%2Fuploads%2Farticles%2Fs4i3ckural89fa1sn8yi.png" alt="React code snippet with the Bearded - Arc Blueberry theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  25. Bearded Theme - Surprising Blueberry
&lt;/h2&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%2Fuploads%2Farticles%2F9zty0bxqdqtt5af4fjnd.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%2Fuploads%2Farticles%2F9zty0bxqdqtt5af4fjnd.png" alt="React code snippet with the Bearded - Surprising Blueberry theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  26. Bearded Theme - Monokai Light
&lt;/h2&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%2Fuploads%2Farticles%2Fco5hh4mb8fc3v59cw4qg.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%2Fuploads%2Farticles%2Fco5hh4mb8fc3v59cw4qg.png" alt="React code snippet with the Bearded - Monokai Light theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  27. &lt;a href="https://marketplace.visualstudio.com/items?itemName=Yummygum.city-lights-theme" rel="noopener noreferrer"&gt;City lights&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Faopn91yn13i40koux2fr.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%2Fuploads%2Farticles%2Faopn91yn13i40koux2fr.png" alt="React code snippet with the City Lights theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  28. &lt;a href="https://marketplace.visualstudio.com/items?itemName=dline.CobaltNext" rel="noopener noreferrer"&gt;Cobalt Next - Dark&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F0vl5lqz9euqtwdzzo2sn.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%2Fuploads%2Farticles%2F0vl5lqz9euqtwdzzo2sn.png" alt="React code snippet with the Cobalt Next - Dark theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  29. &lt;a href="https://marketplace.visualstudio.com/items?itemName=wesbos.theme-cobalt2" rel="noopener noreferrer"&gt;Cobalt 2&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fvymygxzlszx1kdqth5g8.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%2Fuploads%2Farticles%2Fvymygxzlszx1kdqth5g8.png" alt="React code snippet with the Cobalt 2 theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  30. &lt;a href="https://marketplace.visualstudio.com/items?itemName=Sujan.code-blue" rel="noopener noreferrer"&gt;Code Blue&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fyb2uuji8do91a15ttwpz.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%2Fuploads%2Farticles%2Fyb2uuji8do91a15ttwpz.png" alt="React code snippet with the Code Blue theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=sldobri.bunker" rel="noopener noreferrer"&gt;Dobri Next&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  31. Dobri Next - C05 - Electron
&lt;/h2&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%2Fuploads%2Farticles%2F7n3zsjqxtcsqii6tkpqd.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%2Fuploads%2Farticles%2F7n3zsjqxtcsqii6tkpqd.png" alt="React code snippet with the Dobri Next - C05 - Electron theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  32. Dobri Next - C09 - Eve
&lt;/h2&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%2Fuploads%2Farticles%2Ffxavc2zcjusbcm8zpu6z.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%2Fuploads%2Farticles%2Ffxavc2zcjusbcm8zpu6z.png" alt="React code snippet with the Dobri Next - C09 - Eve theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  33. &lt;a href="https://marketplace.visualstudio.com/items?itemName=dracula-theme.theme-dracula" rel="noopener noreferrer"&gt;Dracula&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F1mqxz7ub8nkb6fcxftfi.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%2Fuploads%2Farticles%2F1mqxz7ub8nkb6fcxftfi.png" alt="React code snippet with the Dracula theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  34. &lt;a href="https://marketplace.visualstudio.com/items?itemName=bceskavich.theme-dracula-at-night" rel="noopener noreferrer"&gt;Dracula At Night&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fycnrdwd8ugu96307740q.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%2Fuploads%2Farticles%2Fycnrdwd8ugu96307740q.png" alt="React code snippet with the Dracula At Night theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  35. &lt;a href="https://marketplace.visualstudio.com/items?itemName=kuscamara.electron" rel="noopener noreferrer"&gt;Electron&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fihcxe4jaemwl7ujpzvfz.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%2Fuploads%2Farticles%2Fihcxe4jaemwl7ujpzvfz.png" alt="React code snippet with the Electron theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  36. &lt;a href="https://marketplace.visualstudio.com/items?itemName=brittanychiang.halcyon-vscode" rel="noopener noreferrer"&gt;Halcyon&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Frvlgz5xjr2foduuj5gnw.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%2Fuploads%2Farticles%2Frvlgz5xjr2foduuj5gnw.png" alt="React code snippet with the Halcyon theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=jolaleye.horizon-theme-vscode" rel="noopener noreferrer"&gt;Horizon&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  37. Horizon
&lt;/h2&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%2Fuploads%2Farticles%2F7dyhge8hptgebue2yj7h.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%2Fuploads%2Farticles%2F7dyhge8hptgebue2yj7h.png" alt="React code snippet with the Horizon theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  38. Horizon - Bright
&lt;/h2&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%2Fuploads%2Farticles%2Fqh0fkpqsw6no41wt17ju.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%2Fuploads%2Farticles%2Fqh0fkpqsw6no41wt17ju.png" alt="React code snippet with the Horizon - Bright theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  39. &lt;a href="https://marketplace.visualstudio.com/items?itemName=jaredkent.laserwave" rel="noopener noreferrer"&gt;LaserWave&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F532vbio7zymgop3j3p78.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%2Fuploads%2Farticles%2F532vbio7zymgop3j3p78.png" alt="React code snippet with the LaserWave theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme" rel="noopener noreferrer"&gt;Material&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  40. Material Theme - Ocean
&lt;/h2&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%2Fuploads%2Farticles%2Fov1nm37n72uzbgi68d3g.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%2Fuploads%2Farticles%2Fov1nm37n72uzbgi68d3g.png" alt="React code snippet with the Material - Ocean theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  41. Material Theme - Lighter
&lt;/h2&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%2Fuploads%2Farticles%2Fy36fb3lbsxhaupgbz8sj.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%2Fuploads%2Farticles%2Fy36fb3lbsxhaupgbz8sj.png" alt="React code snippet with the Material - Lighter theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=GulajavaMinistudio.mayukaithemevsc" rel="noopener noreferrer"&gt;Mayukai&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  42. Mayukai - Mirage
&lt;/h2&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%2Fuploads%2Farticles%2Feidot52b1xd0x84egwze.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%2Fuploads%2Farticles%2Feidot52b1xd0x84egwze.png" alt="React code snippet with the Mayukai - Mirage theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  43. Mayukai - Mono
&lt;/h2&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%2Fuploads%2Farticles%2F132n7qbjlfdm0rv7kcq4.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%2Fuploads%2Farticles%2F132n7qbjlfdm0rv7kcq4.png" alt="React code snippet with the Mayukai - Mono theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  44. Mayukai - Sunset
&lt;/h2&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%2Fuploads%2Farticles%2F6lv1orabq2fis5dr1rw0.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%2Fuploads%2Farticles%2F6lv1orabq2fis5dr1rw0.png" alt="React code snippet with the Mayukai - Sunset  theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  45. &lt;a href="https://marketplace.visualstudio.com/items?itemName=miguelsolorio.min-theme" rel="noopener noreferrer"&gt;Min Theme - Dark&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Flxee54gqlwteicunmuqj.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%2Fuploads%2Farticles%2Flxee54gqlwteicunmuqj.png" alt="React code snippet with the Min - Dark theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=sdras.night-owl" rel="noopener noreferrer"&gt;Night Owl&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  46. Night Owl
&lt;/h2&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%2Fuploads%2Farticles%2Fh88xfebp2i5oi4w2oojq.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%2Fuploads%2Farticles%2Fh88xfebp2i5oi4w2oojq.png" alt="React code snippet with the Night Owl theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  47. Night Owl - Light
&lt;/h2&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%2Fuploads%2Farticles%2F8cgk2blmdiv3inw3lcrg.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%2Fuploads%2Farticles%2F8cgk2blmdiv3inw3lcrg.png" alt="React code snippet with the Night Owl - Light theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  48. &lt;a href="https://marketplace.visualstudio.com/items?itemName=liviuschera.noctis" rel="noopener noreferrer"&gt;Noctis - Hibernus&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F6rv22ewqcaes3ofianej.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%2Fuploads%2Farticles%2F6rv22ewqcaes3ofianej.png" alt="React code snippet with the Noctis - Hibernus theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  49. &lt;a href="https://marketplace.visualstudio.com/items?itemName=cev.overnight" rel="noopener noreferrer"&gt;Overnight - Slumber&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fb780uo2n6kkqw8gsofyk.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%2Fuploads%2Farticles%2Fb780uo2n6kkqw8gsofyk.png" alt="React code snippet with the Overnight - Slumber theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  50. &lt;a href="https://marketplace.visualstudio.com/items?itemName=tinkertrain.theme-panda" rel="noopener noreferrer"&gt;Panda Syntax&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fen52e6m8sv0zjym16glv.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%2Fuploads%2Farticles%2Fen52e6m8sv0zjym16glv.png" alt="React code snippet with the Panda Syntax theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  51. &lt;a href="https://marketplace.visualstudio.com/items?itemName=dhedgecock.radical-vscode" rel="noopener noreferrer"&gt;Radical&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fm1bjsrji7uflrgkw004q.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%2Fuploads%2Farticles%2Fm1bjsrji7uflrgkw004q.png" alt="React code snippet with the Radical theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=mvllow.rose-pine" rel="noopener noreferrer"&gt;Rosé Pine&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  52. Rosé Pine
&lt;/h2&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%2Fuploads%2Farticles%2Fg8kzao0trw1c7j264psg.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%2Fuploads%2Farticles%2Fg8kzao0trw1c7j264psg.png" alt="React code snippet with the Rosé Pine theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  53. Rosé Pine - Dawn
&lt;/h2&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%2Fuploads%2Farticles%2Fj3mnpxyairqlxrjp7jv1.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%2Fuploads%2Farticles%2Fj3mnpxyairqlxrjp7jv1.png" alt="React code snippet with the Rosé Pine - Dawn theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=josef.rouge-theme" rel="noopener noreferrer"&gt;Rouge&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  54. Rouge
&lt;/h2&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%2Fuploads%2Farticles%2Foatwsfsa7q1rp5iwzs34.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%2Fuploads%2Farticles%2Foatwsfsa7q1rp5iwzs34.png" alt="React code snippet with the Rouge theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  55. Rouge 2
&lt;/h2&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%2Fuploads%2Farticles%2F4mj20n8ecb0pflpiiyrz.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%2Fuploads%2Farticles%2F4mj20n8ecb0pflpiiyrz.png" alt="React code snippet with the Rouge 2 theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  56. &lt;a href="https://marketplace.visualstudio.com/items?itemName=raashida.fixthecode-vs" rel="noopener noreferrer"&gt;Sea Green Theme&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fayh6cu58nkqvcyp8u3lf.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%2Fuploads%2Farticles%2Fayh6cu58nkqvcyp8u3lf.png" alt="React code snippet with the Sea Green theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  57. &lt;a href="https://marketplace.visualstudio.com/items?itemName=RobbOwen.synthwave-vscode" rel="noopener noreferrer"&gt;SynthWave '84&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fnvxgnmz8b8j10a6witd7.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%2Fuploads%2Farticles%2Fnvxgnmz8b8j10a6witd7.png" alt="React code snippet with the SynthWave '84 theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  &lt;a href="https://marketplace.visualstudio.com/items?itemName=tinaciousdesign.theme-tinaciousdesign" rel="noopener noreferrer"&gt;Tinacious Design&lt;/a&gt;
&lt;/h1&gt;

&lt;h2&gt;
  
  
  58. Tinacious Design
&lt;/h2&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%2Fuploads%2Farticles%2Fliu711lnrx4z6uixzloc.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%2Fuploads%2Farticles%2Fliu711lnrx4z6uixzloc.png" alt="React code snippet with the Tinacious Design theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  59. Tinacious Design - Light
&lt;/h2&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%2Fuploads%2Farticles%2Fr1askukcp75w7mt1av16.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%2Fuploads%2Farticles%2Fr1askukcp75w7mt1av16.png" alt="React code snippet with the Tinacious Design - Light theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  60. &lt;a href="https://marketplace.visualstudio.com/items?itemName=enkia.tokyo-night" rel="noopener noreferrer"&gt;Tokyo Night&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2Fslgx9d16ad2b3tycs3r1.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%2Fuploads%2Farticles%2Fslgx9d16ad2b3tycs3r1.png" alt="React code snippet with the Tokyo Night theme"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  61. &lt;a href="https://marketplace.visualstudio.com/items?itemName=mariorodeghiero.vue-theme" rel="noopener noreferrer"&gt;Vue Theme&lt;/a&gt;
&lt;/h2&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%2Fuploads%2Farticles%2F3i3qgt0wdiq0cx39m2aw.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%2Fuploads%2Farticles%2F3i3qgt0wdiq0cx39m2aw.png" alt="React code snippet with the Vue theme"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;🎉 Don't forget to follow me on &lt;a href="https://instagram.com/underscorecode" rel="noopener noreferrer"&gt;Instagram&lt;/a&gt; and &lt;a href="https://twitter.com/underscorecode" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for more related content.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>vscode</category>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
