- Published on
6 Ideas To Help You Create A Notification (modal) With Tailwind CSS Like A Pro

- What is Tailwind CSS?
- The description of Notification (modal) ui component
- Why use Tailwind CSS to build a Notification (modal) ui component?
- The preview of Notification (modal) ui component
- The source code of Notification (modal) ui component
- How to build a Notification (modal) with Tailwind CSS?
- Install tailwind css of verion 3.0.18
- All the unility class needed to build a Notification (modal) component
- 17 steps to build a Notification (modal) 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 Notification (modal) ui component
Notification
Why use Tailwind CSS to build a Notification (modal) ui component?
- It can make the building process of Notification (modal) ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Notification (modal) component file.
The preview of Notification (modal) ui component
Free download of the Notification (modal)'s source code
The source code of Notification (modal) ui component
<div class="text-white flex flex-col rounded-md bg-emerald-500 p-2 fixed z-10 max-w-xs">
<div class="flex flex-row items-center">
<svg class="fill-lime-400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="32" height="32">
<path d="M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 C 29 8.832031 23.167969 3 16 3 Z M 16 5 C 22.085938 5 27 9.914063 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 Z M 22.28125 11.28125 L 15 18.5625 L 10.71875 14.28125 L 9.28125 15.71875 L 14.28125 20.71875 L 15 21.40625 L 15.71875 20.71875 L 23.71875 12.71875 Z "/>
</svg>
<div class="mx-1 font-bold">Notification header !</div>
</div>
<div class="text-left m-1">
<a> Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cum doloremque vero voluptatibus, assumenda </a>
</div>
<div class="flex flex-row-reverse gap-2">
<button class="rounded-md hover:bg-opacity-30 hover:bg-gray-500 transition-all ease-in p-1">Cancel</button>
<button class="rounded-md hover:bg-opacity-30 hover:bg-gray-500 transition-all ease-in p-1">Ok</button>
</div>
</div>
How to build a Notification (modal) with Tailwind CSS?
Install tailwind css of verion 3.0.18
Use the script
html tag to import the script of Tailwind CSS of the version 3.0.18
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a Notification (modal) component
text-white
flex
flex-col
bg-emerald-500
p-2
fixed
z-10
max-w-xs
flex-row
mx-1
text-left
m-1
flex-row-reverse
gap-2
hover:bg-opacity-30
hover:bg-gray-500
p-1
17 steps to build a Notification (modal) component with Tailwind CSS
Control the text color of an element to white using the
text-white
utilities.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 emerald-500 using the
bg-emerald-500
utilities.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Use
fixed
to position an element relative to the browser window.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.Set the maximum width/height of an element using the
max-w-xs
utilities.Use
flex
to create a block-level flex container.Control the horizontal margin of an element to 0.25rem using the
mx-1
utilities.Control the text color of an element to left using the
text-left
utilities.Control the margin on all sides of an element to 0.25rem using the
m-1
utilities.Use
flex
to create a block-level flex container.To specify the width between columns, you can use the
gap-2
utilities.Control the background color of an element to opacity-30 using the
hover:bg-opacity-30
utilities on hover.Control the background color of an element to gray-500 using the
hover:bg-gray-500
utilities on hover.Control the padding on all sides of an element to 0.25rem using the
p-1
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a Notification (modal) components, learn and follow along to implement your own components.