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

- What is Tailwind CSS?
- The description of User Card ui component
- Why use Tailwind CSS to make a User Card ui component?
- The preview of User Card ui component
- The source code of User Card ui component
- How to make a User Card with Tailwind CSS?
- Install tailwind css of verion 2.1.4
- All the unility class needed to make a User Card component
- 38 steps to make a User Card component with Tailwind CSS
- Conclusion
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
Use
w-full
to set an element to a 100% based width.Set the maximum width/height of an element using the
max-w-md
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Control the background color of an element to white using the
bg-white
utilities.Control the horizontal padding of an element to 1.5rem using the
px-6
utilities.Control the vertical padding of an element to 1rem using the
py-4
utilities.Control the vertical margin of an element to 1.5rem using the
my-6
utilities.Use
flex
to create a block-level flex container at only small screen sizes.Use
flex
to create a block-level flex container.Use
h-12
to set an element to a fixed height(3rem).Use
w-12
to set an element to a fixed width(3rem).Control the margin on left side of an element to 0.5rem using the
ml-2
utilities.Control the text color of an element to lg using the
text-lg
utilities.Control the text color of an element to gray-800 using the
text-gray-800
utilities.Control the text color of an element to gray-600 using the
text-gray-600
utilities.Control the margin on top side of an element to 0.5rem using the
mt-2
utilities.Control the margin on top side of an element to 0rem at only small screen sizes using the
sm:mt-0
utilities.Control the text color of an element to white using the
text-white
utilities.Control the background color of an element to blue-600 using the
bg-blue-600
utilities.Control the horizontal padding of an element to 0.5rem using the
px-2
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the background color of an element to blue-500 using the
hover:bg-blue-500
utilities on hover.Use
h-5
to set an element to a fixed height(1.25rem).Use
w-5
to set an element to a fixed width(1.25rem).Control the margin on left side of an element to 0.25rem using the
ml-1
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the margin on top side of an element to 1rem using the
mt-4
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the margin on top side of an element to 0.75rem using the
mt-3
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent.Use
h-6
to set an element to a fixed height(1.5rem).Use
w-6
to set an element to a fixed width(1.5rem).Control the border color of an element to 0.5rem using the
border-2
utilities.Control the border color of an element to white using the
border-white
utilities.Control the margin on left side of an element to -0.5rem using the
-ml-2
utilities.Use
inline
utilities to put the element on its own line and fill its parent.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.