<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Jyothikrishna </title>
    <description>The latest articles on Forem by Jyothikrishna  (@bhendi).</description>
    <link>https://forem.com/bhendi</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%2F897790%2F1e04b27c-f4c2-452e-b5c1-8e803cc6d875.png</url>
      <title>Forem: Jyothikrishna </title>
      <link>https://forem.com/bhendi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bhendi"/>
    <language>en</language>
    <item>
      <title>Introducing UVM TB Templates</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Tue, 18 Feb 2025 05:02:14 +0000</pubDate>
      <link>https://forem.com/bhendi/introducing-uvm-tb-templates-4aed</link>
      <guid>https://forem.com/bhendi/introducing-uvm-tb-templates-4aed</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Starting a new RTL verification project with UVM? Tired of building test environments from scratch every time? You’re not alone! I’ve felt that pain, and that’s why I’m excited to announce the release of UVM Testbench Templates, a project designed to give you a significant head start in your verification efforts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hzixuxsb5jg44661qla.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0hzixuxsb5jg44661qla.png" alt="Left: Typical proejct progress without UVM TB Templates; Right: Progress graph for a project using UVM TB Templates" width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In modern, coverage-driven verification, progress often stalls until the test environment is fully developed. The more time you spend on setup, the longer your overall project timeline becomes. The solution? A set of generic UVM test environments that can be easily customised for any project.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use UVM TB Templates
&lt;/h2&gt;

&lt;p&gt;UVM TB Templates is available as a &lt;a href="https://github.com/bhendi-boi/uvm_tb_template" rel="noopener noreferrer"&gt;public repository on Github&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;UVM TB Templates currently supports 2 templates.&lt;/p&gt;

&lt;p&gt;Generic uvm test env with only one uvm_agent (active) without coverage support available on &lt;a href="https://github.com/bhendi-boi/uvm_tb_templates" rel="noopener noreferrer"&gt;main branch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Above template with coverage support available on &lt;a href="https://github.com/bhendi-boi/uvm_tb_templates/tree/coverage" rel="noopener noreferrer"&gt;coverage branch&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In addition to that the repository also contains an &lt;a href="https://github.com/bhendi-boi/uvm_tb_templates/tree/d_ff-example" rel="noopener noreferrer"&gt;runnable example&lt;/a&gt; created with template 1 present in main branch.&lt;/p&gt;

&lt;p&gt;Visit the Github repo and choose the template you want to use.&lt;/p&gt;

&lt;p&gt;Using the templates is straightforward. Each template has its own directory with a README file. This README contains the git clone command you need. Simply copy and paste it into your terminal to download the template. The downloaded template includes its own README with step-by-step setup instructions. Follow these instructions, and you’ll have a functional test environment ready to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  License
&lt;/h2&gt;

&lt;p&gt;UVM TB TEMPLATES © 2025 by Jyothikrishna is licensed under Creative Commons Attribution 4.0 International. To view a copy of this license, visit &lt;a href="https://creativecommons.org/licenses/by/4.0/" rel="noopener noreferrer"&gt;https://creativecommons.org/licenses/by/4.0/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Contribute to UVM TB Templates
&lt;/h2&gt;

&lt;p&gt;Currently UVM TB Templates only has 2 templates which might not be able to address the needs of all the RTL Verification engineers out there.&lt;/p&gt;

&lt;p&gt;I believe in Open source! If you have a template you’d like to share or suggestions for improvements, please open a pull request. Additionally you can reach out to me at &lt;a href="//jyothikrishna.in@ieee.org"&gt;jyothikrishna.in@ieee.org&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Audit your sites 10X faster with Unlighthouse</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Tue, 19 Sep 2023 05:05:21 +0000</pubDate>
      <link>https://forem.com/bhendi/audit-your-sites-10x-faster-with-unlighthouse-3149</link>
      <guid>https://forem.com/bhendi/audit-your-sites-10x-faster-with-unlighthouse-3149</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Lighthouse is a powerful tool for auditing the performance, accessibility, and best practices of web pages. It is built into Chrome DevTools and can be used to audit individual pages or entire websites.&lt;/p&gt;

&lt;p&gt;Unlighthouse is an open-source tool that builds on top of Lighthouse to provide a number of advantages, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed&lt;/strong&gt;: Unlighthouse is significantly faster than Lighthouse, especially for auditing large websites.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: Unlighthouse can audit websites of any size, while Lighthouse can struggle to audit large websites without crashing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ease of use&lt;/strong&gt;: Unlighthouse has a user-friendly interface that makes it easy to configure and run audits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensibility&lt;/strong&gt;: Unlighthouse is open source and extensible, so you can customize it to meet your specific needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, Unlighthouse allows you to audit multiple routes at a time, which is not possible with Lighthouse.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use Unlighthouse CLI
&lt;/h2&gt;

&lt;p&gt;The Unlighthouse CLI is a command-line tool that allows you to run Unlighthouse audits from your terminal. This is useful for automating audits and integrating Unlighthouse into your CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;To use the Unlighthouse CLI, you will need to install Unlighthouse globally. You can do this with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;install&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-g&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once Unlighthouse is installed, you can run an audit on your website using the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;your-site&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="c"&gt;# OR pnpm dlx unlighthouse --site &amp;lt;your-site&amp;gt;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example, to run an audit on the my portfolio, you would use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;https://jyothikrishna.vercel.app&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 run it you will unlighthouse audit my portfolio and it will display the output on &lt;code&gt;localhost:5678&lt;/code&gt;. Here is an demo pic for your reference 👇&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%2F1x0d1winfktm5uj6oczf.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%2F1x0d1winfktm5uj6oczf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Unlighthouse CLI also supports a number of other options. You can see a list of all the options by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--help&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here are some examples of how to use the Unlighthouse CLI to audit a website with 5-10 routes:&lt;/p&gt;

&lt;p&gt;To audit all of the routes on your website, you can use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--sitemaps&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;https://your-website.com/sitemap.xml&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To audit a specific subset of routes on your website, you can use the &lt;code&gt;--include&lt;/code&gt; and &lt;code&gt;--exclude&lt;/code&gt; options. For example, to exclude about route on your website, you would use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;siteURL&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--exlude&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;about&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To audit your website with different settings, you can use the &lt;code&gt;--config&lt;/code&gt; option. For example, to audit your website with the mobile settings, you would use the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npx&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;unlighthouse&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--site&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;siteURL&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;--config&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;chrome-mobile.config.json&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I encourage you to experiment with the Unlighthouse CLI to see how it can meet your specific needs. Here is the &lt;a href="https://unlighthouse.dev/" rel="noopener noreferrer"&gt;link to official docs&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;Unlighthouse is a powerful tool that can help you improve the quality of your website. It is faster, more scalable, and easier to use than Lighthouse. The Unlighthouse CLI is also a great option for automating audits and integrating Unlighthouse into your CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;If you are auditing a website with 5-10 routes or more, I highly recommend using Unlighthouse instead of Lighthouse. You will save a significant amount of time and frustration. &lt;/p&gt;

&lt;p&gt;If you enjoyed reading this post and want to stay connected, make sure to check out my &lt;a href="https://linktr.ee/jyothikrishna22?utm_source=linktree_admin_share" rel="noopener noreferrer"&gt;Linktree&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
    <item>
      <title>Top 5 Advanced Tailwind Tips to Supercharge Your Web Development</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Tue, 04 Jul 2023 05:37:11 +0000</pubDate>
      <link>https://forem.com/bhendi/top-5-advanced-tailwind-tips-to-supercharge-your-web-development-5a21</link>
      <guid>https://forem.com/bhendi/top-5-advanced-tailwind-tips-to-supercharge-your-web-development-5a21</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Tailwind CSS has gained immense popularity among web developers due to its utility-first approach and easy customization options. While many developers are familiar with the basics of Tailwind, there are several advanced techniques and tips that can take your Tailwind skills to the next level.&lt;/p&gt;

&lt;p&gt;In this article, we will explore the top five advanced Tailwind tips that will help you optimize your workflow, enhance your designs, and make your development process more efficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Copying classnames is perfectly fine
&lt;/h2&gt;

&lt;p&gt;Many times you might have come across a situation where you repeat a classnames a bunch of time like this 👇&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;ul&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;li&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;"text-lg font-medium text-blue-600 hover:opacity-80"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Home
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&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;li&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;"text-lg font-medium text-blue-600 hover:opacity-80"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        About
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&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;li&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;"text-lg font-medium text-blue-600 hover:opacity-80"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Contact
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&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;li&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;"text-lg font-medium text-blue-600 hover:opacity-80"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        Signin
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;li&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;ul&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might get tempted to create a separate component for &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; to apply styles. Creating a separate component for &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; solely to apply styles may not be necessary, in my opinion. Instead, you can leverage the capabilities of your text editor, such as multi-cursor editing. Alternatively, you can style a single &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; first, applying the desired design, and then simply copy the class names from that &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; to reuse them elsewhere. This approach can save time and streamline the development process&lt;/p&gt;

&lt;h2&gt;
  
  
  Dark mode
&lt;/h2&gt;

&lt;p&gt;If you have implemented a dark mode using the &lt;code&gt;class&lt;/code&gt; strategy, you may have noticed that your sidebar appears white in color, which doesn't look quite right. To resolve this issue, you can rectify it by setting the &lt;code&gt;color-scheme&lt;/code&gt; property of &lt;code&gt;html&lt;/code&gt; element to &lt;code&gt;light dark&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="nc"&gt;.dark&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="py"&gt;color-scheme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;dark&lt;/span&gt; &lt;span class="n"&gt;light&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 you're unsure about implementing dark mode in a React+Tailwind project, I have written a detailed article explaining the process. Take a look to learn how to effectively incorporate dark mode into your projects.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/bhendi/simplest-way-to-implement-darkmode-in-your-react-tailwind-project-2e14" class="ltag_cta ltag_cta--branded"&gt;View artcle&lt;/a&gt;
  &lt;/p&gt;
&lt;h2&gt;
  
  
  Using &lt;code&gt;ring&lt;/code&gt; utility to create shadows
&lt;/h2&gt;

&lt;p&gt;Tailwind provides pre-defined classes for box-shadow, but none of them create an evenly distributed shadow in all four directions. However, you can accomplish this by utilizing the &lt;code&gt;ring&lt;/code&gt; utility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ring-1 ring-black/10&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Optimize Workflow with Plugins
&lt;/h2&gt;

&lt;p&gt;Tailwind offers a vast ecosystem of plugins that extend its functionality and streamline your workflow. Plugins can add new components, utilities, or even integrate with other libraries. Familiarize yourself with popular plugins such as Typography, Forms, Aspect Ratio, or Transition utilities to boost your productivity. &lt;/p&gt;

&lt;p&gt;By leveraging plugins, you can enhance your designs and reduce the need for writing custom CSS.&lt;/p&gt;

&lt;p&gt;If you are building a PWA you should definitely check &lt;a href="https://www.npmjs.com/package/tailwindcss-displaymodes"&gt;this&lt;/a&gt; plugin I made. It helps you to increase the UX of your PWA.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using &lt;code&gt;tailwind-merge&lt;/code&gt; instead of regular classname constructer
&lt;/h2&gt;

&lt;p&gt;When incorporating Tailwind CSS into a JavaScript framework, you might have utilized packages such as &lt;code&gt;classnames&lt;/code&gt; or &lt;code&gt;clsx&lt;/code&gt; to dynamically generate class names for elements based on your custom logic. These packages streamline the task of conditionally adding class names, making the process much simpler and more efficient.&lt;/p&gt;

&lt;p&gt;However, if you're building your own design system and require your components/elements to accept a classname prop that can modify specific styles of your components, I suggest utilizing &lt;code&gt;tailwind-merge&lt;/code&gt; instead of &lt;code&gt;clsx&lt;/code&gt; or &lt;code&gt;classnames&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Imagine this is how you are computing classname for your component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Props&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ComponentProps&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;a&lt;/span&gt;&lt;span class="dl"&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;Test&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;rest&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="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;a&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;rest&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;clsx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;classes required to satisfy your design system&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;className&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;
      Test
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;a&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;for arguments sake let's assume this the className&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;clsx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-blue-600 text-4xl font-bold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and you wish to change the text color to fuchsia-600, you can easily pass &lt;code&gt;text-fuchsia-600&lt;/code&gt; as the className, and it will work seamlessly. However, if you attempt to change the text color to black by passing &lt;code&gt;text-black&lt;/code&gt;, it won't have the desired effect. &lt;/p&gt;

&lt;p&gt;This is due to the nature of Tailwind, where utility classes are applied, and each class carries the same level of specificity. As a result, when multiple classes modify the same element property, the class that appears later takes precedence. This behavior aligns with the standard CSS principles.&lt;/p&gt;

&lt;p&gt;Let's look at the classnames computed in both the cases&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// when text-fuchsia-600 is passed className = "text-blue-600 text-4xl font-bold text-fuchsia-600"&lt;/span&gt;

&lt;span class="c1"&gt;// when text-black is passed as className = "text-blue-600 text-4xl font-bold text-black"&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Now we will swap &lt;code&gt;tailwind-merge&lt;/code&gt; for clsx or classnames and let's look at the computed classes again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// when text-fuchsia-600 is passed className = "text-4xl font-bold text-fuchsia-600"&lt;/span&gt;

&lt;span class="c1"&gt;// when text-black is passed as className = "text-4xl font-bold text-black"&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;If you have noticed keenly &lt;code&gt;tailwind-merge&lt;/code&gt; just removed conflicting classes altogether 🤯.&lt;/p&gt;

&lt;p&gt;Amazed by what &lt;code&gt;tailwind-merge&lt;/code&gt; can achieve ? Start using it today by downloading through npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwind-merge&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 want to know more about &lt;code&gt;tailwind-merge&lt;/code&gt; watch this tutorial by Simonwiss on Youtube&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/tfgLd5ZSNPc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

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

&lt;p&gt;Tailwind CSS is a powerful utility-first framework that offers numerous advanced techniques to enhance your web development workflow. In this article, we explored five valuable tips to take your Tailwind skills to the next level.&lt;/p&gt;

&lt;p&gt;I encourage you to try out these advanced Tailwind tips in your web development projects. &lt;/p&gt;

&lt;p&gt;I would love to hear about your experiences and feedback. Please feel free to share your thoughts and insights in the comments section below. Your feedback is valuable and can help further refine these techniques and contribute to the Tailwind CSS community.&lt;/p&gt;

&lt;p&gt;If you enjoyed reading this post and want to stay connected, make sure to check out my &lt;a href="https://linktr.ee/jyothikrishna22"&gt;Linktree&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>tip</category>
      <category>css</category>
    </item>
    <item>
      <title>Enhance your pwa's ui/ux with tailwindcss-displaymodes Plugin</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Tue, 20 Jun 2023 15:48:32 +0000</pubDate>
      <link>https://forem.com/bhendi/enhance-your-ui-design-with-tailwindcss-displaymodes-plugin-2m30</link>
      <guid>https://forem.com/bhendi/enhance-your-ui-design-with-tailwindcss-displaymodes-plugin-2m30</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever wanted to dynamically adjust content and customize the visibility of UI elements based on the display mode of a website? Look no further! I'm thrilled to introduce you to the &lt;strong&gt;tailwindcss-displaymodes&lt;/strong&gt; plugin, a powerful extension for Tailwind CSS that simplifies responsive web design by providing additional variants for specific display modes.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore how this plugin can revolutionize your development process and help you create adaptive user experiences effortlessly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Throughout my journey as a developer, I faced a particular challenge when building a Progressive Web App (PWA). I needed a seamless way to modify content and adjust styles of an UI element based on different display modes. Despite searching for a Tailwind CSS plugin that offered this functionality, I couldn't find a suitable solution. Realizing the potential benefits for fellow developers facing the same dilemma, I embarked on a mission to create &lt;strong&gt;tailwindcss-displaymodes&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Display Modes
&lt;/h2&gt;

&lt;p&gt;The &lt;strong&gt;tailwindcss-displaymodes&lt;/strong&gt; plugin supports four display modes: standalone, minimal-ui, browser, and fullscreen.&lt;br&gt;
For a detailed understanding of the functionality of each display mode, you can refer to the documentation available on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/display-mode"&gt;MDN&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing the plugin
&lt;/h2&gt;

&lt;p&gt;Run the following command to add this plugin to your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;npm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;tailwindcss-diaplaymodes&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now register this plugin in your &lt;code&gt;tailwind.config.js/ts&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// tailwind.config.js&lt;/span&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="c1"&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="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tailwindcss-displaymodes&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;h2&gt;
  
  
  Leveraging Display Mode Variants
&lt;/h2&gt;

&lt;p&gt;One of the common challenges in building Progressive Web Apps (PWAs) is deciding what to show as the root URL, especially when it serves as a landing page that highlights the capabilities of your app. However, once users have installed your PWA on their mobile devices or desktops, you may not want to continuously show them the landing page. With this plugin, achieving this level of control becomes effortless.&lt;/p&gt;

&lt;p&gt;By utilizing the display mode variants offered by the plugin, you can easily hide your landing page for users who have already installed your PWA. Instead, you can present them with quick links to navigate directly to specific sections or even show them their personalized dashboard upon launch. &lt;/p&gt;

&lt;p&gt;This flexibility allows you to tailor the experience based on the user's device and their interaction history with your app.&lt;/p&gt;

&lt;p&gt;These display modes variants act just like normal variants like &lt;code&gt;hover:&lt;/code&gt; or &lt;code&gt;focus:&lt;/code&gt; in tailwind. So if you add &lt;code&gt;standalone:hidden&lt;/code&gt; class to an element then that element gets hidden when a user opens your pwa after installing.&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="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"standalone:hidden"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
  This content will be hidden in standalone mode.
&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find a working demo on &lt;a href="https://hex-cal.vercel.app/"&gt;Hex Cal&lt;/a&gt;, a pwa that I am currently working on. And &lt;a href="https://github.com/bhendi-boi/Hex-cal/blob/main/app/page.tsx"&gt;here&lt;/a&gt; is the source code.&lt;/p&gt;

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

&lt;p&gt;With the this plugin, you have a powerful tool at your disposal to create responsive websites that seamlessly adapt to various display modes. Say goodbye to manual adjustments and hello to a more efficient development workflow.&lt;/p&gt;

&lt;p&gt;Remember, in the world of modern web development, delivering exceptional user experiences across different devices and display modes is crucial. With &lt;strong&gt;tailwindcss-displaymodes&lt;/strong&gt;, you're equipped with the right tools to accomplish just that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>pwa</category>
      <category>ui</category>
      <category>ux</category>
    </item>
    <item>
      <title>Mastering the art of hiding scrollbars with CSS</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Tue, 23 May 2023 11:47:38 +0000</pubDate>
      <link>https://forem.com/bhendi/mastering-the-art-of-hiding-scrollbars-with-css-1bck</link>
      <guid>https://forem.com/bhendi/mastering-the-art-of-hiding-scrollbars-with-css-1bck</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Scrollbars are an essential part of web browsing, providing users with a visual cues to navigate through content that exceeds the viewport. &lt;/p&gt;

&lt;p&gt;However, there are cases where you may want to hide the scrollbars to create a cleaner, more minimalistic design or customize the user experience. &lt;/p&gt;

&lt;p&gt;In native mobile apps, scrollbars are typically not visible, and removing them from your website can give it a more &lt;em&gt;native app-like&lt;/em&gt; feel. In this article, we will explore various techniques to hide scrollbars using CSS.&lt;/p&gt;

&lt;p&gt;In this article, we will explore the algorithm behind the technique to hide scrollbars using CSS. Understanding the underlying principles will empower you to apply the technique in various contexts. Additionally, we will provide a practical example implemented with Tailwind CSS, a popular utility-first CSS framework that enables rapid development by providing pre-defined classes for styling elements.&lt;/p&gt;

&lt;p&gt;By delving into the algorithm and showcasing an example with Tailwind CSS, you'll gain a comprehensive understanding of how to achieve a native app-like feel by hiding scrollbars. So, let's dive in and explore the algorithm behind this trick, followed by an implementation example using Tailwind CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Algorithm
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create the component with a specific height, let's say &lt;code&gt;x&lt;/code&gt; pixels, and set the &lt;code&gt;overflow-x&lt;/code&gt; property to &lt;code&gt;auto&lt;/code&gt;. This ensures that a horizontal scrollbar appears if the content overflows horizontally.&lt;/li&gt;
&lt;li&gt;Wrap the component with a div and set the height of the wrapper div to &lt;code&gt;x&lt;/code&gt; pixels.&lt;/li&gt;
&lt;li&gt; Set the &lt;code&gt;overflow&lt;/code&gt; property of the wrapper div to &lt;code&gt;hidden&lt;/code&gt;. This hides any content that exceeds the height of the wrapper div.&lt;/li&gt;
&lt;li&gt;Increase the height of the component by &lt;code&gt;y&lt;/code&gt; pixels.&lt;/li&gt;
&lt;li&gt;Apply a matching &lt;code&gt;padding-bottom&lt;/code&gt; of &lt;code&gt;y&lt;/code&gt; pixels to the component. This ensures that there is enough space at the bottom of the component to accommodate the increased height without triggering the scrollbar.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these steps, the scrollbar will disappear because the content no longer overflows the wrapper div. The padding at the bottom of the component compensates for the increased height, resulting in a hidden scrollbar effect.&lt;/p&gt;

&lt;p&gt;This technique is useful for creating visually appealing designs without the visible clutter of scrollbars. It provides a smooth and seamless user experience while allowing content to be scrolled horizontally if necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building a scrollable list
&lt;/h2&gt;

&lt;p&gt;I have set up a new React application using Vite as the build tool. As part of the application, I have created a simple &lt;code&gt;&amp;lt;List /&amp;gt;&lt;/code&gt; component. While the purpose of this blog is not to delve into building a scrollable list, I would like to provide the code for your reference. Please find the code snippet below.&lt;/p&gt;

&lt;h3&gt;
  
  
  List component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;List&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;hiddenScrollBar&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;hiddenScrollBar&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;boolean&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;ul&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;classNames&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;flex gap-4 px-4 py-8 overflow-x-auto sm:gap-8 sm:px-8 md:px-12 md:gap-12&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nx"&gt;hiddenScrollBar&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-56&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;hiddenScrollBar&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-52&lt;/span&gt;&lt;span class="dl"&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;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;images&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;image&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ImageCard&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;image&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;ul&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;h3&gt;
  
  
  ImageCard component
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;ImageCard&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;Image&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;li&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;"overflow-hidden bg-gradient-to-br from-gray-50/30 to-gray-300 via-gray-100/50 shrink-0 rounded-xl"&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;img&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;src&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
        &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;alt&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="s"&gt;"object-cover aspect-[7/5] h-full w-full"&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;li&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;ImageCard&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Types for Image
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&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;NOTE&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;classnames&lt;/code&gt; is an npm package which helps us with conditionally setting classnames for an element. One can simply do this 👇 for adding classnames conditionally&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;    &lt;span class="nx"&gt;className&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;`flex gap-4 px-4 py-8 overflow-x-auto sm:gap-8 sm:px-8 md:px-12 md:gap-12 &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;hiddenScrollBar&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h-56&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;h-52&lt;/span&gt;&lt;span class="dl"&gt;"&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Hiding scrollbars with CSS offers a range of possibilities to enhance the user experience or achieve a particular design aesthetic. &lt;/p&gt;

&lt;p&gt;Experiment with these techniques to create seamless and engaging scrolling experiences on your web projects, giving them a native app-like feel.&lt;/p&gt;

&lt;p&gt;Did you find this article on hiding scrollbars with CSS helpful? If so, show your support by giving it a thumbs-up! Don't forget to like and share to help others discover these handy techniques for achieving a clean and native app-like feel on their websites. Engage with us and let us know your thoughts!&lt;/p&gt;

&lt;p&gt;You may find the full source code on &lt;a href="https://github.com/bhendi-boi/hide-scrollbar"&gt;github&lt;/a&gt;. And &lt;a href="https://hide-scrollbar.vercel.app/"&gt;here&lt;/a&gt; is a working demo of the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>uidesign</category>
      <category>webdev</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>How to Build a fully accessible Accordion with HeadlessUI, Framer Motion, and TailwindCSS</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Thu, 04 May 2023 16:03:02 +0000</pubDate>
      <link>https://forem.com/bhendi/how-to-build-an-accordion-with-headlessui-framer-motion-and-tailwindcss-62h</link>
      <guid>https://forem.com/bhendi/how-to-build-an-accordion-with-headlessui-framer-motion-and-tailwindcss-62h</guid>
      <description>&lt;p&gt;Before we get started, let's briefly discuss what each of these technologies does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HeadlessUI&lt;/strong&gt;: A set of fully accessible, lightweight, unstyled components for building UIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Framer Motion&lt;/strong&gt;: A production-ready motion library for React that makes it easy to add animations and gestures to your UI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TailwindCSS&lt;/strong&gt;: A utility-first CSS framework that makes it easy to style your UI using pre-defined classes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, let's dive into how to build an FAQ section with these tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;To get started, you'll need to install the following dependencies to your react project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;     npm i headlessui framer-motion
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can refer to &lt;a href="https://tailwindcss.com/docs/installation"&gt;tailwindcss docs&lt;/a&gt; on how to install and configure tailwindcss for the framework of your choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the basic structure for accordion
&lt;/h2&gt;

&lt;p&gt;Create a new tsx or jsx file by the name &lt;code&gt;Accordion.{tsx/jsx}&lt;/code&gt; in your components folder and paste this block of code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&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;Disclosure&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;@headlessui/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;ArrowSmallDownIcon&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;@heroicons/react/24/outline&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;Accordion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;FAQ&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;Disclosure&lt;/span&gt; &lt;span class="na"&gt;as&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"li"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;open&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;&amp;lt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Button&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;"font-semibold text-xl inline-flex items-center cursor-pointer justify-between w-full mb-1 text-neutral-800"&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;question&lt;/span&gt;&lt;span class="si"&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="si"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;span&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="s2"&gt;`p-2 hover:bg-zinc-400/30 rounded-full &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;
                &lt;span class="nx"&gt;open&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rotate-180&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="p"&gt;}&lt;/span&gt;&lt;span class="s2"&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;ArrowSmallDownIcon&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;"w-5 h-5"&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;span&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;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&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;"text-sm"&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;answer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&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;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&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;Accordion&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;We make use of &lt;strong&gt;Disclosure&lt;/strong&gt; component provided by headlessui. Our accordion accepts two props : question and answer, both are of string type.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Disclosure.Button&lt;/code&gt; is the component that toggles our disclosure/ accordion. So we render our question inside this component so that the users can see the answer when they click on the question.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Disclousre.Panel&lt;/code&gt; is the component that gets mounted and unmounted whenever user clicks on the &lt;code&gt;Disclosure.Button&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We use the render prop &lt;code&gt;open&lt;/code&gt; to conditionally rotate the icon. I am using &lt;code&gt;ArrowSmallDownIcon&lt;/code&gt; from &lt;strong&gt;Heroicons&lt;/strong&gt;. You may use the icon of your choice. You may find more on this topic &lt;a href="https://headlessui.com/react/disclosure#using-render-props"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding animations with framer-motion
&lt;/h2&gt;

&lt;h3&gt;
  
  
  for answer
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&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;AnimatePresence&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;framer-motion&lt;/span&gt;&lt;span class="dl"&gt;"&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;AnimatePresence&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;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&lt;/span&gt;
    &lt;span class="na"&gt;as&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;initial&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;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;animate&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;y&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="na"&gt;opacity&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="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;exit&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;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&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;tween&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="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;transition&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;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.15&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;tween&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="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="s"&gt;"text-sm text-neutral-700"&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;answer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&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;AnimatePresence&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;We must wrap &lt;code&gt;Disclosure.Panel&lt;/code&gt; component that displays the answer with &lt;code&gt;AnimatePresence&lt;/code&gt; so that we can add exit animations to it. The &lt;code&gt;as={motion.div}&lt;/code&gt; prop allows us to use the motion component from Framer Motion and apply animations to the content inside the Disclosure.Panel.&lt;/p&gt;

&lt;p&gt;The animation we are going for is pretty straight forward. The answer &lt;em&gt;slides from top and fades in&lt;/em&gt; when it is supposed to appear and &lt;em&gt;slides to the top and fades out&lt;/em&gt; when it is supposed to disappear. &lt;/p&gt;

&lt;h2&gt;
  
  
  for question
&lt;/h2&gt;

&lt;p&gt;This is quite simple when compared to the former. We just need to toggle the &lt;code&gt;backgroundColor&lt;/code&gt; of the span that is holding our icon between transparent and an off white color which provides an instant feedback for our users that it is a clickable item.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Button&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;"font-semibold text-xl inline-flex items-center cursor-pointer justify-between w-full mb-1 text-neutral-800"&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;question&lt;/span&gt;&lt;span class="si"&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="si"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;
    &lt;span class="na"&gt;whileHover&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;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgb(161 161 170 / 0.3)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;initial&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;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transparent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;animate&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;rotate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;open&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="na"&gt;transition&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;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.15&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;tween&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="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="s"&gt;"p-2 rounded-full text-neutral-950"&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;ArrowSmallDownIcon&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;"w-5 h-5"&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;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;span&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;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&lt;br&gt;
You may customize the duration and easing of the animations to your liking.&lt;/p&gt;

&lt;p&gt;Accordion component after adding animations&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&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;motion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;AnimatePresence&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;framer-motion&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;Disclosure&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;@headlessui/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;ArrowSmallDownIcon&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;@heroicons/react/24/outline&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;Accordion&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;answer&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;FAQ&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;Disclosure&lt;/span&gt; &lt;span class="na"&gt;as&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"li"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;open&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;&amp;lt;&amp;gt;&lt;/span&gt;
          &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Button&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;"font-semibold text-xl inline-flex items-center cursor-pointer justify-between w-full mb-1 text-neutral-800"&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;question&lt;/span&gt;&lt;span class="si"&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="si"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;span&lt;/span&gt;
              &lt;span class="na"&gt;whileHover&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;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rgb(161 161 170 / 0.3)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;initial&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;backgroundColor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;transparent&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;animate&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;rotate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;open&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;180&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;transition&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;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.15&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;tween&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="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="s"&gt;"p-2 rounded-full text-neutral-950"&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;ArrowSmallDownIcon&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;"w-5 h-5"&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;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nt"&gt;span&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;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AnimatePresence&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;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&lt;/span&gt;
              &lt;span class="na"&gt;as&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;motion&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;initial&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;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;animate&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;y&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="na"&gt;opacity&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="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;exit&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;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="na"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.2&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;tween&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="si"&gt;}&lt;/span&gt;
              &lt;span class="na"&gt;transition&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;duration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.15&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;tween&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="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="s"&gt;"text-sm text-neutral-700"&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;answer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
            &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Panel&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;AnimatePresence&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;)&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Disclosure&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;Accordion&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;That's it folks !! By following these simple steps you have bult a fully accessible accordion component. You can use this to render an FAQ section. You may find an example on how to use this component below 👇.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Accordion&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;./Accordion&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;faqs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;FAQ&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="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Is vite the best bundler ?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`It's difficult to say whether ViteJS is the "best" bundler out there, as it ultimately depends on your specific needs and preferences. ViteJS has gained popularity due to its fast development server and quick build times, which can be beneficial for certain types of projects.`&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;question&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Why should I start using headlessui ?&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HeadlessUI provides fully accessible, unstyled UI components that are flexible and customizable, can be used with any front-end framework, and are lightweight for optimal performance.&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="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;main&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;"min-h-screen bg-fuchsia-400 grid place-items-center font-inter"&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;"bg-neutral-50 rounded-xl backdrop-blur-xl w-[70vw] p-12 min-h-[70vh]"&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;ul&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 flex-col gap-4 mb-8"&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;faqs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;faq&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Accordion&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;index&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;faq&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;ul&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;main&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;You can grab the full source code on &lt;a href="https://github.com/bhendi-boi/accordion"&gt;github&lt;/a&gt; and &lt;a href="https://accordian-beta.vercel.app/"&gt;here&lt;/a&gt; is a working demo for reference. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>framermotion</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Transform your navbar into a design resembling that of Google's navbar with React and Tailwind CSS.</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Mon, 10 Apr 2023 13:26:52 +0000</pubDate>
      <link>https://forem.com/bhendi/transform-your-navbar-into-a-design-resembling-that-of-googles-navbar-with-react-and-tailwind-css-54hf</link>
      <guid>https://forem.com/bhendi/transform-your-navbar-into-a-design-resembling-that-of-googles-navbar-with-react-and-tailwind-css-54hf</guid>
      <description>&lt;p&gt;Greetings everyone, I am &lt;a href="https://github.com/bhendi-boi" rel="noopener noreferrer"&gt;Jyothikrishna&lt;/a&gt; and I am thrilled to demonstrate to you how to create a navbar that resembles Google's navbar using React and TailwindCSS.&lt;/p&gt;

&lt;p&gt;As a developer, I know the importance of creating a user-friendly interface, and the navbar is one of the most crucial elements of any website. With Google's navbar being a popular design that users are familiar with, it's a great way to improve the user experience of your website. &lt;/p&gt;

&lt;p&gt;In this article, I'll walk you through the steps needed to create a navbar that looks like Google's, including adding dynamic styling based on the user's scroll position. Let's get started!&lt;/p&gt;

&lt;p&gt;To begin the process of creating a Google-like navbar, let's first describe its features. Specifically, the navbar should initially have a border at the bottom when page is not scrolled, and as the user begins to scroll, a shadow should be added to the bottom of the navbar. You can find a working demo &lt;a href="https://google-like-navbar.vercel.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt; and you can grab the source code on &lt;a href="https://github.com/bhendi-boi/google-like-navbar" rel="noopener noreferrer"&gt;github&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating the basic skeleton
&lt;/h2&gt;

&lt;p&gt;I have created a basic navbar with a &lt;code&gt;h1&lt;/code&gt; and some links. Don't forget to wrap text inside &lt;code&gt;li&lt;/code&gt; with &lt;code&gt;Link&lt;/code&gt; component provided by the framework you are using.&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%2Fstbtvyv2tjsway1mo0cc.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%2Fstbtvyv2tjsway1mo0cc.png" alt="code snippet for basic structure for navbar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Determining when to show the shadow
&lt;/h2&gt;

&lt;p&gt;To determine if the user has scrolled or not, we can inspect the value of the &lt;code&gt;scrollY&lt;/code&gt; key on the &lt;em&gt;window&lt;/em&gt; object. Because our navbar needs to respond to changes in &lt;code&gt;scrollY&lt;/code&gt;, we should store whether to show a shadow or not in a state variable.&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%2Fnwjjhc7gj4xuycmzfh8d.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%2Fnwjjhc7gj4xuycmzfh8d.png" alt="code snippet for determining when to show shadow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We need to attach an event listener to the window object, which will update the &lt;code&gt;showShadow&lt;/code&gt; state variable to true as soon as &lt;code&gt;scrollY&lt;/code&gt; becomes a non-zero value. Conversely, when &lt;code&gt;scrollY&lt;/code&gt; becomes zero, i.e., when the user scrolls to the top of the page, we should set the &lt;code&gt;showShadow&lt;/code&gt; variable to false.&lt;/p&gt;

&lt;p&gt;Remember to remove the event listener when the &lt;code&gt;NavBar&lt;/code&gt; component is unmounted.&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%2Ffqqyymjoyy5fagvkgqcu.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%2Ffqqyymjoyy5fagvkgqcu.png" alt="Code snippet for event listner"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Shadow conditionally
&lt;/h2&gt;

&lt;p&gt;Change the nav element's className attribute to the following 👇&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%2Famjh7j2oyy7u7r65m7ai.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%2Famjh7j2oyy7u7r65m7ai.png" alt="Code snippet showing how to add classes conditionally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You may be wondering why we are keeping the &lt;code&gt;border-b&lt;/code&gt; class even when &lt;code&gt;showShadow&lt;/code&gt; is true. The reason is that the &lt;code&gt;border-b&lt;/code&gt; class increases the height of our navbar by 1px. If we remove the &lt;code&gt;border-b&lt;/code&gt; class, the content inside our navbar will shift slightly.&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%2Fyzomwgqjn3zx5lhz9n1l.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%2Fyzomwgqjn3zx5lhz9n1l.png" alt="Code for the whole navbar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it folks, you have made a navbar similar to Google's design 🥳🎉&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>tailwindcss</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to open Vite dev server on your mobile</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Thu, 23 Mar 2023 05:25:51 +0000</pubDate>
      <link>https://forem.com/bhendi/how-to-open-your-vite-dev-server-on-your-mobile-k1k</link>
      <guid>https://forem.com/bhendi/how-to-open-your-vite-dev-server-on-your-mobile-k1k</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Developing web applications that work seamlessly across multiple devices is a critical aspect of modern web development. As a developer, you may often need to test your web application on different devices and screen sizes to ensure its compatibility and responsiveness. However, manually testing your web application on various devices can be time-consuming and tedious.&lt;/p&gt;

&lt;p&gt;Fortunately, there are tools and techniques available that can help you streamline this process. One such technique is to open your Vite development server on your mobile device, which can allow you to test your web application on your smartphone or tablet quickly and easily. This article will guide you through the steps to open your Vite development server on your mobile device so that you can test your web application on the go.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get your computer and mobile device on the same network
&lt;/h2&gt;

&lt;p&gt;To open your Vite dev server on your mobile device, your computer and mobile device need to be on the same network. This can be a Wi-Fi network or a wired network. Make sure both devices are connected to the same network before proceeding further.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get your computer's IP address
&lt;/h2&gt;

&lt;p&gt;Next, you need to get your computer's IP address.&lt;/p&gt;

&lt;p&gt;On &lt;em&gt;Windows&lt;/em&gt;, open your powershell and type the following command&lt;/p&gt;

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

   &lt;/span&gt;&lt;span class="n"&gt;ipconfig&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;findstr&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;IPv4&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;On &lt;em&gt;Mac&lt;/em&gt;, open your terminal and type the following command&lt;/p&gt;

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

   ipconfig | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"inet "&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; 127.0.0.1 | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $2}'&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;On &lt;em&gt;Linux&lt;/em&gt;, open your terminal and type the following command&lt;/p&gt;

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

   &lt;span class="nb"&gt;hostname&lt;/span&gt; &lt;span class="nt"&gt;-I&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Look for the line that starts with "IPv4 Address" and note the IP address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start the Vite dev server with &lt;code&gt;--host&lt;/code&gt; option
&lt;/h2&gt;

&lt;p&gt;By default, the Vite dev server binds to localhost only, which means it can't be accessed from other devices on the network. To allow access from other devices, you need to start the server with the --host option and specify your computer's IP address.&lt;/p&gt;

&lt;p&gt;Open &lt;code&gt;package.json&lt;/code&gt; for your project and go to scripts key.In scripts change &lt;code&gt;"dev" : "vite"&lt;/code&gt; to &lt;code&gt;"dev" : "vite --host"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;After making necessary changes your scripts key should be similar to 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%2Fs031dznzfhf8tq1n9lpa.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%2Fs031dznzfhf8tq1n9lpa.png" alt="Script key after making necessary changes" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;&lt;br&gt;
If you just want to open vite dev server on your mobile for this one time you can use the following command&lt;/p&gt;

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

    npm run dev -- --host


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

&lt;/div&gt;
&lt;h2&gt;
  
  
  Access the Vite dev server on your mobile device
&lt;/h2&gt;

&lt;p&gt;Now that the Vite dev server is running with the --host option, you can access it on your mobile device. Open the browser on your mobile device and type in the URL:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

   http://&amp;lt;YOUR_COMPUTER'S_IP&amp;gt;:&amp;lt;YOUR_DEV_SERVER_PORT_NUMBER&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Replace YOUR_COMPUTER'S_IP with IPv4 address which you noted in &lt;em&gt;step 2&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Replace YOUR_DEV_SERVER_PORT_NUMBER with the port number which you defined in your &lt;em&gt;vite config&lt;/em&gt; file. In case if you haven't explicitly defined the port number it defaults to &lt;code&gt;5173&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus Tip&lt;/strong&gt;&lt;br&gt;
Vite displays the url which you need in the terminal itself.&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%2F2m58csiij9n038ps5g1l.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%2F2m58csiij9n038ps5g1l.png" alt="Terminal output when Vite dev server is started" width="549" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should now see the same Vite dev server running on your mobile device. You can interact with it just like you would on your computer.&lt;/p&gt;

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

&lt;p&gt;Opening your Vite dev server on your mobile device is a quick and easy way to test your application on different devices and screen sizes. By following the steps outlined in this blog post, you can easily access your Vite dev server on your mobile device and test your application on the go.&lt;/p&gt;

&lt;p&gt;Hope you find this post useful !! &lt;br&gt;
Want to know how to build navbar similar to Google's design. Click &lt;a href="https://dev.to/bhendi/transform-your-navbar-into-a-design-resembling-that-of-googles-navbar-with-react-and-tailwind-css-54hf"&gt;here&lt;/a&gt; to find out.&lt;/p&gt;

&lt;p&gt;If you enjoyed reading this post and want to stay connected, make sure to check out my &lt;a href="https://linktr.ee/jyothikrishna22" rel="noopener noreferrer"&gt;Linktree&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>testing</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Turn your react + vite app into a PWA</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Thu, 23 Feb 2023 16:01:43 +0000</pubDate>
      <link>https://forem.com/bhendi/turn-your-react-vite-app-into-a-pwa-3lpg</link>
      <guid>https://forem.com/bhendi/turn-your-react-vite-app-into-a-pwa-3lpg</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;A Progressive Web Application (PWA) is a web application that has a &lt;em&gt;native&lt;/em&gt; app-like experience. PWAs are designed to be fast, reliable, and work offline. In this post, we'll look at how to turn a React + Vite project into a PWA.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Adding necessary dependencies to your project
&lt;/h2&gt;

&lt;p&gt;We need two dependencies to make our app into a PWA. The first one is &lt;strong&gt;Workbox&lt;/strong&gt;. Workbox is a library that makes it easy to add offline support to your application. The latter is a vite plugin - &lt;strong&gt;vite-plugin-pwa&lt;/strong&gt;. Feel free to copy the command below and paste it in your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -D workbox-window vite-plugin-pwa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Updating vite config file
&lt;/h2&gt;

&lt;p&gt;Import the plugin we have installed using at the top of your &lt;code&gt;vite.config.ts&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { VitePWA } from "vite-plugin-pwa";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in your &lt;em&gt;plugins&lt;/em&gt; array add &lt;strong&gt;VitePWA&lt;/strong&gt; with an object as an argument. The object must look like this 👇&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// https://vitejs.dev/config/
export default defineConfig({
    base: "./",
    plugins: [react(), VitePWA(manifestForPlugin)],
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: manifest &lt;em&gt;key&lt;/em&gt; must be identical to your manifest.json&lt;br&gt;
Also, don't forget to add an icon with role maskable because it is used as the icon for your app when a person &lt;em&gt;installs&lt;/em&gt; your PWA.&lt;/p&gt;

&lt;p&gt;Don't have a &lt;em&gt;maskable icon&lt;/em&gt; for your app ? Use &lt;a href="https://www.npmjs.com/package/pwa-asset-generator" rel="noopener noreferrer"&gt;pwa-asset-generator&lt;/a&gt; to create  maskable icon and splash screens for your app.&lt;/p&gt;

&lt;p&gt;At this point of time if you open dev tools and generate a &lt;a href="https://developer.chrome.com/docs/lighthouse/overview/" rel="noopener noreferrer"&gt;lighthouse&lt;/a&gt; report for progressive web app you should get a result which is similar to this 👇&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmbt31ecw08aqd0xplg4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftmbt31ecw08aqd0xplg4.png" alt="Lighthouse report" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't get panicked by looking at those errors. They will go away once you have deployed your app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step3: Deploying your app
&lt;/h2&gt;

&lt;p&gt;Now, deploy your React app using platforms like &lt;a href="https://www.netlify.com/" rel="noopener noreferrer"&gt;netlify&lt;/a&gt; or &lt;a href="https://vercel.com/" rel="noopener noreferrer"&gt;vercel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once you have finished deploying your app visit your app in your browser and run a lighthouse audit again.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9s7eexqxxf2w951reoy1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9s7eexqxxf2w951reoy1.png" alt="Lighthouse report after deploying" width="800" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it folks! Now you know how to turn your React app into a Progressive Web App (PWA) 🥳🎉. If you have any doubts I am happy to help in the &lt;em&gt;comments&lt;/em&gt;. I have turned one of my React app into a PWA. Check it &lt;a href="https://weatherups.vercel.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;If you enjoyed reading this post and want to stay connected, make sure to check out my &lt;a href="https://linktr.ee/jyothikrishna22" rel="noopener noreferrer"&gt;Linktree&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>web3</category>
      <category>cryptocurrency</category>
      <category>announcement</category>
      <category>devto</category>
    </item>
    <item>
      <title>Remove specific files from your git repository</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Thu, 09 Feb 2023 13:38:45 +0000</pubDate>
      <link>https://forem.com/bhendi/remove-specific-files-from-your-git-repository-53l7</link>
      <guid>https://forem.com/bhendi/remove-specific-files-from-your-git-repository-53l7</guid>
      <description>&lt;p&gt;Hi 👋. Welcome to this guide on removing specific files from your Git repository. Whether you're a seasoned Git user or just starting out, there will come a time when you need to clean up your repository and remove unwanted files. Perhaps you've accidentally committed sensitive information, or maybe you just need to clean up old, unnecessary files. Whatever the reason, removing files from your Git repository can seem like a daunting task, but it's actually quite simple once you know how. In this post, we'll take a step-by-step approach to explain how to safely remove specific files from your Git repository, and what to do if you've already pushed the files to a remote repository. Let's get started!&lt;/p&gt;

&lt;p&gt;Use this command to remove file &lt;strong&gt;only from the git&lt;/strong&gt; repository&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm --cached pathtothefilewhichyouwanttoremove
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running this command you should get output like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm 'pathtofilewhichyouwanttoremove'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run &lt;code&gt;git status&lt;/code&gt; at this point you will get output like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Changes to be committed:
  (use "git restore --staged &amp;lt;file&amp;gt;..." to unstage)
        deleted:    js/one.js

Untracked files:
  (use "git add &amp;lt;file&amp;gt;..." to include in what will be committed)
        js/one.js

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

&lt;/div&gt;



&lt;p&gt;Since I have deleted one.js file which is present in js folder, I got this as my output. Depending upon the path and filename of the file which you have deleted you will get similar output. &lt;/p&gt;

&lt;p&gt;If you wish to keep the file at the same location as before you may add it in the &lt;code&gt;gitignore&lt;/code&gt; file. In this case I am adding &lt;code&gt;js/one.js&lt;/code&gt; to my git ignore file. You should add relative path to the file which you don't want to appear in your git repository.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If you wish to &lt;strong&gt;delete that specific file from your machine&lt;/strong&gt; as well you this command 👇 instead&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm  pathtothefilewhichyouwanttoremove
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you may commit these changes and push to your remote repository. After finishing the above mentioned steps if you head over to your remote repository the file which you have removed will not be present. If you have found this blog post useful leave a like 👍. &lt;/p&gt;

&lt;p&gt;Struck somewhere 🥶, comment down below so that I can help you out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Leetcode question 58 Length of Last Word js solution</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Thu, 05 Jan 2023 04:46:41 +0000</pubDate>
      <link>https://forem.com/bhendi/leetcode-question-58-lenght-of-last-word-js-solution-5h5i</link>
      <guid>https://forem.com/bhendi/leetcode-question-58-lenght-of-last-word-js-solution-5h5i</guid>
      <description>&lt;p&gt;We can break the problem into 3 subproblems &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Removing trailing spaces if they exist&lt;/li&gt;
&lt;li&gt;Finding the words present in that processed string&lt;/li&gt;
&lt;li&gt;And finally finding the length of the last word present in the processed string&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will tackle this subproblems one at a time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 : Removing whitespaces at the beginning and end of the string
&lt;/h2&gt;

&lt;p&gt;Since the string given to us might contain whitespaces in it, we need to remove them because if we don't remove them js treats them as different words.&lt;/p&gt;

&lt;p&gt;To achieve this we make use of the &lt;code&gt;trim&lt;/code&gt; method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const sWithOutWhiteSpaces = s.trim()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2 : Finding words present in string given
&lt;/h2&gt;

&lt;p&gt;This step is very easy to do. We use &lt;code&gt;split&lt;/code&gt; method achieve this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const wordsInS = sWithOutWhiteSpaces.split(" ")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3 : Finding the last word in given string
&lt;/h2&gt;

&lt;p&gt;Last word present in given string is the last element in array &lt;code&gt;wordsInS&lt;/code&gt;. Length of that word is our required answer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const lastWord = wordsInS[wordsInS.length - 1]
return lastWord.length
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Total solution&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var lengthOfLastWord = function (s) {
  const sWithOutWhiteSpaces = s.trim();
  const wordsInS = sWithOutWhiteSpaces.split(" ");
  const lastWord = wordsInS[wordsInS.length - 1];
  return lastWord.length;
};

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

&lt;/div&gt;



&lt;p&gt;If you submit at this point you will get these stats&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%2F0o2dy49gpiyvwe14q5ms.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%2F0o2dy49gpiyvwe14q5ms.png" alt="stats before optimization"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Optimization
&lt;/h2&gt;

&lt;p&gt;We can optimize the time and space required to run this program by chaining all the methods and make it into a single statement thereby reducing the amount of space used by our program since we are no longer using memory to store intermediate values linke wordsInS.&lt;/p&gt;

&lt;p&gt;Now our solution looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var lengthOfLastWord = function (s) {
  return s.trim().split(" ").pop().length;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Time and space complexity
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Time: &lt;strong&gt;O(n)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Space: &lt;strong&gt;O(1)&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After doing above mentioned optimizations you will get these stats&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%2Fali6akrf07t402ddp6y8.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%2Fali6akrf07t402ddp6y8.png" alt="stats after optimization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article. If yes hit that like button.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt; &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>leetcode</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Simplest way to implement dark mode in your react + tailwind project</title>
      <dc:creator>Jyothikrishna </dc:creator>
      <pubDate>Mon, 26 Dec 2022 12:55:35 +0000</pubDate>
      <link>https://forem.com/bhendi/simplest-way-to-implement-darkmode-in-your-react-tailwind-project-2e14</link>
      <guid>https://forem.com/bhendi/simplest-way-to-implement-darkmode-in-your-react-tailwind-project-2e14</guid>
      <description>&lt;p&gt;Having dark mode in your website is essential nowadays. In this blog post I will show you how to implement dark mode in your react + tailwind app. This involves 3 simple steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 : Opting into dark mode in tailwind config file
&lt;/h2&gt;

&lt;p&gt;Open your &lt;code&gt;tailwind.config.cjs&lt;/code&gt; and add this to your config.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vWcR4Zhd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx0kwzto745uibqx95ie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vWcR4Zhd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx0kwzto745uibqx95ie.png" alt="changes to make to tailwind.config.cjs file for opting into darkmode" width="800" height="322"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 : Writing the logic for dark mode to work
&lt;/h2&gt;

&lt;p&gt;In your hooks folder create a new file named &lt;code&gt;useTheme.js&lt;/code&gt; with the following lines of code in it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H-8OcxTa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxoa0w4qtf3c09mh8fwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H-8OcxTa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vxoa0w4qtf3c09mh8fwz.png" alt="useTheme.js file" width="800" height="902"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This code takes user's preferred theme into account and it also stores the theme state in browser's localStorage so that preferred theme is persisted between different sessions. So feel free to copy this and paste it in &lt;code&gt;useTheme.js&lt;/code&gt; file which we have created.&lt;/p&gt;

&lt;p&gt;Next use this &lt;code&gt;theme&lt;/code&gt; state and &lt;code&gt;toggleTheme&lt;/code&gt; function to make an ui so that your users can switch between different theme options. I used icons from react-icons to achieve this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--x4dDToNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h91oaplbzrir6osg2my7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--x4dDToNx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h91oaplbzrir6osg2my7.png" alt="code snipped for ui which allows users to change theme" width="800" height="854"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 : Adding styles for dark mode
&lt;/h2&gt;

&lt;p&gt;This is the final step for implementing dark mode in your app. Define the classNames you want to use when theme is set to dark with a prefix &lt;code&gt;dark:&lt;/code&gt;. For example if you want to use text-neutral-100 className in dark mode use &lt;code&gt;dark:text-neutal-100&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is a code snippet for your reference 👇&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--azAxOdJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6nb4e3fns5y5t93tj8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--azAxOdJU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6nb4e3fns5y5t93tj8z.png" alt="code snippet for using dark mode in tailwind css" width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since I have added &lt;code&gt;dark:bg-dark-background&lt;/code&gt; to my root div, when users change their preferred theme to dark either by using the ui we created in step 2 or by changing their preferred theme in browser bg-dark-background className is added to my root div. I have defined dark-background with the value &lt;code&gt;#141414&lt;/code&gt; in my &lt;code&gt;tailwind.config.cjs&lt;/code&gt; file which makes the background of my root div to &lt;code&gt;#141414&lt;/code&gt;. Add necessary styles to all the elements on your app and you are good to go.&lt;/p&gt;

&lt;p&gt;Woohoo 🥳🎉 You have managed to add dark mode to your app. Don't forget to share your opinions on this article down in the comments 👇.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy Hacking&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
