Published on

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

Popover

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

  1. Control the background color of an element to green-200 using the bg-green-200 utilities.

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

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

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

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

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

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

  8. Control the margin on right side of an element to 1.25rem using the mr-5 utilities.

  9. Use w-80 to set an element to a fixed width(20rem).

  10. Use relative to position an element according to the normal flow of the document.

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

  12. Control the background color of an element to blue-700 using the bg-blue-700 utilities.

  13. Use h-64 to set an element to a fixed height(16rem).

  14. 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.

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

  16. Use overflow-y-auto to allow vertical scrolling if needed.

  17. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  18. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

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

  20. 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.

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

  22. Use w-10 to set an element to a fixed width(2.5rem).

  23. Use h-10 to set an element to a fixed height(2.5rem).

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

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

  26. Control the vertical margin of an element to 0.25rem using the my-1 utilities.

  27. Control the text color of an element to gray-300 using the text-gray-300 utilities.

  28. Use w-60 to set an element to a fixed width(15rem).

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

  30. Control the border color of an element to 0rem using the border-0 utilities.

  31. Control the border color of an element to t-4 using the border-t-4 utilities.

  32. Control the border color of an element to purple-600 using the border-purple-600 utilities.

  33. Control the margin on left side of an element to 0.75rem using the ml-3 utilities.

  34. Control the text color of an element to black using the text-black utilities.

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

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

  37. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

  38. Control the border color of an element to b using the border-b utilities.

  39. Control the background color of an element to gray-300 using the bg-gray-300 utilities.

  40. Use h-7 to set an element to a fixed height(1.75rem).

  41. Use w-7 to set an element to a fixed width(1.75rem).

  42. Control the text color of an element to gray-500 using the text-gray-500 utilities.

  43. Control the margin on top side of an element to 0rem using the mt-0 utilities.

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

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

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

  47. Control the border color of an element to blue-500 using the border-blue-500 utilities.

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

  49. Control the padding on all sides of an element to 0.5rem using the p-2 utilities.

  50. Use h-8 to set an element to a fixed height(2rem).

  51. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

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

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

  54. To specify the width between columns, you can use the gap-3 utilities.

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

  56. Control the border color of an element to black using the border-black utilities.

  57. Control the horizontal padding of an element to 1rem using the px-4 utilities.

  58. To specify the width between columns, you can use the gap-2 utilities.

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

  60. Use h-32 to set an element to a fixed height(8rem).

  61. Control the horizontal margin of an element to 0.25rem using the mx-1 utilities.

  62. Control the vertical margin of an element to 0.75rem using the my-3 utilities.

  63. Control the text color of an element to justify using the text-justify utilities.

  64. Use w-14 to set an element to a fixed width(3.5rem).

  65. Use h-14 to set an element to a fixed height(3.5rem).

  66. Control the margin on all sides of an element to 1rem using the m-4 utilities.

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

  68. 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.