- Published on
How to Make A Toaster Notification With Tailwind CSS?

- What is Tailwind CSS?
- The description of Toaster Notification ui component
- Why use Tailwind CSS to make a Toaster Notification ui component?
- The preview of Toaster Notification ui component
- The source code of Toaster Notification ui component
- How to make a Toaster Notification with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to make a Toaster Notification component
- 20 steps to make a Toaster Notification 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 Toaster Notification ui component
Simple toaster notification
Why use Tailwind CSS to make a Toaster Notification ui component?
- It can make the building process of Toaster Notification ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Toaster Notification component file.
The preview of Toaster Notification ui component
Free download of the Toaster Notification's source code
The source code of Toaster Notification ui component
<div class="w-full h-screen flex flex-col items-center justify-center">
<div class="mb-4">
<div class="flex max-w-sm w-full bg-white shadow-md rounded-lg overflow-hidden mx-auto">
<div class="w-2 bg-red-600">
</div>
<div class="w-full flex justify-between items-start px-2 py-2">
<div class="flex flex-col ml-2">
<label class="text-gray-800">Your submission was rejected</label>
<p class="text-gray-500 ">Lorem ipsum dolor sit amet consectetur sit amet
</div>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
</div>
</div>
<div class="mb-4">
<div class="flex max-w-sm w-full bg-white shadow-md rounded-lg overflow-hidden mx-auto">
<div class="w-2 bg-green-600">
</div>
<div class="w-full flex justify-between items-start px-2 py-2">
<div class="flex flex-col ml-2">
<label class="text-gray-800">Your submission was approved</label>
<p class="text-gray-500 ">Lorem ipsum dolor sit amet consectetur sit amet
</div>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
</div>
</div>
<div class="mb-4">
<div class="flex max-w-sm w-full bg-white shadow-md rounded-lg overflow-hidden mx-auto">
<div class="w-2 bg-yellow-600">
</div>
<div class="w-full flex justify-between items-start px-2 py-2">
<div class="flex flex-col ml-2">
<label class="text-gray-800">Your submission is pending</label>
<p class="text-gray-500 ">Lorem ipsum dolor sit amet consectetur sit amet
</div>
<a href="#">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</a>
</div>
</div>
</div>
</div>
How to make a Toaster Notification 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 make a Toaster Notification component
w-full
h-screen
flex
flex-col
mb-4
max-w-sm
bg-white
overflow-hidden
mx-auto
w-2
bg-red-600
px-2
py-2
ml-2
text-gray-800
text-gray-500
h-6
w-6
bg-green-600
bg-yellow-600
20 steps to make a Toaster Notification component with Tailwind CSS
Use
w-full
to set an element to a 100% based width.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.Control the margin on bottom side of an element to 1rem using the
mb-4
utilities.Set the maximum width/height of an element using the
max-w-sm
utilities.Control the background color of an element to white using the
bg-white
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Use
w-2
to set an element to a fixed width(0.5rem).Control the background color of an element to red-600 using the
bg-red-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.5rem using the
py-2
utilities.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 gray-800 using the
text-gray-800
utilities.Control the text color of an element to gray-500 using the
text-gray-500
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).Control the background color of an element to green-600 using the
bg-green-600
utilities.Control the background color of an element to yellow-600 using the
bg-yellow-600
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to make a Toaster Notification components, learn and follow along to implement your own components.