Published on

Ultimate Guide: Create A Notification With Tailwind CSS


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 ui component

A notification for tailwind ccss

Why use Tailwind CSS to build a Notification ui component?

  • It can make the building process of Notification ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Notification component file.

The preview of Notification ui component

Free download of the Notification's source code

The source code of Notification ui component

<!-- This is an example component -->
<div class="flex h-screen">
  <div class="m-auto">
    <div class="bg-white rounded-lg border-gray-300 border p-3 shadow-lg">
      <div class="flex flex-row">
        <div class="px-2">
          <svg width="24" height="24" viewBox="0 0 1792 1792" fill="#44C997" xmlns="">
            <path d="M1299 813l-422 422q-19 19-45 19t-45-19l-294-294q-19-19-19-45t19-45l102-102q19-19 45-19t45 19l147 147 275-275q19-19 45-19t45 19l102 102q19 19 19 45t-19 45zm141 83q0-148-73-273t-198-198-273-73-273 73-198 198-73 273 73 273 198 198 273 73 273-73 198-198 73-273zm224 0q0 209-103 385.5t-279.5 279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5 385.5-103 385.5 103 279.5 279.5 103 385.5z"/>
        <div class="ml-2 mr-6">
          <span class="font-semibold">Successfully Saved!</span>
          <span class="block text-gray-500">Anyone with a link can now view this file</span>

How to build a Notification with Tailwind CSS?

Install tailwind css of verion 1.2.0

Use the link html tag to import the stylesheet of Tailwind CSS of the version 1.2.0

<link href=[email protected]/dist/tailwind.min.css rel="stylesheet">

All the unility class needed to build a Notification component

  • flex
  • h-screen
  • m-auto
  • bg-white
  • border-gray-300
  • p-3
  • flex-row
  • px-2
  • ml-2
  • mr-6
  • block
  • text-gray-500

12 steps to build a Notification component with Tailwind CSS

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

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

  3. Control the margin on all sides of an element to auto using the m-auto utilities.

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

  5. Control the border color of an element to gray-300 using the border-gray-300 utilities.

  6. Control the padding on all sides of an element to 0.75rem using the p-3 utilities.

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

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

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

  10. Control the margin on right side of an element to 1.5rem using the mr-6 utilities.

  11. Use inline utilities to put the element on its own line and fill its parent.

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


The above is a step-by-step tutorial on how to use Tailwind CSS to build a Notification components, learn and follow along to implement your own components.