Published on

6 Easy Ways To Make A User Dropdown With Icon + Profile Picture With Tailwind CSS Without Even Thinking About It

Tags
User Dropdown With Icon + Profile Picture

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.

The description of User Dropdown With Icon + Profile Picture ui component

Simple component user dropdown +darkmode

Why use Tailwind CSS to make a User Dropdown With Icon + Profile Picture ui component?

  • It can make the building process of User Dropdown With Icon + Profile Picture ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in User Dropdown With Icon + Profile Picture component file.

The preview of User Dropdown With Icon + Profile Picture ui component

Free download of the User Dropdown With Icon + Profile Picture's source code

The source code of User Dropdown With Icon + Profile Picture ui component

<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js"></script>
<div class="h-screen bg-gray-200 flex justify-center items-center dark:bg-gray-500">
  <div x-data="{ open: false }" class="bg-white dark:bg-gray-800 w-64  shadow flex justify-center items-center">
      <div @click="open = !open" class="relative border-b-4 border-transparent py-3" :class="{'border-indigo-700 transform transition duration-300 ': open}" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100">
        <div class="flex justify-center items-center space-x-3 cursor-pointer">
          <div class="w-12 h-12 rounded-full overflow-hidden border-2 dark:border-white border-gray-900">
            <img src="https://images.unsplash.com/photo-1610397095767-84a5b4736cbd?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" alt="" class="w-full h-full object-cover">
          </div>
          <div class="font-semibold dark:text-white text-gray-900 text-lg">
            <div class="cursor-pointer">Hasan Muhammad</div>
          </div>
        </div>
        <div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="transform opacity-0 scale-95" x-transition:enter-end="transform opacity-100 scale-100" x-transition:leave="transition ease-in duration-75" x-transition:leave-start="transform opacity-100 scale-100" x-transition:leave-end="transform opacity-0 scale-95" class="absolute w-60 px-5 py-3 dark:bg-gray-800 bg-white rounded-lg shadow border dark:border-transparent mt-5">
          <ul class="space-y-3 dark:text-white">
            <li class="font-medium">
              <a href="#" class="flex items-center transform transition-colors duration-200 border-r-4 border-transparent hover:border-indigo-700">
                <div class="mr-3">
                  <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"></path></svg>
                </div>
                Account
              </a>
            </li>
            <li class="font-medium">
              <a href="#" class="flex items-center transform transition-colors duration-200 border-r-4 border-transparent hover:border-indigo-700">
                <div class="mr-3">
                  <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path></svg>
                </div>
                Setting
              </a>
            </li>
            <hr class="dark:border-gray-700">
            <li class="font-medium">
              <a href="#" class="flex items-center transform transition-colors duration-200 border-r-4 border-transparent hover:border-red-600">
                <div class="mr-3 text-red-600">
                  <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"></path></svg>
                </div>
                Logout
              </a>
            </li>
          </ul>
        </div>
      </div>
  </div>
</div>

How to make a User Dropdown With Icon + Profile Picture with Tailwind CSS?

Install tailwind css of verion 2.0.2

Use the script html tag to import the script of Tailwind CSS of the version 2.0.2

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to make a User Dropdown With Icon + Profile Picture component

  • h-screen
  • bg-gray-200
  • flex
  • dark:bg-gray-500
  • bg-white
  • dark:bg-gray-800
  • w-64
  • relative
  • border-b-4
  • border-transparent
  • py-3
  • border-indigo-700
  • w-12
  • h-12
  • overflow-hidden
  • border-2
  • dark:border-white
  • border-gray-900
  • w-full
  • h-full
  • dark:text-white
  • text-gray-900
  • text-lg
  • absolute
  • w-60
  • px-5
  • dark:border-transparent
  • mt-5
  • border-r-4
  • hover:border-indigo-700
  • mr-3
  • w-6
  • h-6
  • dark:border-gray-700
  • hover:border-red-600
  • text-red-600

36 steps to make a User Dropdown With Icon + Profile Picture component with Tailwind CSS

  1. Use h-screen to make an element span the entire height of the viewport.

  2. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

  3. Use flex to create a block-level flex container.

  4. Control the background color of an element to gray-500 using the dark:bg-gray-500 utilities in dark theme.

  5. Control the background color of an element to white using the bg-white utilities.

  6. Control the background color of an element to gray-800 using the dark:bg-gray-800 utilities in dark theme.

  7. Use w-64 to set an element to a fixed width(16rem).

  8. Use relative to position an element according to the normal flow of the document.

  9. Control the border color of an element to b-4 using the border-b-4 utilities.

  10. Control the border color of an element to transparent using the border-transparent utilities.

  11. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

  12. Control the border color of an element to indigo-700 using the border-indigo-700 utilities.

  13. Use w-12 to set an element to a fixed width(3rem).

  14. Use h-12 to set an element to a fixed height(3rem).

  15. Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

  16. Control the border color of an element to 0.5rem using the border-2 utilities.

  17. Control the border color of an element to white using the dark:border-white utilities in dark theme.

  18. Control the border color of an element to gray-900 using the border-gray-900 utilities.

  19. Use w-full to set an element to a 100% based width.

  20. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  21. Control the text color of an element to white in dark theme using the dark:text-white utilities.

  22. Control the text color of an element to gray-900 using the text-gray-900 utilities.

  23. Control the text color of an element to lg using the text-lg utilities.

  24. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  25. Use w-60 to set an element to a fixed width(15rem).

  26. Control the horizontal padding of an element to 1.25rem using the px-5 utilities.

  27. Control the border color of an element to transparent using the dark:border-transparent utilities in dark theme.

  28. Control the margin on top side of an element to 1.25rem using the mt-5 utilities.

  29. Control the border color of an element to r-4 using the border-r-4 utilities.

  30. Control the border color of an element to indigo-700 using the hover:border-indigo-700 utilities on hover.

  31. Control the margin on right side of an element to 0.75rem using the mr-3 utilities.

  32. Use w-6 to set an element to a fixed width(1.5rem).

  33. Use h-6 to set an element to a fixed height(1.5rem).

  34. Control the border color of an element to gray-700 using the dark:border-gray-700 utilities in dark theme.

  35. Control the border color of an element to red-600 using the hover:border-red-600 utilities on hover.

  36. Control the text color of an element to red-600 using the text-red-600 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to make a User Dropdown With Icon + Profile Picture components, learn and follow along to implement your own components.