- Published on
Learn How To Make A Popover With Tailwind CSS Like an Expert

- What is Tailwind CSS?
- The description of Popover ui component
- Why use Tailwind CSS to build a Popover ui component?
- The preview of Popover ui component
- The source code of Popover ui component
- How to build a Popover with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to build a Popover component
- 68 steps to build a Popover 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 Popover ui component
A beautiful popover ui design
Why use Tailwind CSS to build a Popover ui component?
- It can make the building process of Popover ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Popover component file.
The preview of Popover ui component
Free download of the Popover's source code
The source code of Popover ui component
<div class="bg-green-200 h-screen flex flex-col items-end">
<div class="flex-1 bg-white shadow-xl mt-8 mr-5 w-80 rounded-lg relative overflow-hidden">
<div class="bg-blue-700 h-64 rounded-t-lg absolute w-full"></div>
<div class="flex flex-col overflow-y-auto h-full space-y-3 py-3">
<div class="flex flex-col ml-4 z-10">
<div class="">
<svg class="text-white w-10 h-10 -ml-2" 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="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4" />
</svg>
</div>
<div class="text-white text-2xl font-extrabold my-1">Bonjour 🖐</div>
<div class="text-gray-300 w-60 text-sm">Send one-off messages or orchestrate full integrated campaigns that drive customers to act—both inside your app and out.</div>
</div>
<div class="bg-white border-0 border-t-4 border-purple-600 rounded-b-md flex flex-col z-10 shadow-md ml-3">
<div class="text-sm text-black ml-3 mt-3 font-bold">Poursuivre la conversation</div>
<div class="flex px-2 py-2 border-b">
<div class="bg-gray-300 rounded-full flex w-10 h-10 items-center justify-center">
<svg class="text-white h-7 w-7" 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="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
</svg>
</div>
<div class="flex flex-col">
<div class="text-gray-500 text-sm ml-3 mt-0">Operator . Il ya 11 min</div>
<div class="text-gray-500 text-sm ml-3 mt-0">Operator. 🌟Pop quiz🌟...</div>
</div>
<div class="mt-2 ml-3">
<svg class="h-5 w-5 text-gray-500" 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="M19 9l-7 7-7-7" />
</svg>
</div>
</div>
<div class="flex px-2 py-2">
<div class="bg-gray-300 rounded-full flex w-10 h-10 justify-center items-center">
<svg class="text-white h-7 w-7" 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="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4" />
</svg>
</div>
<div class="flex flex-col">
<div class="text-gray-500 text-sm ml-3 mt-0">Operator . Il ya 11 min</div>
<div class="text-gray-500 text-sm ml-3 mt-0">Operator. 🌟Pop quiz🌟...</div>
</div>
<div class="mt-2 ml-3">
<svg class="h-5 w-5 text-gray-500" 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="M19 9l-7 7-7-7" />
</svg>
</div>
</div>
</div>
<div class="bg-white border border-t-4 border-blue-500 rounded-md flex flex-col z-10 shadow-md ml-3 py-2">
<div class="text-sm text-black ml-3 mt-3 font-bold">Poursuivre la conversation</div>
<div class="flex flex-row p-2">
<input type="text" name="" class="p-2 rounded-l h-8 flex-1 bg-gray-200 shadow-inner focus:gray-200 outline-none" placeholder="search a message here..." id="" />
<button class="bg-blue-600 w-10 rounded-r flex items-center justify-center">
<svg class="h-5 w-5 text-white" 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="M19 9l-7 7-7-7" />
</svg>
</button>
</div>
</div>
<div class="bg-white border-0 border-t-4 border-purple-600 rounded-b-md flex flex-col items-start z-10 shadow-md ml-3 py-4">
<div class="text-sm text-black ml-3 mt-3 font-bold">Poursuivre la conversation</div>
<div class="flex px-2 py-2 gap-3">
<div class="flex -space-x-6">
<div class="bg-gray-300 rounded-full border-2 border-black flex w-10 h-10 items-center justify-center"></div>
<div class="bg-gray-300 rounded-full border-2 border-black flex w-10 h-10 items-center justify-center"></div>
<div class="bg-gray-300 rounded-full border-2 border-black flex w-10 h-10 items-center justify-center"></div>
</div>
<div class="flex flex-col">
<div class="text-gray-500 text-sm ml-3 mt-0">Our usualy reply time</div>
<div class="text-black text-sm ml-3 mt-0 font-bold">⏱ A few minutes</div>
</div>
</div>
<button type="button" class="flex bg-blue-700 text-sm text-white font-semibold items-center justify-center ml-3 px-4 py-2 rounded-full gap-2">
<svg class="text-white w-5 h-5 -ml-2" 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="M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4" />
</svg>
Send us a message
</button>
</div>
<div class="bg-white border border-t-4 border-blue-500 rounded-md flex flex-col z-10 shadow-md ml-3 py-2">
<div class="text-sm text-black ml-1 mt-3 font-bold">Poursuivre la conversation</div>
<div class="bg-gray-300 h-32 mx-1 my-3">
</div>
<p class="text-sm text-gray-500 ml-1 text-justify">
Share automated messages with quick, conversational chats, or use attention-grabbing posts for more important updates.
</p>
</div>
</div>
</div>
<div class="bg-blue-600 rounded-full w-14 h-14 m-4 flex items-center justify-center cursor-pointer shadow-xl">
<svg class="h-6 w-6 text-white" 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="M19 9l-7 7-7-7" />
</svg>
</div>
</div>
How to build a Popover with Tailwind CSS?
Install tailwind css of verion 2.2.4
Use the script
html tag to import the script of Tailwind CSS of the version 2.2.4
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a Popover component
bg-green-200
h-screen
flex
flex-col
flex-1
bg-white
mt-8
mr-5
w-80
relative
overflow-hidden
bg-blue-700
h-64
absolute
w-full
overflow-y-auto
h-full
py-3
ml-4
z-10
text-white
w-10
h-10
-ml-2
text-2xl
my-1
text-gray-300
w-60
text-sm
border-0
border-t-4
border-purple-600
ml-3
text-black
mt-3
px-2
py-2
border-b
bg-gray-300
h-7
w-7
text-gray-500
mt-0
mt-2
h-5
w-5
border-blue-500
flex-row
p-2
h-8
bg-gray-200
bg-blue-600
py-4
gap-3
border-2
border-black
px-4
gap-2
ml-1
h-32
mx-1
my-3
text-justify
w-14
h-14
m-4
h-6
w-6
68 steps to build a Popover component with Tailwind CSS
Control the background color of an element to green-200 using the
bg-green-200
utilities.Use
h-screen
to make an element span the entire height of the viewport.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Control the background color of an element to white using the
bg-white
utilities.Control the margin on top side of an element to 2rem using the
mt-8
utilities.Control the margin on right side of an element to 1.25rem using the
mr-5
utilities.Use
w-80
to set an element to a fixed width(20rem).Use
relative
to position an element according to the normal flow of the document.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the background color of an element to blue-700 using the
bg-blue-700
utilities.Use
h-64
to set an element to a fixed height(16rem).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
w-full
to set an element to a 100% based width.Use
overflow-y-auto
to allow vertical scrolling if needed.Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.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 1rem using the
ml-4
utilities.Control the stack order (or three-dimensional positioning) of an element to 10 in Tailwind, regardless of order it has been displayed, using the
z-10
utilities.Control the text color of an element to white using the
text-white
utilities.Use
w-10
to set an element to a fixed width(2.5rem).Use
h-10
to set an element to a fixed height(2.5rem).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 2xl using the
text-2xl
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-300 using the
text-gray-300
utilities.Use
w-60
to set an element to a fixed width(15rem).Control the text color of an element to sm using the
text-sm
utilities.Control the border color of an element to 0rem using the
border-0
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 purple-600 using the
border-purple-600
utilities.Control the margin on left side of an element to 0.75rem using the
ml-3
utilities.Control the text color of an element to black using the
text-black
utilities.Control the margin on top side of an element to 0.75rem using the
mt-3
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.5rem using the
py-2
utilities.Control the border color of an element to b using the
border-b
utilities.Control the background color of an element to gray-300 using the
bg-gray-300
utilities.Use
h-7
to set an element to a fixed height(1.75rem).Use
w-7
to set an element to a fixed width(1.75rem).Control the text color of an element to gray-500 using the
text-gray-500
utilities.Control the margin on top side of an element to 0rem using the
mt-0
utilities.Control the margin on top side of an element to 0.5rem using the
mt-2
utilities.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 border color of an element to blue-500 using the
border-blue-500
utilities.Use
flex
to create a block-level flex container.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Use
h-8
to set an element to a fixed height(2rem).Control the background color of an element to gray-200 using the
bg-gray-200
utilities.Control the background color of an element to blue-600 using the
bg-blue-600
utilities.Control the vertical padding of an element to 1rem using the
py-4
utilities.To specify the width between columns, you can use the
gap-3
utilities.Control the border color of an element to 0.5rem using the
border-2
utilities.Control the border color of an element to black using the
border-black
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.To specify the width between columns, you can use the
gap-2
utilities.Control the margin on left side of an element to 0.25rem using the
ml-1
utilities.Use
h-32
to set an element to a fixed height(8rem).Control the horizontal margin of an element to 0.25rem using the
mx-1
utilities.Control the vertical margin of an element to 0.75rem using the
my-3
utilities.Control the text color of an element to justify using the
text-justify
utilities.Use
w-14
to set an element to a fixed width(3.5rem).Use
h-14
to set an element to a fixed height(3.5rem).Control the margin on all sides of an element to 1rem using the
m-4
utilities.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).
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Popover components, learn and follow along to implement your own components.