Published on

6 Ideas To Help You Create A Simple Modern Modals With Tailwind CSS Like A Pro

Simple Modern Modals

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

Why use Tailwind CSS to build a Simple Modern Modals ui component?

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

The preview of Simple Modern Modals ui component

Free download of the Simple Modern Modals's source code

The source code of Simple Modern Modals ui component

<link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/>
<div class="flex flex-col justify-center items-center">
  <!-- Information Modal -->
	<div class="md:w-1/3 sm:w-full rounded-lg shadow-lg bg-white my-3">
        <div class="flex justify-between border-b border-gray-100 px-5 py-4">
      		<div>
              <i class="fas fa-exclamation-circle text-blue-500"></i>
              <span class="font-bold text-gray-700 text-lg">Information</span>
          	</div>
          <div>
              <button><i class="fa fa-times-circle text-red-500 hover:text-red-600 transition duration-150"></i></button>
          	</div>
      	</div>
      
      	<div class="px-10 py-5 text-gray-600">
          Lorem ipsum dolor sit amet, consectetur adipi scing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      	</div>
      
      	<div class="px-5 py-4 flex justify-end">
          <button class="text-sm py-2 px-3 text-gray-500 hover:text-gray-600 transition duration-150">Close</button>
      	</div>
	</div>
  
  	<!-- Warning Modal -->
	<div class="md:w-1/3 sm:w-full rounded-lg shadow-lg bg-white my-3">
        <div class="flex justify-between border-b border-gray-100 px-5 py-4">
      		<div>
              <i class="fa fa-exclamation-triangle text-orange-500"></i>
              <span class="font-bold text-gray-700 text-lg">Warning</span>
          	</div>
          	<div>
              <button><i class="fa fa-times-circle text-red-500 hover:text-red-600 transition duration-150"></i></button>
          	</div>
      	</div>
      
      	<div class="px-10 py-5 text-gray-600">
          Lorem ipsum dolor sit amet, consectetur adipi scing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      	</div>
      
      	<div class="px-5 py-4 flex justify-end">
          <button class="bg-orange-500 mr-1 rounded text-sm py-2 px-3 text-white hover:bg-orange-600 transition duration-150">Cancel</button>
          <button class="text-sm py-2 px-3 text-gray-500 hover:text-gray-600 transition duration-150">OK</button>
      	</div>
	</div>
  
  	<!-- Error Modal -->
	<div class="md:w-1/3 sm:w-full rounded-lg shadow-lg bg-white my-3">
        <div class="flex justify-between border-b border-gray-100 px-5 py-4">
      		<div>
              <i class="fa fa-exclamation-triangle text-red-500"></i>
              <span class="font-bold text-gray-700 text-lg">Error</span>
          	</div>
          	<div>
              <button><i class="fa fa-times-circle text-red-500 hover:text-red-600 transition duration-150"></i></button>
          	</div>
      	</div>
      
      	<div class="px-10 py-5 text-gray-600">
          Lorem ipsum dolor sit amet, consectetur adipi scing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
      	</div>
      
      	<div class="px-5 py-4 flex justify-end">
          <button class="text-sm py-2 px-3 text-gray-500 hover:text-gray-600 transition duration-150">OK</button>
      	</div>
	</div>
</div>

How to build a Simple Modern Modals with Tailwind CSS?

Install tailwind css of verion 1.4.6

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

<link href=https://unpkg.com/[email protected]4.6/dist/tailwind.min.css rel="stylesheet">

All the unility class needed to build a Simple Modern Modals component

  • flex
  • flex-col
  • md:w-1/3
  • sm:w-full
  • bg-white
  • my-3
  • border-b
  • border-gray-100
  • px-5
  • py-4
  • text-blue-500
  • text-gray-700
  • text-lg
  • text-red-500
  • hover:text-red-600
  • px-10
  • py-5
  • text-gray-600
  • text-sm
  • py-2
  • px-3
  • text-gray-500
  • hover:text-gray-600
  • text-orange-500
  • bg-orange-500
  • mr-1
  • text-white
  • hover:bg-orange-600

28 steps to build a Simple Modern Modals component with Tailwind CSS

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

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

  3. Use md:w-1/3 to set an element to a fixed width(1/3) at only medium screen sizes.

  4. Use w-full to set an element to a 100% based width at only small screen sizes.

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

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

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

  8. Control the border color of an element to gray-100 using the border-gray-100 utilities.

  9. Control the horizontal padding of an element to 1.25rem using the px-5 utilities.

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

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

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

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

  14. Control the text color of an element to red-500 using the text-red-500 utilities.

  15. Control the text color of an element to red-600 on hover using the hover:text-red-600 utilities.

  16. Control the horizontal padding of an element to 2.5rem using the px-10 utilities.

  17. Control the vertical padding of an element to 1.25rem using the py-5 utilities.

  18. Control the text color of an element to gray-600 using the text-gray-600 utilities.

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

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

  21. Control the horizontal padding of an element to 0.75rem using the px-3 utilities.

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

  23. Control the text color of an element to gray-600 on hover using the hover:text-gray-600 utilities.

  24. Control the text color of an element to orange-500 using the text-orange-500 utilities.

  25. Control the background color of an element to orange-500 using the bg-orange-500 utilities.

  26. Control the margin on right side of an element to 0.25rem using the mr-1 utilities.

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

  28. Control the background color of an element to orange-600 using the hover:bg-orange-600 utilities on hover.

Conclusion

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