Published on

The 5 Really Obvious Ways To Make A User Avatar with presence indicator With Tailwind CSS Better That You Ever Did

Tags
User Avatar with presence indicator

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 Avatar with presence indicator ui component

User avatar component with status

Why use Tailwind CSS to make a User Avatar with presence indicator ui component?

  • It can make the building process of User Avatar with presence indicator ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in User Avatar with presence indicator component file.

The preview of User Avatar with presence indicator ui component

Free download of the User Avatar with presence indicator's source code

The source code of User Avatar with presence indicator ui component

<div class="bg-gray-200 flex justify-center items-center relative rounded-full">
  <!-- Heroicon `user` -->
  <svg class="w-9 h-9 m-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
    <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" />
  </svg>

  <!-- active -->
  <span class="w-4 h-4 bg-green-500 absolute bottom-0 right-0 rounded-full"></span>
  <!-- sleep -->
  <!-- <span class="w-4 h-4 bg-yellow-500 absolute bottom-0 right-0 rounded-full"></span> -->
  <!-- away -->
  <!-- <span class="w-4 h-4 bg-red-500 absolute bottom-0 right-0 rounded-full"></span> -->
</div>

How to make a User Avatar with presence indicator with Tailwind CSS?

Install tailwind css of verion 2.0.3

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

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

All the unility class needed to make a User Avatar with presence indicator component

  • bg-gray-200
  • flex
  • relative
  • w-9
  • h-9
  • m-6
  • w-4
  • h-4
  • bg-green-500
  • absolute
  • bottom-0
  • right-0
  • bg-yellow-500
  • bg-red-500

14 steps to make a User Avatar with presence indicator component with Tailwind CSS

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

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

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

  4. Use w-9 to set an element to a fixed width(2.25rem).

  5. Use h-9 to set an element to a fixed height(2.25rem).

  6. Control the margin on all sides of an element to 1.5rem using the m-6 utilities.

  7. Use w-4 to set an element to a fixed width(1rem).

  8. Use h-4 to set an element to a fixed height(1rem).

  9. Control the background color of an element to green-500 using the bg-green-500 utilities.

  10. 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.

  11. Use the bottom-0 utilities to set the bottom position of a positioned element to 0rem.

  12. Use the right-0 utilities to set the right position of a positioned element to 0rem.

  13. Control the background color of an element to yellow-500 using the bg-yellow-500 utilities.

  14. Control the background color of an element to red-500 using the bg-red-500 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to make a User Avatar with presence indicator components, learn and follow along to implement your own components.