- Published on
Advanced Guide: Build A Profile Page With Tailwind CSS

- What is Tailwind CSS?
- The description of Profile Page ui component
- Why use Tailwind CSS to build a Profile Page ui component?
- The preview of Profile Page ui component
- The source code of Profile Page ui component
- How to build a Profile Page with Tailwind CSS?
- Install tailwind css of verion 2.0.2
- All the unility class needed to build a Profile Page component
- 96 steps to build a Profile Page 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 Profile Page ui component
Responsive user profile page
Why use Tailwind CSS to build a Profile Page ui component?
- It can make the building process of Profile Page ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Profile Page component file.
The preview of Profile Page ui component
Free download of the Profile Page's source code
The source code of Profile Page ui component
<style>
:root {
--main-color: #4a76a8;
}
.bg-main-color {
background-color: var(--main-color);
}
.text-main-color {
color: var(--main-color);
}
.border-main-color {
border-color: var(--main-color);
}
</style>
<link href="https://unpkg.com/[email protected]^1.0/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
<div class="bg-gray-100">
<div class="w-full text-white bg-main-color">
<div x-data="{ open: false }"
class="flex flex-col max-w-screen-xl px-4 mx-auto md:items-center md:justify-between md:flex-row md:px-6 lg:px-8">
<div class="p-4 flex flex-row items-center justify-between">
<a href="#"
class="text-lg font-semibold tracking-widest uppercase rounded-lg focus:outline-none focus:shadow-outline">example
profile</a>
<button class="md:hidden rounded-lg focus:outline-none focus:shadow-outline" @click="open = !open">
<svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6">
<path x-show="!open" fill-rule="evenodd"
d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z"
clip-rule="evenodd"></path>
<path x-show="open" fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
</button>
</div>
<nav :class="{'flex': open, 'hidden': !open}"
class="flex-col flex-grow pb-4 md:pb-0 hidden md:flex md:justify-end md:flex-row">
<div @click.away="open = false" class="relative" x-data="{ open: false }">
<button @click="open = !open"
class="flex flex-row items-center space-x-2 w-full px-4 py-2 mt-2 text-sm font-semibold text-left bg-transparent hover:bg-blue-800 md:w-auto md:inline md:mt-0 md:ml-4 hover:bg-gray-200 focus:bg-blue-800 focus:outline-none focus:shadow-outline">
<span>Jane Doe</span>
<img class="inline h-6 rounded-full"
src="https://avatars2.githubusercontent.com/u/24622175?s=60&v=4">
<svg fill="currentColor" viewBox="0 0 20 20" :class="{'rotate-180': open, 'rotate-0': !open}"
class="inline w-4 h-4 transition-transform duration-200 transform">
<path fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
</button>
<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 right-0 w-full mt-2 origin-top-right rounded-md shadow-lg md:w-48">
<div class="py-2 bg-white text-blue-800 text-sm rounded-sm border border-main-color shadow-sm">
<a class="block px-4 py-2 mt-2 text-sm bg-white md:mt-0 focus:text-gray-900 hover:bg-indigo-100 focus:bg-gray-200 focus:outline-none focus:shadow-outline"
href="#">Settings</a>
<a class="block px-4 py-2 mt-2 text-sm bg-white md:mt-0 focus:text-gray-900 hover:bg-indigo-100 focus:bg-gray-200 focus:outline-none focus:shadow-outline"
href="#">Help</a>
<div class="border-b"></div>
<a class="block px-4 py-2 mt-2 text-sm bg-white md:mt-0 focus:text-gray-900 hover:bg-indigo-100 focus:bg-gray-200 focus:outline-none focus:shadow-outline"
href="#">Logout</a>
</div>
</div>
</div>
</nav>
</div>
</div>
<!-- End of Navbar -->
<div class="container mx-auto my-5 p-5">
<div class="md:flex no-wrap md:-mx-2 ">
<!-- Left Side -->
<div class="w-full md:w-3/12 md:mx-2">
<!-- Profile Card -->
<div class="bg-white p-3 border-t-4 border-green-400">
<div class="image overflow-hidden">
<img class="h-auto w-full mx-auto"
src="https://lavinephotography.com.au/wp-content/uploads/2017/01/PROFILE-Photography-112.jpg"
alt="">
</div>
<h1 class="text-gray-900 font-bold text-xl leading-8 my-1">Jane Doe</h1>
<h3 class="text-gray-600 font-lg text-semibold leading-6">Owner at Her Company Inc.</h3>
<p class="text-sm text-gray-500 hover:text-gray-600 leading-6">Lorem ipsum dolor sit amet
consectetur adipisicing elit.
Reprehenderit, eligendi dolorum sequi illum qui unde aspernatur non deserunt</p>
<ul
class="bg-gray-100 text-gray-600 hover:text-gray-700 hover:shadow py-2 px-3 mt-3 divide-y rounded shadow-sm">
<li class="flex items-center py-3">
<span>Status</span>
<span class="ml-auto"><span
class="bg-green-500 py-1 px-2 rounded text-white text-sm">Active</span></span>
</li>
<li class="flex items-center py-3">
<span>Member since</span>
<span class="ml-auto">Nov 07, 2016</span>
</li>
</ul>
</div>
<!-- End of profile card -->
<div class="my-4"></div>
<!-- Friends card -->
<div class="bg-white p-3 hover:shadow">
<div class="flex items-center space-x-3 font-semibold text-gray-900 text-xl leading-8">
<span class="text-green-500">
<svg class="h-5 fill-current" 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="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
</svg>
</span>
<span>Similar Profiles</span>
</div>
<div class="grid grid-cols-3">
<div class="text-center my-2">
<img class="h-16 w-16 rounded-full mx-auto"
src="https://cdn.australianageingagenda.com.au/wp-content/uploads/2015/06/28085920/Phil-Beckett-2-e1435107243361.jpg"
alt="">
<a href="#" class="text-main-color">Kojstantin</a>
</div>
<div class="text-center my-2">
<img class="h-16 w-16 rounded-full mx-auto"
src="https://widgetwhats.com/app/uploads/2019/11/free-profile-photo-whatsapp-4.png"
alt="">
<a href="#" class="text-main-color">James</a>
</div>
<div class="text-center my-2">
<img class="h-16 w-16 rounded-full mx-auto"
src="https://lavinephotography.com.au/wp-content/uploads/2017/01/PROFILE-Photography-112.jpg"
alt="">
<a href="#" class="text-main-color">Natie</a>
</div>
<div class="text-center my-2">
<img class="h-16 w-16 rounded-full mx-auto"
src="https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/f04b52da-12f2-449f-b90c-5e4d5e2b1469_361x361.png"
alt="">
<a href="#" class="text-main-color">Casey</a>
</div>
</div>
</div>
<!-- End of friends card -->
</div>
<!-- Right Side -->
<div class="w-full md:w-9/12 mx-2 h-64">
<!-- Profile tab -->
<!-- About Section -->
<div class="bg-white p-3 shadow-sm rounded-sm">
<div class="flex items-center space-x-2 font-semibold text-gray-900 leading-8">
<span clas="text-green-500">
<svg class="h-5" 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>
</span>
<span class="tracking-wide">About</span>
</div>
<div class="text-gray-700">
<div class="grid md:grid-cols-2 text-sm">
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">First Name</div>
<div class="px-4 py-2">Jane</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Last Name</div>
<div class="px-4 py-2">Doe</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Gender</div>
<div class="px-4 py-2">Female</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Contact No.</div>
<div class="px-4 py-2">+11 998001001</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Current Address</div>
<div class="px-4 py-2">Beech Creek, PA, Pennsylvania</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Permanant Address</div>
<div class="px-4 py-2">Arlington Heights, IL, Illinois</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Email.</div>
<div class="px-4 py-2">
<a class="text-blue-800" href="mailto:[email protected]">[email protected]</a>
</div>
</div>
<div class="grid grid-cols-2">
<div class="px-4 py-2 font-semibold">Birthday</div>
<div class="px-4 py-2">Feb 06, 1998</div>
</div>
</div>
</div>
<button
class="block w-full text-blue-800 text-sm font-semibold rounded-lg hover:bg-gray-100 focus:outline-none focus:shadow-outline focus:bg-gray-100 hover:shadow-xs p-3 my-4">Show
Full Information</button>
</div>
<!-- End of about section -->
<div class="my-4"></div>
<!-- Experience and education -->
<div class="bg-white p-3 shadow-sm rounded-sm">
<div class="grid grid-cols-2">
<div>
<div class="flex items-center space-x-2 font-semibold text-gray-900 leading-8 mb-3">
<span clas="text-green-500">
<svg class="h-5" 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="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
</span>
<span class="tracking-wide">Experience</span>
</div>
<ul class="list-inside space-y-2">
<li>
<div class="text-teal-600">Owner at Her Company Inc.</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
<li>
<div class="text-teal-600">Owner at Her Company Inc.</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
<li>
<div class="text-teal-600">Owner at Her Company Inc.</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
<li>
<div class="text-teal-600">Owner at Her Company Inc.</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
</ul>
</div>
<div>
<div class="flex items-center space-x-2 font-semibold text-gray-900 leading-8 mb-3">
<span clas="text-green-500">
<svg class="h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path fill="#fff" d="M12 14l9-5-9-5-9 5 9 5z" />
<path fill="#fff"
d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222" />
</svg>
</span>
<span class="tracking-wide">Education</span>
</div>
<ul class="list-inside space-y-2">
<li>
<div class="text-teal-600">Masters Degree in Oxford</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
<li>
<div class="text-teal-600">Bachelors Degreen in LPU</div>
<div class="text-gray-500 text-xs">March 2020 - Now</div>
</li>
</ul>
</div>
</div>
<!-- End of Experience and education grid -->
</div>
<!-- End of profile tab -->
</div>
</div>
</div>
</div>
How to build a Profile Page 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 build a Profile Page component
bg-gray-100
w-full
text-white
bg-main-color
flex
flex-col
max-w-screen-xl
px-4
mx-auto
md:flex-row
md:px-6
lg:px-8
p-4
flex-row
text-lg
md:hidden
w-6
h-6
hidden
flex-grow
pb-4
md:pb-0
md:flex
relative
py-2
mt-2
text-sm
text-left
bg-transparent
hover:bg-blue-800
md:w-auto
md:inline
md:mt-0
md:ml-4
hover:bg-gray-200
focus:bg-blue-800
inline
w-4
h-4
absolute
right-0
md:w-48
bg-white
text-blue-800
border-main-color
block
focus:text-gray-900
hover:bg-indigo-100
focus:bg-gray-200
border-b
my-5
p-5
md:-mx-2
md:w-3/12
md:mx-2
p-3
border-t-4
border-green-400
overflow-hidden
h-auto
text-gray-900
text-xl
my-1
text-gray-600
text-semibold
text-gray-500
hover:text-gray-600
hover:text-gray-700
px-3
mt-3
py-3
ml-auto
bg-green-500
py-1
px-2
my-4
text-green-500
h-5
grid
grid-cols-3
text-center
my-2
h-16
w-16
text-main-color
md:w-9/12
mx-2
h-64
text-gray-700
md:grid-cols-2
grid-cols-2
hover:bg-gray-100
focus:bg-gray-100
mb-3
text-teal-600
text-xs
96 steps to build a Profile Page component with Tailwind CSS
Control the background color of an element to gray-100 using the
bg-gray-100
utilities.Use
w-full
to set an element to a 100% based width.Control the text color of an element to white using the
text-white
utilities.Control the background color of an element to main-color using the
bg-main-color
utilities.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Set the maximum width/height of an element using the
max-w-screen-xl
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Use
flex
to create a block-level flex container at only medium screen sizes.Control the horizontal padding of an element to 1.5rem at only medium screen sizes using the
md:px-6
utilities.Control the horizontal padding of an element to 2rem at only large screen sizes using the
lg:px-8
utilities.Control the padding on all sides of an element to 1rem using the
p-4
utilities.Use
flex
to create a block-level flex container.Control the text color of an element to lg using the
text-lg
utilities.Use
hidden
to set an element to display: none and remove it from the page layout at only medium screen sizes.Use
w-6
to set an element to a fixed width(1.5rem).Use
h-6
to set an element to a fixed height(1.5rem).Use
hidden
to set an element to display: none and remove it from the page layout.Use
flex
to create a block-level flex container.Control the padding on bottom side of an element to 1rem using the
pb-4
utilities.Control the padding on bottom side of an element to 0rem at only medium screen sizes using the
md:pb-0
utilities.Use
flex
to create a block-level flex container at only medium screen sizes.Use
relative
to position an element according to the normal flow of the document.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.Control the margin on top side of an element to 0.5rem using the
mt-2
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the text color of an element to left using the
text-left
utilities.Control the background color of an element to transparent using the
bg-transparent
utilities.Control the background color of an element to blue-800 using the
hover:bg-blue-800
utilities on hover.The
w-auto
utility can be useful if you need to remove an element’s assigned width under a specific condition, like at a particular breakpoint.Use
inline
utilities to control the flow of text inside the element to wrap normally at only medium screen sizes.Control the margin on top side of an element to 0rem at only medium screen sizes using the
md:mt-0
utilities.Control the margin on left side of an element to 1rem at only medium screen sizes using the
md:ml-4
utilities.Control the background color of an element to gray-200 using the
hover:bg-gray-200
utilities on hover.Control the background color of an element to blue-800 using the
focus:bg-blue-800
utilities on focus.Use
inline
utilities to control the flow of text inside the element to wrap normally.Use
w-4
to set an element to a fixed width(1rem).Use
h-4
to set an element to a fixed height(1rem).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.Use the
right-0
utilities to set the right position of a positioned element to 0rem.Use
md:w-48
to set an element to a fixed width(12rem) at only medium screen sizes.Control the background color of an element to white using the
bg-white
utilities.Control the text color of an element to blue-800 using the
text-blue-800
utilities.Control the border color of an element to main-color using the
border-main-color
utilities.Use
inline
utilities to put the element on its own line and fill its parent.Control the text color of an element to gray-900 on focus using the
focus:text-gray-900
utilities.Control the background color of an element to indigo-100 using the
hover:bg-indigo-100
utilities on hover.Control the background color of an element to gray-200 using the
focus:bg-gray-200
utilities on focus.Control the border color of an element to b using the
border-b
utilities.Control the vertical margin of an element to 1.25rem using the
my-5
utilities.Control the padding on all sides of an element to 1.25rem using the
p-5
utilities.Control the horizontal margin of an element to -0.5rem at only medium screen sizes using the
md:-mx-2
utilities.Use
md:w-3/12
to set an element to a fixed width(3/12) at only medium screen sizes.Control the horizontal margin of an element to 0.5rem at only medium screen sizes using the
md:mx-2
utilities.Control the padding on all sides of an element to 0.75rem using the
p-3
utilities.Control the border color of an element to t-4 using the
border-t-4
utilities.Control the border color of an element to green-400 using the
border-green-400
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Use
h-auto
to set an element to a fixed height(auto).Control the text color of an element to gray-900 using the
text-gray-900
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the vertical margin of an element to 0.25rem using the
my-1
utilities.Control the text color of an element to gray-600 using the
text-gray-600
utilities.Control the text color of an element to semibold using the
text-semibold
utilities.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Control the text color of an element to gray-600 on hover using the
hover:text-gray-600
utilities.Control the text color of an element to gray-700 on hover using the
hover:text-gray-700
utilities.Control the horizontal padding of an element to 0.75rem using the
px-3
utilities.Control the margin on top side of an element to 0.75rem using the
mt-3
utilities.Control the vertical padding of an element to 0.75rem using the
py-3
utilities.Control the margin on left side of an element to auto using the
ml-auto
utilities.Control the background color of an element to green-500 using the
bg-green-500
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the horizontal padding of an element to 0.5rem using the
px-2
utilities.Control the vertical margin of an element to 1rem using the
my-4
utilities.Control the text color of an element to green-500 using the
text-green-500
utilities.Use
h-5
to set an element to a fixed height(1.25rem).Use
grid
to create a grid container.Use
grid
to create a grid container.Control the text color of an element to center using the
text-center
utilities.Control the vertical margin of an element to 0.5rem using the
my-2
utilities.Use
h-16
to set an element to a fixed height(4rem).Use
w-16
to set an element to a fixed width(4rem).Control the text color of an element to main-color using the
text-main-color
utilities.Use
md:w-9/12
to set an element to a fixed width(9/12) at only medium screen sizes.Control the horizontal margin of an element to 0.5rem using the
mx-2
utilities.Use
h-64
to set an element to a fixed height(16rem).Control the text color of an element to gray-700 using the
text-gray-700
utilities.Use
grid
to create a grid container at only medium screen sizes.Use
grid
to create a grid container.Control the background color of an element to gray-100 using the
hover:bg-gray-100
utilities on hover.Control the background color of an element to gray-100 using the
focus:bg-gray-100
utilities on focus.Control the margin on bottom side of an element to 0.75rem using the
mb-3
utilities.Control the text color of an element to teal-600 using the
text-teal-600
utilities.Control the text color of an element to xs using the
text-xs
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Profile Page components, learn and follow along to implement your own components.