Published on

3 Things You Must Know To Build A User Card With Tailwind CSS

Tags
User 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 Card ui component

User profile card

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

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

The preview of User Card ui component

Free download of the User Card's source code

The source code of User Card ui component

<div class="w-full max-w-md w-full mx-auto bg-white shadow-md rounded-md px-6 py-4 my-6">
        <div class="sm:flex sm:justify-between">
            <div class="flex items-center">
                <img class="h-12 w-12 rounded-full" src="https://lh3.googleusercontent.com/a-/AOh14Gi0DgItGDTATTFV6lPiVrqtja6RZ_qrY91zg42o-g" alt="">
                <div class="ml-2">
                    <h3 class="text-lg text-gray-800 font-medium">Khatab Wedaa</h3>
                    <span class="text-gray-600">[email protected]</span>
                </div>
            </div>
            <div class="mt-2 sm:mt-0">
                <button class="flex items-center text-white bg-blue-600 rounded px-2 py-1 hover:bg-blue-500 focus:outline-none focus:shadow-outline">
                    <svg class="h-5 w-5" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24" stroke="currentColor"><path d="M12 9v3m0 0v3m0-3h3m-3 0H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
                    <span class="ml-1 text-sm">Follow</span> 
                </button>
            </div>
        </div>
        <div class="flex justify-between items-center mt-4">
            <div>
                <h4 class="text-gray-600 text-sm">Rating</h4>
                <span class="mt-2 text-xl font-medium text-gray-800">127274</span>
            </div>
            <div>
                <h4 class="text-gray-600 text-sm">Submissions</h4>
                <span class="mt-2 text-xl font-medium text-gray-800">12171</span>
            </div>
            <div>
                <h4 class="text-gray-600 text-sm">Reviews</h4>
                <span class="mt-2 text-xl font-medium text-gray-800">35</span>
            </div>
        </div>
        <div class="mt-3">
            <h4 class="text-gray-600 text-sm">User Score</h4>
            <span class="mt-2 text-xl font-medium text-gray-800">21%</span>
        </div>
        <div class="mt-4">
            <h4 class="text-sm text-gray-600">45 Followers</h4>
            <div class="flex items-center overflow-hidden mt-2">
                <img class="inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
            </div>
        </div>
        <div class="mt-4">
            <h4 class="text-sm text-gray-600">250 Following</h4>
            <div class="flex items-center overflow-hidden mt-2">
                <img class="inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1570295999919-56ceb5ecca61?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1510520434124-5bc7e642b61d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80" alt="">
                <img class="-ml-2 inline-block h-6 w-6 rounded-full text-white border-2 border-white object-cover object-center" src="https://images.unsplash.com/photo-1542156822-6924d1a71ace?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" alt="">
            </div>
        </div>
        <a class="block mt-4 text-blue-400 hover:underline" href="#">3 Collections</a>
    </div>

How to make a User Card with Tailwind CSS?

Install tailwind css of verion 2.1.4

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

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

All the unility class needed to make a User Card component

  • w-full
  • max-w-md
  • mx-auto
  • bg-white
  • px-6
  • py-4
  • my-6
  • sm:flex
  • flex
  • h-12
  • w-12
  • ml-2
  • text-lg
  • text-gray-800
  • text-gray-600
  • mt-2
  • sm:mt-0
  • text-white
  • bg-blue-600
  • px-2
  • py-1
  • hover:bg-blue-500
  • h-5
  • w-5
  • ml-1
  • text-sm
  • mt-4
  • text-xl
  • mt-3
  • overflow-hidden
  • inline-block
  • h-6
  • w-6
  • border-2
  • border-white
  • -ml-2
  • block
  • text-blue-400

38 steps to make a User Card component with Tailwind CSS

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

  2. Set the maximum width/height of an element using the max-w-md utilities.

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

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

  5. Control the horizontal padding of an element to 1.5rem using the px-6 utilities.

  6. Control the vertical padding of an element to 1rem using the py-4 utilities.

  7. Control the vertical margin of an element to 1.5rem using the my-6 utilities.

  8. Use flex to create a block-level flex container at only small screen sizes.

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

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

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

  12. Control the margin on left side of an element to 0.5rem using the ml-2 utilities.

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

  14. Control the text color of an element to gray-800 using the text-gray-800 utilities.

  15. Control the text color of an element to gray-600 using the text-gray-600 utilities.

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

  17. Control the margin on top side of an element to 0rem at only small screen sizes using the sm:mt-0 utilities.

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

  19. Control the background color of an element to blue-600 using the bg-blue-600 utilities.

  20. Control the horizontal padding of an element to 0.5rem using the px-2 utilities.

  21. Control the vertical padding of an element to 0.25rem using the py-1 utilities.

  22. Control the background color of an element to blue-500 using the hover:bg-blue-500 utilities on hover.

  23. Use h-5 to set an element to a fixed height(1.25rem).

  24. Use w-5 to set an element to a fixed width(1.25rem).

  25. Control the margin on left side of an element to 0.25rem using the ml-1 utilities.

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

  27. Control the margin on top side of an element to 1rem using the mt-4 utilities.

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

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

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

  31. Use inline-block utilities to wrap the element to prevent the text inside from extending beyond its parent.

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

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

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

  35. Control the border color of an element to white using the border-white utilities.

  36. Control the margin on left side of an element to -0.5rem using the -ml-2 utilities.

  37. Use inline utilities to put the element on its own line and fill its parent.

  38. Control the text color of an element to blue-400 using the text-blue-400 utilities.

Conclusion

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