Published on

Beginners Guide: Build A User Profile Card With Tailwind CSS

Tags
User Profile Card

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 Profile Card ui component

User profile card style

Why use Tailwind CSS to make a User Profile Card ui component?

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

The preview of User Profile Card ui component

Free download of the User Profile Card's source code

The source code of User Profile Card ui component

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:[email protected];500;600;700&display=swap" rel="stylesheet">

<section style="font-family: Montserrat" class=" bg-[#071e34] flex font-medium items-center justify-center h-screen">

    <section class="w-64 mx-auto bg-[#20354b] rounded-2xl px-8 py-6 shadow-lg">
        <div class="flex items-center justify-between">
            <span class="text-gray-400 text-sm">2d ago</span>
            <span class="text-emerald-400">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z" />
              </svg>
            </span>
        </div>
        <div class="mt-6 w-fit mx-auto">
            <img src="https://api.lorem.space/image/face?w=120&h=120&hash=bart89fe" class="rounded-full w-28 " alt="profile picture" srcset="">
        </div>

        <div class="mt-8 ">
            <h2 class="text-white font-bold text-2xl tracking-wide">Jonathan <br/> Smith</h2>
        </div>
        <p class="text-emerald-400 font-semibold mt-2.5" >
            Active
        </p>

        <div class="h-1 w-full bg-black mt-8 rounded-full">
            <div class="h-1 rounded-full w-2/5 bg-yellow-500 "></div>
        </div>
        <div class="mt-3 text-white text-sm">
            <span class="text-gray-400 font-semibold">Storage:</span>
            <span>40%</span>
        </div>

    </section>


</section>

How to make a User Profile Card with Tailwind CSS?

Install tailwind css of verion 3.0.18

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

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

All the unility class needed to make a User Profile Card component

  • bg-[#071e34]
  • flex
  • h-screen
  • w-64
  • mx-auto
  • bg-[#20354b]
  • px-8
  • py-6
  • text-gray-400
  • text-sm
  • text-emerald-400
  • h-6
  • w-6
  • mt-6
  • w-fit
  • w-28
  • mt-8
  • text-white
  • text-2xl
  • mt-2.5
  • h-1
  • w-full
  • bg-black
  • w-2/5
  • bg-yellow-500
  • mt-3

26 steps to make a User Profile Card component with Tailwind CSS

  1. Control the background color of an element to [#071e34] using the bg-[#071e34] utilities.

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

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

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

  5. Control the horizontal margin of an element to auto using the mx-auto utilities.

  6. Control the background color of an element to [#20354b] using the bg-[#20354b] utilities.

  7. Control the horizontal padding of an element to 2rem using the px-8 utilities.

  8. Control the vertical padding of an element to 1.5rem using the py-6 utilities.

  9. Control the text color of an element to gray-400 using the text-gray-400 utilities.

  10. Control the text color of an element to sm using the text-sm utilities.

  11. Control the text color of an element to emerald-400 using the text-emerald-400 utilities.

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

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

  14. Control the margin on top side of an element to 1.5rem using the mt-6 utilities.

  15. Use w-fit to set an element to a fixed width(fit).

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

  17. Control the margin on top side of an element to 2rem using the mt-8 utilities.

  18. Control the text color of an element to white using the text-white utilities.

  19. Control the text color of an element to 2xl using the text-2xl utilities.

  20. Control the margin on top side of an element to 2.5 using the mt-2.5 utilities.

  21. Use h-1 to set an element to a fixed height(0.25rem).

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

  23. Control the background color of an element to black using the bg-black utilities.

  24. Use w-2/5 to set an element to a fixed width(2/5).

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

  26. Control the margin on top side of an element to 0.75rem using the mt-3 utilities.

Conclusion

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