Published on

Beginners Guide: Build A Form Login With Tailwind CSS

Form Login

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

Create form login and use flexbox and positionig

Why use Tailwind CSS to build a Form Login ui component?

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

The preview of Form Login ui component

Free download of the Form Login's source code

The source code of Form Login ui component

<div class="min-h-screen bg-purple-400 flex justify-center items-center">
	<div class="absolute w-60 h-60 rounded-xl bg-purple-300 -top-5 -left-16 z-0 transform rotate-45 hidden md:block">
	</div>
	<div class="absolute w-48 h-48 rounded-xl bg-purple-300 -bottom-6 -right-10 transform rotate-12 hidden md:block">
	</div>
	<div class="py-12 px-12 bg-white rounded-2xl shadow-xl z-20">
		<div>
			<h1 class="text-3xl font-bold text-center mb-4 cursor-pointer">Create An Account</h1>
			<p class="w-80 text-center text-sm mb-8 font-semibold text-gray-700 tracking-wide cursor-pointer">Create an
				account to enjoy all the services without any ads for free!</p>
		</div>
		<div class="space-y-4">
			<input type="text" placeholder="Email Addres" class="block text-sm py-3 px-4 rounded-lg w-full border outline-none" />
			<input type="text" placeholder="Password" class="block text-sm py-3 px-4 rounded-lg w-full border outline-none" />
    </div>
			<div class="text-center mt-6">
				<button class="py-3 w-64 text-xl text-white bg-purple-400 rounded-2xl">Create Account</button>
				<p class="mt-4 text-sm">Already Have An Account? <span class="underline cursor-pointer"> Sign In</span>
				</p>
			</div>
		</div>
		<div class="w-40 h-40 absolute bg-purple-300 rounded-full top-0 right-12 hidden md:block"></div>
		<div
			class="w-20 h-40 absolute bg-purple-300 rounded-full bottom-20 left-10 transform rotate-45 hidden md:block">
		</div>
	</div>

How to build a Form Login 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 Form Login component

  • min-h-screen
  • bg-purple-400
  • flex
  • absolute
  • w-60
  • h-60
  • bg-purple-300
  • -top-5
  • -left-16
  • z-0
  • hidden
  • md:block
  • w-48
  • h-48
  • -bottom-6
  • -right-10
  • py-12
  • px-12
  • bg-white
  • z-20
  • text-3xl
  • text-center
  • mb-4
  • w-80
  • text-sm
  • mb-8
  • text-gray-700
  • block
  • py-3
  • px-4
  • w-full
  • mt-6
  • w-64
  • text-xl
  • text-white
  • mt-4
  • w-40
  • h-40
  • top-0
  • right-12
  • w-20
  • bottom-20
  • left-10

43 steps to build a Form Login component with Tailwind CSS

  1. Set the minimum width/height of an element using the min-h-screen utilities.

  2. Control the background color of an element to purple-400 using the bg-purple-400 utilities.

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

  4. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

  5. Use w-60 to set an element to a fixed width(15rem).

  6. Use h-60 to set an element to a fixed height(15rem).

  7. Control the background color of an element to purple-300 using the bg-purple-300 utilities.

  8. Use the -top-5 utilities to set the top position of a positioned element to -1.25rem.

  9. Use the -left-16 utilities to set the left position of a positioned element to -4rem.

  10. Control the stack order (or three-dimensional positioning) of an element to 0 in Tailwind, regardless of order it has been displayed, using the z-0 utilities.

  11. Use hidden to set an element to display: none and remove it from the page layout.

  12. Use inline utilities to put the element on its own line and fill its parent at only medium screen sizes.

  13. Use w-48 to set an element to a fixed width(12rem).

  14. Use h-48 to set an element to a fixed height(12rem).

  15. Use the -bottom-6 utilities to set the bottom position of a positioned element to -1.5rem.

  16. Use the -right-10 utilities to set the right position of a positioned element to -2.5rem.

  17. Control the vertical padding of an element to 3rem using the py-12 utilities.

  18. Control the horizontal padding of an element to 3rem using the px-12 utilities.

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

  20. Control the stack order (or three-dimensional positioning) of an element to 20 in Tailwind, regardless of order it has been displayed, using the z-20 utilities.

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

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

  23. Control the margin on bottom side of an element to 1rem using the mb-4 utilities.

  24. Use w-80 to set an element to a fixed width(20rem).

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

  26. Control the margin on bottom side of an element to 2rem using the mb-8 utilities.

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

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

  29. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

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

  31. Use w-full to set an element to a 100% based width.

  32. Control the margin on top side of an element to 1.5rem using the mt-6 utilities.

  33. Use w-64 to set an element to a fixed width(16rem).

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

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

  36. Control the margin on top side of an element to 1rem using the mt-4 utilities.

  37. Use w-40 to set an element to a fixed width(10rem).

  38. Use h-40 to set an element to a fixed height(10rem).

  39. Use the top-0 utilities to set the top position of a positioned element to 0rem.

  40. Use the right-12 utilities to set the right position of a positioned element to 3rem.

  41. Use w-20 to set an element to a fixed width(5rem).

  42. Use the bottom-20 utilities to set the bottom position of a positioned element to 5rem.

  43. Use the left-10 utilities to set the left position of a positioned element to 2.5rem.

Conclusion

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