<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Saurabh Paryani</title>
    <description>The latest articles on DEV Community by Saurabh Paryani (@saurabhparyani).</description>
    <link>https://dev.to/saurabhparyani</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%2F1506654%2F574603bc-e561-4735-8f45-697923ee64d2.png</url>
      <title>DEV Community: Saurabh Paryani</title>
      <link>https://dev.to/saurabhparyani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/saurabhparyani"/>
    <language>en</language>
    <item>
      <title>Creating a simple Show/Hide Password feature in Nextjs Forms</title>
      <dc:creator>Saurabh Paryani</dc:creator>
      <pubDate>Tue, 06 Aug 2024 20:54:34 +0000</pubDate>
      <link>https://dev.to/saurabhparyani/creating-a-simple-showhide-password-feature-in-nextjs-forms-19oe</link>
      <guid>https://dev.to/saurabhparyani/creating-a-simple-showhide-password-feature-in-nextjs-forms-19oe</guid>
      <description>&lt;p&gt;This is a simple blog on how you can add a simple eye icon next to the password field of your login/sign up form. &lt;br&gt;
The end result would look something like:&lt;/p&gt;

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

&lt;p&gt;What we want:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An eye off icon next to the password field &lt;strong&gt;&lt;em&gt;only after the password field has some non-empty value inside&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;When clicked on eye off, it should reveal password and the icon should change to eye.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;All you need for this is: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;2 React Icons (RiEyeFill and RiEyeOffFill) (you can search for other icons on [&lt;a href="https://react-icons.github.io/react-icons%5D" rel="noopener noreferrer"&gt;https://react-icons.github.io/react-icons]&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Knowledge of the useState hook in React&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So let me take you with what I'm working. I have a form component in Nextjs using the React-Hook-Form and other components by ShadcnUI.&lt;/p&gt;

&lt;p&gt;Let's say we're working on the &lt;strong&gt;login form&lt;/strong&gt; (you can follow the same steps for the signup as well)&lt;/p&gt;

&lt;p&gt;In the login form, I have 2 form fields.&lt;/p&gt;

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

&lt;p&gt;An email field and a password field. &lt;/p&gt;

&lt;p&gt;Step 1: Import the React icons.&lt;br&gt;
&lt;code&gt;import { RiEyeFill, RiEyeOffFill } from "react-icons/ri";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Step 2: Go all the way down to your password field input.&lt;br&gt;
For me, it looks like:&lt;/p&gt;

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

&lt;p&gt;Try rendering an icon here. In order to render it next to the password, wrap the Input in a div and add a button in the same row using flex.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                  &amp;lt;FormControl&amp;gt;
                    &amp;lt;div className="flex flex-row"&amp;gt;
                      &amp;lt;Input
                        placeholder="******"
                        type="password"
                        {...field}
                        disabled={isPending}
                      /&amp;gt;
                      &amp;lt;button className="ml-4 text-gray-700"&amp;gt;
                        &amp;lt;RiEyeOffFill /&amp;gt;
                      &amp;lt;/button&amp;gt;
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/FormControl&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;But what I want is that the icon should be displayed only when there is something inside the password field. &lt;br&gt;
For that, create a state at the top: &lt;/p&gt;

&lt;p&gt;&lt;code&gt;const [isPasswordTyping, setIsPasswordTyping] = useState(false);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inside the Input tag, whenever there is a change in the password field, create an onChange event that sets this isPasswordTyping to true. Or rather, length &amp;gt; 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onChange={(e) =&amp;gt; {
     field.onChange(e);
     setIsPasswordTyping(e.target.value.length &amp;gt; 0);
  }}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This &lt;code&gt;field&lt;/code&gt; is something that Shadcn's React-Hook-Form provides.&lt;/p&gt;

&lt;p&gt;Finally render the button only if isPasswordTyping is true.&lt;br&gt;
So now, you will only see the icon rendered if the password has a non empty field inside.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                  &amp;lt;FormControl&amp;gt;
                    &amp;lt;div className="flex flex-row"&amp;gt;
                      &amp;lt;Input
                        placeholder="******"
                        type="password"
                        {...field}
                        onChange={(e) =&amp;gt; {
                          field.onChange(e);
                          setIsPasswordTyping(e.target.value.length &amp;gt; 0);
                        }}
                        disabled={isPending}
                      /&amp;gt;
                      {isPasswordTyping &amp;amp;&amp;amp; (
                        &amp;lt;button className="ml-4 text-gray-700"&amp;gt;
                          &amp;lt;RiEyeOffFill /&amp;gt;
                        &amp;lt;/button&amp;gt;
                      )}
                    &amp;lt;/div&amp;gt;
                  &amp;lt;/FormControl&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Toggle Visibility and change icon&lt;/p&gt;

&lt;p&gt;We need to render the password as text if a variable "showPassword" is true, and the password as password (******) if "showPassword" is false.&lt;/p&gt;

&lt;p&gt;For that create a state,&lt;br&gt;
&lt;code&gt;const [showPassword, setShowPassword] = useState(false);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and in the Input, add the line: &lt;code&gt;type={showPassword ? "text" : "password"}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                      &amp;lt;Input
                        placeholder="******"
                        type={showPassword ? "text" : "password"}
                        {...field}
                        onChange={(e) =&amp;gt; {
                          field.onChange(e);
                          setIsPasswordTyping(e.target.value.length &amp;gt; 0);
                        }}
                        disabled={isPending}
                      /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We need to render the icon. if showPassword is true, then we need to render the EyeFill icon, else the EyeOffFill.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button className="ml-4 text-gray-700"&amp;gt;
    {showPassword ? &amp;lt;RiEyeFill /&amp;gt; : &amp;lt;RiEyeOffFill /&amp;gt;}
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we need to add an onClick to this button and toggle the visibility.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const togglePasswordVisibility = () =&amp;gt; {
    setShowPassword((prev) =&amp;gt; !prev);
 };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button type="button" onClick={togglePasswordVisibility} className="ml-4 text-gray-700"&amp;gt;
    {showPassword ? &amp;lt;RiEyeFill /&amp;gt; : &amp;lt;RiEyeOffFill /&amp;gt;}
&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And we're done. Here's a live demo:&lt;/p&gt;

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

&lt;p&gt;Thanks for reading. Let me know if you have any questions!&lt;br&gt;
Happy coding. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.saurabhparyani.dev/" rel="noopener noreferrer"&gt;Saurabh Paryani&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>ui</category>
    </item>
    <item>
      <title>Finding the duplicate number in constant space (Python)</title>
      <dc:creator>Saurabh Paryani</dc:creator>
      <pubDate>Mon, 20 May 2024 17:55:43 +0000</pubDate>
      <link>https://dev.to/saurabhparyani/finding-the-duplicate-number-in-constant-space-python-mn9</link>
      <guid>https://dev.to/saurabhparyani/finding-the-duplicate-number-in-constant-space-python-mn9</guid>
      <description>&lt;p&gt;LeetCode’s problem number &lt;a href="https://leetcode.com/problems/find-the-duplicate-number/description/"&gt;287. Find the Duplicate Number&lt;/a&gt; poses a great challenge to anybody familiar with problem-solving using data structures like Linked Lists or Arrays. The problem might look easy to solve in the first glance but given the constraints of the problem, becomes a real task to do.&lt;/p&gt;

&lt;h3&gt;
  
  
  Problem Statement
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.&lt;br&gt;
There is only one repeated number in nums, return this repeated number.&lt;br&gt;
You must solve the problem without modifying the array nums and uses only constant extra space.&lt;br&gt;
All the integers in nums appear only once except for precisely one integer which appears two or more times.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Understanding The Problem
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Examining The Examples
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Example 1:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: nums = [1,3,4,2,2]
Output: 2

# 2 is the repeated number.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Example 2:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: nums = [3,1,3,4,2]
Output: 3

# 3 is the repeated number.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Example 3:
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Input: nums = [3,3,3,3,3]
Output: 3

# The only repeated number is 3.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Approaching The Problem
&lt;/h3&gt;

&lt;h4&gt;
  
  
  ❌ Approach 1: Brute Force
&lt;/h4&gt;

&lt;p&gt;The obvious approach that comes to mind is to use two pointers and run two loops. If &lt;code&gt;nums[i] == nums[j]&lt;/code&gt; then we can deduce that there has been a repeated number, and we can return that.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85ss6kevfrzweyxya8k7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F85ss6kevfrzweyxya8k7.png" alt="Using two pointers i and j in 2 for loops." width="322" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sadly, this costs too much time. The time complexity of this approach becomes O(N²), N being the length of the array, resulting in a TLE. (Time Limit Exceeded)&lt;/p&gt;

&lt;h4&gt;
  
  
  ❌ Approach 2: Trying out sorting, hashing and negating
&lt;/h4&gt;

&lt;p&gt;❌ &lt;em&gt;Sorting&lt;/em&gt; the array, &lt;code&gt;[1,3,4,2,2] → [1,2,2,3,4]&lt;/code&gt; and checking adjacent elements would have been a valid approach, but we have a constraint to &lt;strong&gt;not modify&lt;/strong&gt; the given array.&lt;/p&gt;

&lt;p&gt;❌ &lt;em&gt;Using a set&lt;/em&gt; to store the visited numbers would also have been a valid approach, had the question not ask us to do this in &lt;strong&gt;constant space&lt;/strong&gt;. Using a set data structure to check if a number has been visited to find out the duplicate number takes O(N) space, which isn’t allowed in this problem.&lt;/p&gt;

&lt;p&gt;❌ Another smart approach that fails is to negate every number we visit, &lt;strong&gt;acknowledging the fact that the numbers in&lt;/strong&gt; &lt;code&gt;nums&lt;/code&gt; &lt;strong&gt;are a valid&lt;/strong&gt; &lt;em&gt;index&lt;/em&gt;. This particular statement will be useful later on, but let’s focus on why this approach fails. If I’m traversing through the array, my approach is to make &lt;code&gt;nums[|nums[i]|]&lt;/code&gt; negative. If I find out that &lt;code&gt;nums[|nums[i]|]&lt;/code&gt; is already negative, then I can be sure that there’s a duplicate.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmeclst2eapxeke46o2x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwmeclst2eapxeke46o2x.png" alt="A traversal of the array showing how negating the numbers can catch the repeated number" width="800" height="133"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This modifies the array &lt;strong&gt;which is not allowed&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Approach 3: Binary Search
&lt;/h3&gt;

&lt;p&gt;The idea of a binary search comes from the fact that we have been given an inclusive range of &lt;code&gt;[1,n]&lt;/code&gt; We know the numbers ranging from 1 to n are in an increasing order, hence sorted, which gives us the freedom to apply Binary Search on this range. Our &lt;code&gt;low&lt;/code&gt; gets initialized to 0 and &lt;code&gt;high&lt;/code&gt; gets initialized to &lt;code&gt;len(nums)-1&lt;/code&gt; as our two pointers. We use a while loop and find out the middle index for every check &lt;code&gt;low &amp;lt; high&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;low, high = 1, len(nums)-1
while low &amp;lt; high:
  mid = (low + high) // 2
  .....
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially, we have &lt;code&gt;low = 1, high = 4&lt;/code&gt; because remember, we’re doing binary search on [1,2,3,4] and not on our given array, [1,3,4,2,2].&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovn37zyqizwgbh2qs7jk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fovn37zyqizwgbh2qs7jk.png" alt="calculating mid for low = 1, high = 4" width="292" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For each mid &lt;strong&gt;value&lt;/strong&gt;, we will count the number of elements in the array that are less than or equal to this mid &lt;strong&gt;value&lt;/strong&gt;. So our mid is now 2. We will use the given array &lt;code&gt;[1,3,4,2,2]&lt;/code&gt; and traverse through it, to find out how many such numbers exist that are less than or equal to mid. There are 3 such numbers (1, 2 and 2) which are lesser or equal to mid (2).&lt;br&gt;
Now, you see, try to visualize this.&lt;/p&gt;

&lt;p&gt;The range array [1,2,3,4] is sorted. Say our given array was &lt;code&gt;[3,1,3,4,2]&lt;/code&gt; From the range array, we know our mid is at 2. Traversing our &lt;code&gt;nums&lt;/code&gt; array, there are only 2 elements (1 and 2) lesser than or equal to mid (2). Meaning, both 1 and 2 are such elements which have no duplicate.&lt;br&gt;
If our given array was &lt;code&gt;[1,3,4,2]&lt;/code&gt; i.e. with no duplicates, the count of elements lesser than or equal to mid (2) would have been 2 (1 and 2). But since we have 3 elements lesser than or equal to mid, we can deduce that 2 has been repeated.&lt;/p&gt;

&lt;p&gt;We conclude by saying that &lt;strong&gt;if the count is greater than mid, then the duplicate lies in the left half of the range; otherwise, it lies in the right half.&lt;/strong&gt;&lt;br&gt;
This can be better understood with further narrowing down of the binary search. Since we have now deduced that the duplicate has to lie on the left half of the range array, we shift our &lt;code&gt;high&lt;/code&gt; to &lt;code&gt;mid&lt;/code&gt; meaning our new &lt;code&gt;high&lt;/code&gt; is now equal to 2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70spox8mwmn8028623ff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F70spox8mwmn8028623ff.png" alt="calculating mid for low = 1, high = 2" width="284" height="374"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mid&lt;/code&gt; is equal to 1. We will traverse &lt;code&gt;nums = [1,3,4,2,2]&lt;/code&gt; again and count the number of elements which are lesser or equal to 1. It’s only 1 (1).&lt;br&gt;
This count isn’t greater than mid, that means our duplicate has to lie on the right half of &lt;code&gt;[1]&lt;/code&gt;&lt;br&gt;
We shift our &lt;code&gt;low&lt;/code&gt; to &lt;code&gt;mid+1&lt;/code&gt; making &lt;code&gt;low = 2 = high&lt;/code&gt;.&lt;br&gt;
The while loop ends with low pointing at 2, which indeed is our answer. 2 is the repeated number because if &lt;code&gt;low = high = 2&lt;/code&gt; then our &lt;code&gt;mid = 2&lt;/code&gt; too.&lt;br&gt;
And if we traverse &lt;code&gt;nums = [1,3,4,2,2]&lt;/code&gt; again, we find out that there are 3 elements (1, 2 and 2) that are higher than mid. And since our while loop has been exhausted, we can conclude — 2 is our repeated number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;low, high = 1, len(nums)-1
while low &amp;lt; high:
    mid = (low + high)//2
    count = 0
    for n in nums:
        if n &amp;lt;= mid:
            count += 1

    if count &amp;gt; mid: # duplicate lies in the left half
        high = mid
    else: # duplicate will lie in the right half
        low = mid + 1

return low
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since we’re applying Binary Search on our range array &lt;code&gt;[1,n]&lt;/code&gt; it will cost us O(NlogN) time complexity, N being the length of the given array and space complexity being O(1) — taking no extra space.&lt;br&gt;
Amazing.&lt;br&gt;
&lt;em&gt;But, can we do better?&lt;/em&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  ✅ Approach 4: Hare-Tortoise
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Follow up:&lt;br&gt;
How can we prove that at least one duplicate number must exist in nums?&lt;br&gt;
Can you solve the problem in linear runtime complexity?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal of this approach is to solve this in linear runtime. Let’s solve the first follow up question — proving that at least one duplicate number must exist in &lt;code&gt;nums&lt;/code&gt; and why is this important.&lt;br&gt;
Say n = 5. Meaning, our array should have a size of n+1 or 6 elements.&lt;br&gt;
So, &lt;code&gt;[4,3,1,2,5,?]&lt;/code&gt; But we know the array will only include elements &lt;code&gt;[1,5]&lt;/code&gt; inclusive, the &lt;code&gt;?&lt;/code&gt; should be a repeated number.&lt;/p&gt;

&lt;p&gt;The trick of this approach, like I mentioned in Approach 3, is &lt;strong&gt;acknowledging the fact that the numbers in &lt;code&gt;nums&lt;/code&gt; are a valid &lt;em&gt;index&lt;/em&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The “Hare-Tortoise” approach, also known as, slow-fast pointer approach is used here. Problems having:&lt;br&gt;
a) Duplicate elements,&lt;br&gt;
b) The ability to traverse through &lt;strong&gt;indices&lt;/strong&gt; — can be done by the slow-fast pointer approach. A very popular question called &lt;a href="https://leetcode.com/problems/linked-list-cycle-ii/"&gt;Linked List Cycle II&lt;/a&gt; uses the same approach, where we &lt;strong&gt;first detect a cycle, and if it does, return the node where the cycle begins.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This problem is also very similar. We’re trying to find a cycle and then the starting number to that cycle. If we’re stuck in a cycle, we know there is a repetition. Walking through the dry-run will give more clarity.&lt;/p&gt;

&lt;p&gt;There will be 2 phases to this problem.&lt;br&gt;
&lt;strong&gt;Phase 1&lt;/strong&gt;: Detecting a cycle. Here, the slow pointer (tortoise) s moves 1 move at a time and the fast pointer (hare) f moves 2 moves at a time.&lt;br&gt;
Initially, both s and f are at 0.&lt;/p&gt;

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

&lt;p&gt;Let’s not worry about the looping constraint for now, and focus on the movement of s and f.&lt;br&gt;
We define s’s movement as &lt;code&gt;slow = nums[slow]&lt;/code&gt;&lt;br&gt;
and f’s movement as &lt;code&gt;fast = nums[nums[fast]]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;slow = nums[slow]
     = nums[0]
     = 1

fast = nums[nums[fast]]
     = nums[nums[0]]
     = nums[1]
     = 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kmxsz3bk7rzd4m1d5jm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8kmxsz3bk7rzd4m1d5jm.png" alt="s = 1, f = 3" width="518" height="200"&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;slow = nums[slow]
     = nums[1]
     = 3

fast = nums[nums[fast]]
     = nums[nums[3]]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq9msfi261jufjxbsu7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq9msfi261jufjxbsu7h.png" alt="s = 3, f = 4" width="511" height="191"&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;slow = nums[slow]
     = nums[3]
     = 2

fast = nums[nums[fast]]
     = nums[nums[4]]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdffwkufteq3x1sr57s00.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdffwkufteq3x1sr57s00.png" alt="s = 2, f = 4" width="526" height="188"&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;slow = nums[slow]
     = nums[2]
     = 4

fast = nums[nums[fast]]
     = nums[nums[4]]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh65e58lc9ttuflscvoka.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh65e58lc9ttuflscvoka.png" alt="s = 4, f = 4" width="519" height="203"&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;slow = nums[slow]
     = nums[4]
     = 2

fast = nums[nums[fast]]
     = nums[nums[4]]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5m35lr0lq8c3k87j06d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn5m35lr0lq8c3k87j06d.png" alt="s = 2, 4 infinitely. f = 4" width="535" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There clearly is a cycle. When &lt;code&gt;slow == fast&lt;/code&gt; there is a cycle beginning. Now, we only need to find the starting point of the cycle — which begins our Phase 2.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Phase 2: Reset slow to 0, and move both slow and fast at the same pace, both by 1 move.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ycx0hyr01w0popfgo8q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ycx0hyr01w0popfgo8q.png" alt="s reset to 0, f = 4." width="522" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Movement of the pointers: &lt;code&gt;slow = nums[slow]&lt;/code&gt;, &lt;code&gt;fast = nums[fast]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;slow = nums[slow]
     = nums[0]
     = 0

fast = nums[fast]
     = nums[4]
     = 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbozohuaij79wm7zhj99u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbozohuaij79wm7zhj99u.png" alt="s = 1, f = 2" width="522" height="178"&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;slow = nums[slow]
     = nums[1]
     = 3

fast = nums[fast]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj9yr11bnhd4rfmglgx7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj9yr11bnhd4rfmglgx7.png" alt="s = 3, f = 4" width="526" height="196"&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;slow = nums[slow]
     = nums[3]
     = 2

fast = nums[fast]
     = nums[4]
     = 2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmai6car5t9bp6gz11mvg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmai6car5t9bp6gz11mvg.png" alt="s = f = 2" width="518" height="188"&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;slow = nums[slow]
     = nums[2]
     = 4

fast = nums[fast]
     = nums[2]
     = 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;And this keeps happening. So the moment &lt;code&gt;slow == fast&lt;/code&gt; we know there is a cycle happening. And from &lt;strong&gt;Phase 2&lt;/strong&gt;, we know that &lt;code&gt;slow == fast&lt;/code&gt; happened at &lt;code&gt;slow = 2&lt;/code&gt; Meaning 2 has to be the starting point of the cycle.&lt;br&gt;
Which concludes to the fact that 2 has to be the number that has to be repeated &lt;strong&gt;first&lt;/strong&gt;.&lt;br&gt;
Thus, finally, we return &lt;code&gt;slow&lt;/code&gt; (or &lt;code&gt;fast&lt;/code&gt;, as they’re equal) as our final answer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;slow = fast = nums[0]
        slow = nums[slow]
        fast = nums[nums[fast]]

        while slow != fast:
            slow = nums[slow]
            fast = nums[nums[fast]]

        slow = nums[0]

        while slow != fast:
            slow = nums[slow]
            fast = nums[fast]

        return slow
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Time Complexity is O(N) and we’ve solved this problem in constant space so Space Complexity is O(1).&lt;/p&gt;

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

&lt;p&gt;If you’ve reached this far, remember — coming up with a solution like this super hard at first, but by recognizing patterns, this can be done!&lt;br&gt;
Thanks for reading!&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>python</category>
      <category>programming</category>
      <category>interview</category>
    </item>
    <item>
      <title>Creating a User Nav bar in Next.js 14 using Shadcn UI and Tailwind CSS</title>
      <dc:creator>Saurabh Paryani</dc:creator>
      <pubDate>Mon, 20 May 2024 17:23:07 +0000</pubDate>
      <link>https://dev.to/saurabhparyani/creating-a-user-nav-bar-in-nextjs-14-using-shadcn-ui-and-tailwind-css-ccp</link>
      <guid>https://dev.to/saurabhparyani/creating-a-user-nav-bar-in-nextjs-14-using-shadcn-ui-and-tailwind-css-ccp</guid>
      <description>&lt;h3&gt;
  
  
  The goal for this article is to build something like:
&lt;/h3&gt;

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

&lt;p&gt;When I was working on a project (&lt;a href="https://github.com/saurabhparyani"&gt;https://github.com/saurabhparyani&lt;/a&gt;), I made a nav bar that looked something like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgrtys9c96xkteqh6kdf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftgrtys9c96xkteqh6kdf.png" alt="Nav bar showing user image on the right" width="800" height="41"&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;&amp;lt;div className="flex items-center gap-x-2 ms-auto md:col-span-3"&amp;gt;
        {user ? (
          &amp;lt;UserNav/&amp;gt;
        ) : (
          &amp;lt;div className="flex items-center gap-x-2"&amp;gt;
            &amp;lt;Button asChild&amp;gt;
              &amp;lt;LoginLink&amp;gt;Log in&amp;lt;/LoginLink&amp;gt;
            &amp;lt;/Button&amp;gt;
            &amp;lt;Button variant="secondary" asChild&amp;gt;
              &amp;lt;RegisterLink&amp;gt;Register&amp;lt;/RegisterLink&amp;gt;
            &amp;lt;/Button&amp;gt;
          &amp;lt;/div&amp;gt;
        )}
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used KindeAuth for authentication and when I signed up by Google, I rendered my user image on the right.&lt;/p&gt;

&lt;p&gt;When clicked on the user avatar (in this case, "S" because my google avatar is just my name), it should give me all sort of options like:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The user's name&lt;/li&gt;
&lt;li&gt;The user's email address&lt;/li&gt;
&lt;li&gt;Some properties you wish to add&lt;/li&gt;
&lt;li&gt;A Log out button&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's begin building! &lt;/p&gt;

&lt;p&gt;So without the user nav and the nav bar, my project structure looks like:&lt;/p&gt;

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

&lt;p&gt;To make a User Nav, create a component inside the app folder and name it UserNav.tsx.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export function UserNav() {
    return (
        &amp;lt;div&amp;gt;User Nav content&amp;lt;/div&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We want a functionality that when a user clicks on the avatar, the button trigger should open a dropdown menu from which the user can see all sort of options.&lt;/p&gt;

&lt;p&gt;To do that, we will use Shadcn UI. Since we need to show the user name and email, we will use the Dropdown component. We also need the Avatar component to display the user image as a nice round avatar. And if you have an authentication feature in your project, you can include a Log Out button so for that, we also install the Button component from Shadcn.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ui.shadcn.com/docs/components/dropdown-menu"&gt;https://ui.shadcn.com/docs/components/dropdown-menu&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ui.shadcn.com/docs/components/avatar"&gt;https://ui.shadcn.com/docs/components/avatar&lt;/a&gt;&lt;br&gt;
&lt;a href="https://ui.shadcn.com/docs/components/button"&gt;https://ui.shadcn.com/docs/components/button&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install these packages and you're ready to code.&lt;/p&gt;
&lt;h4&gt;
  
  
  The User Avatar
&lt;/h4&gt;

&lt;p&gt;Let's start with the avatar to display the user image. &lt;br&gt;
To do that, add the DropdownMenu component from "@/components/ui/dropdown-menu" and NOT the radix-ui one or you would get a webpack error.&lt;/p&gt;

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

&lt;p&gt;Inside the DropdownMenu component, you first add a DropdownMenuTrigger component from the same @/components/ui folder. This component triggers the button click and shows the Avatar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { DropdownMenu, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";

export function UserNav() {
    return (
        &amp;lt;DropdownMenu&amp;gt;
            &amp;lt;DropdownMenuTrigger&amp;gt;
            &amp;lt;/DropdownMenuTrigger&amp;gt;
        &amp;lt;/DropdownMenu&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But for a trigger, we need a button to click so add the Button component installed inside it. The button component should have the Avatar component, which further contains the AvatarFallback component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  DropdownMenu,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";

export function UserNav() {
  return (
    &amp;lt;DropdownMenu&amp;gt;
      &amp;lt;DropdownMenuTrigger asChild&amp;gt;
        &amp;lt;Button&amp;gt;
          &amp;lt;Avatar&amp;gt;
            &amp;lt;AvatarFallback&amp;gt;S&amp;lt;/AvatarFallback&amp;gt;
          &amp;lt;/Avatar&amp;gt;
        &amp;lt;/Button&amp;gt;
      &amp;lt;/DropdownMenuTrigger&amp;gt;
    &amp;lt;/DropdownMenu&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I've added an S in the AvatarFallback as an example of how my name's first letter would look as an avatar.&lt;/p&gt;

&lt;p&gt;The above code when saved, shows something like: &lt;/p&gt;

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

&lt;p&gt;We need to style the button to see this clear, so after adding some styling to the Button and Avatar component....&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  DropdownMenu,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";

export function UserNav() {
  return (
    &amp;lt;DropdownMenu&amp;gt;
      &amp;lt;DropdownMenuTrigger&amp;gt;
        &amp;lt;Button variant="ghost" className="relative h-10 w-10 rounded-full"&amp;gt;
          &amp;lt;Avatar className="h-10 w-10"&amp;gt;
            &amp;lt;AvatarFallback&amp;gt;S&amp;lt;/AvatarFallback&amp;gt;
          &amp;lt;/Avatar&amp;gt;
        &amp;lt;/Button&amp;gt;
      &amp;lt;/DropdownMenuTrigger&amp;gt;
    &amp;lt;/DropdownMenu&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;...we get something looking like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifnkt4yaxhrxsfq0rps1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fifnkt4yaxhrxsfq0rps1.png" alt="better button" width="242" height="97"&gt;&lt;/a&gt;&lt;br&gt;
Later, we can add the user image to this button inside the Avatar component.&lt;/p&gt;
&lt;h4&gt;
  
  
  DropdownMenuContent
&lt;/h4&gt;

&lt;p&gt;The DropdownMenuTrigger actives the drop down when clicked on the avatar button. The following code will be the content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DropdownMenuContent className="w-56" align="end" forceMount&amp;gt;
        &amp;lt;DropdownMenuLabel className="font-normal"&amp;gt;
          &amp;lt;div className="flex flex-col space-y-1"&amp;gt;
            &amp;lt;p className="text-sm font-medium leading-none"&amp;gt;Saurabh&amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/DropdownMenuLabel&amp;gt;
&amp;lt;/DropdownMenuContent&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the DropdownMenuContent, we define labels as our items with the DropdownMenuLabel component. Inside which, we will add our item names. &lt;br&gt;
The above code, when clicked on the button, would look something like:&lt;/p&gt;

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

&lt;p&gt;We will similarly add another item as a &lt;/p&gt;
&lt;p&gt; tag with the email and style it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DropdownMenuContent className="w-56" align="end" forceMount&amp;gt;
        &amp;lt;DropdownMenuLabel className="font-normal"&amp;gt;
          &amp;lt;div className="flex flex-col space-y-1"&amp;gt;
            &amp;lt;p className="text-sm font-medium leading-none"&amp;gt;Saurabh&amp;lt;/p&amp;gt;
            &amp;lt;p className="text-xs leading-none text-muted-foreground"&amp;gt;
              saurabhparyani@64gmail.com
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/DropdownMenuLabel&amp;gt;
&amp;lt;/DropdownMenuContent&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h4&gt;
  
  
  DropdownMenuSeparator
&lt;/h4&gt;

&lt;p&gt;Add a small line as a separator after the name and email, to add more list items as per your need.&lt;/p&gt;

&lt;p&gt;i&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mport { Avatar, AvatarFallback } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";

export function UserNav() {
  return (
    &amp;lt;DropdownMenu&amp;gt;
      &amp;lt;DropdownMenuTrigger&amp;gt;
        &amp;lt;Button variant="ghost" className="relative h-10 w-10 rounded-full"&amp;gt;
          &amp;lt;Avatar className="h-10 w-10"&amp;gt;
            &amp;lt;AvatarFallback&amp;gt;S&amp;lt;/AvatarFallback&amp;gt;
          &amp;lt;/Avatar&amp;gt;
        &amp;lt;/Button&amp;gt;
      &amp;lt;/DropdownMenuTrigger&amp;gt;
      &amp;lt;DropdownMenuContent className="w-56" align="end" forceMount&amp;gt;
        &amp;lt;DropdownMenuLabel className="font-normal"&amp;gt;
          &amp;lt;div className="flex flex-col space-y-1"&amp;gt;
            &amp;lt;p className="text-sm font-medium leading-none"&amp;gt;Saurabh&amp;lt;/p&amp;gt;
            &amp;lt;p className="text-xs leading-none text-muted-foreground"&amp;gt;
              saurabhparyani@64gmail.com
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/DropdownMenuLabel&amp;gt;
        &amp;lt;DropdownMenuSeparator /&amp;gt;
        &amp;lt;DropdownMenuGroup&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
        &amp;lt;/DropdownMenuGroup&amp;gt;
        &amp;lt;DropdownMenuSeparator /&amp;gt;
      &amp;lt;/DropdownMenuContent&amp;gt;
    &amp;lt;/DropdownMenu&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h4&gt;
  
  
  Log out
&lt;/h4&gt;

&lt;p&gt;Just add another DropDownMenu item that says Log out. Since I'm using Kinde, I can just add a &lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { LogoutLink } from "@kinde-oss/kinde-auth-nextjs/components";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and add a,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;DropdownMenuItem asChild&amp;gt;
          &amp;lt;LogoutLink&amp;gt;Log out&amp;lt;/LogoutLink&amp;gt;
&amp;lt;/DropdownMenuItem&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;after the DropdownMenuSeparator.&lt;/p&gt;

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

&lt;h4&gt;
  
  
  Render User name, email and picture on the avatar.
&lt;/h4&gt;

&lt;p&gt;To do this, first create an interface in your UserNav.tsx&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface iAppProps {
    email: string;
    name: string;
    userImage: string | undefined;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And add this interface in the function, &lt;br&gt;
&lt;code&gt;export function UserNav({ email, name, userImage }: iAppProps) {&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will give an error in the Navbar.tsx file so go back and add these props over there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div className="flex items-center gap-x-2 ms-auto md:col-span-3"&amp;gt;
        {user ? (
          &amp;lt;UserNav
            email={user.email as string}
            name={user.given_name as string}
            userImage={
              user.picture ?? `https://avatar.vercel.sh/${user.given_name}`
            }
          /&amp;gt;
        ) : (
          &amp;lt;div className="flex items-center gap-x-2"&amp;gt;
            &amp;lt;Button asChild&amp;gt;
              &amp;lt;LoginLink&amp;gt;Log in&amp;lt;/LoginLink&amp;gt;
            &amp;lt;/Button&amp;gt;
            &amp;lt;Button variant="secondary" asChild&amp;gt;
              &amp;lt;RegisterLink&amp;gt;Register&amp;lt;/RegisterLink&amp;gt;
            &amp;lt;/Button&amp;gt;
          &amp;lt;/div&amp;gt;
        )}
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user object comes from Kinde,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { getUser } = getKindeServerSession();
const user = await getUser();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user may not provide a picture if they are signing up with their email. So use &lt;a href="https://avatar.vercel.sh/$%7Buser.given_name%7D"&gt;https://avatar.vercel.sh/${user.given_name}&lt;/a&gt;&lt;br&gt;
to generate a random picture based on any given name. &lt;/p&gt;

&lt;p&gt;Once you add the props to the Nav bar, simply add the userImage inside the Avatar component to display the image.&lt;/p&gt;

&lt;p&gt;The final UserNav.tsx would look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { LogoutLink } from "@kinde-oss/kinde-auth-nextjs/components";

interface iAppProps {
  email: string;
  name: string;
  userImage: string | undefined;
}

export function UserNav({ email, name, userImage }: iAppProps) {
  return (
    &amp;lt;DropdownMenu&amp;gt;
      &amp;lt;DropdownMenuTrigger asChild&amp;gt;
        &amp;lt;Button variant="ghost" className="relative h-10 w-10 rounded-full"&amp;gt;
          &amp;lt;Avatar className="h-10 w-10"&amp;gt;
            &amp;lt;AvatarImage src={userImage} alt="User Image" /&amp;gt;
            &amp;lt;AvatarFallback&amp;gt;{name[0]}&amp;lt;/AvatarFallback&amp;gt;
          &amp;lt;/Avatar&amp;gt;
        &amp;lt;/Button&amp;gt;
      &amp;lt;/DropdownMenuTrigger&amp;gt;
      &amp;lt;DropdownMenuContent align="end" className="w-56" forceMount&amp;gt;
        &amp;lt;DropdownMenuLabel className="font-normal"&amp;gt;
          &amp;lt;div className="flex flex-col space-y-1"&amp;gt;
            &amp;lt;p className="text-sm font-medium leading-none"&amp;gt;{name}&amp;lt;/p&amp;gt;
            &amp;lt;p className="text-xs leading-none text-muted-foreground"&amp;gt;
              {email}
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/DropdownMenuLabel&amp;gt;
        &amp;lt;DropdownMenuSeparator /&amp;gt;
        &amp;lt;DropdownMenuGroup&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
          &amp;lt;DropdownMenuItem&amp;gt;test&amp;lt;/DropdownMenuItem&amp;gt;
        &amp;lt;/DropdownMenuGroup&amp;gt;
        &amp;lt;DropdownMenuSeparator /&amp;gt;
        &amp;lt;DropdownMenuItem asChild&amp;gt;
          &amp;lt;LogoutLink&amp;gt;Log out&amp;lt;/LogoutLink&amp;gt;
        &amp;lt;/DropdownMenuItem&amp;gt;
      &amp;lt;/DropdownMenuContent&amp;gt;
    &amp;lt;/DropdownMenu&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;That concludes this article on how you can use Shadcn and Tailwind to style and create a customizable User Nav bar rendering your profile picture, name and email address.&lt;/p&gt;

&lt;p&gt;Thanks for reading! &amp;lt;3&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>shadcn</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
