Published on

6 Steps To Make A Simple Promotion Banner (Notification) With Tailwind CSS Like A Pro In Under An Hour

Tags
Simple Promotion Banner (Notification)

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 Simple Promotion Banner (Notification) ui component

A simple notification banner to promote whatever you need.

Why use Tailwind CSS to build a Simple Promotion Banner (Notification) ui component?

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

The preview of Simple Promotion Banner (Notification) ui component

Free download of the Simple Promotion Banner (Notification)'s source code

The source code of Simple Promotion Banner (Notification) ui component

<link href="https://use.fontawesome.com/releases/v5.10.2/css/all.css" rel="stylesheet" />

<div>
      <div
        class="text-center flex flex-col p-4 md:text-left md:flex-row md:items-center md:justify-between md:p-4 bg-purple-100"
        id="messageModal"
      >
        <div class="text-xl font-semibold">
          <div class="text-gray-900">
            Some interesting header.
            <b class="text-purple-500">Some secondary text</b>
          </div>
        </div>

        <div class="mt-3 md:mt-0 md:ml-2">
          <button
            class="inline-block rounded-md text-lg font-semibold py-2 px-4 text-white bg-purple-500"
            onclick="window.open('https://google.com')"
          >
            <i class="fas fa-user"></i> Some Button
          </button>
          <button
            class="inline-block rounded-md text-lg font-semibold py-2 px-4 text-black bg-gray-300"
            onclick="document.getElementById('messageModal').style.display = 'none'"
          >
            <i class="fas fa-times"></i>
          </button>
        </div>
      </div>
    </div>

How to build a Simple Promotion Banner (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 build a Simple Promotion Banner (Notification) component

  • text-center
  • flex
  • flex-col
  • p-4
  • md:text-left
  • md:flex-row
  • md:p-4
  • bg-purple-100
  • text-xl
  • text-gray-900
  • text-purple-500
  • mt-3
  • md:mt-0
  • md:ml-2
  • inline-block
  • text-lg
  • py-2
  • px-4
  • text-white
  • bg-purple-500
  • text-black
  • bg-gray-300

22 steps to build a Simple Promotion Banner (Notification) component with Tailwind CSS

  1. Control the text color of an element to center using the text-center utilities.

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

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

  4. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  5. Control the text color of an element to left at only medium screen sizes using the md:text-left utilities.

  6. Use flex to create a block-level flex container at only medium screen sizes.

  7. Control the padding on all sides of an element to 1rem at only medium screen sizes using the md:p-4 utilities.

  8. Control the background color of an element to purple-100 using the bg-purple-100 utilities.

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

  10. Control the text color of an element to gray-900 using the text-gray-900 utilities.

  11. Control the text color of an element to purple-500 using the text-purple-500 utilities.

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

  13. Control the margin on top side of an element to 0rem at only medium screen sizes using the md:mt-0 utilities.

  14. Control the margin on left side of an element to 0.5rem at only medium screen sizes using the md:ml-2 utilities.

  15. Use inline-block utilities to wrap the element to prevent the text inside from extending beyond its parent.

  16. Control the text color of an element to lg using the text-lg utilities.

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

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

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

  20. Control the background color of an element to purple-500 using the bg-purple-500 utilities.

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

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

Conclusion

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