Published on

How To Make A Grid Template Rows With Tailwind CSS From Scratch

Tags
Grid template rows

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 Grid template rows ui component

Example component divided with grid template rows and fontawesome icons

Why use Tailwind CSS to build a Grid template rows ui component?

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

The preview of Grid template rows ui component

Free download of the Grid template rows's source code

The source code of Grid template rows ui component

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">

<!-- This is an example component divided with grid template rows and fontawesome icons -->
<!-- More info: https://tailwindcss.com/docs/grid-template-rows   -->
<div class="bg-indigo-800 dark:bg-light_secondary rounded-lg py-5 px-5">
	<div class="grid grid-rows-2 gap-5">
		<div class="row-span-1">
			<h1 class="text-1xl md:text-2xl text-white mb-5">Follow me</h1>
			<div class="grid grid-cols-3 gap-2 px-10">
				<div class="flex justify-between items-center mt-5">
					<!-- Facebook -->
					<a class="cursor-pointer items-center" href="#" target="_blank">
						<div
							class="text-white hover:text-blue-600 rounded-full hover:scale-105 transform transition-all duration-500">
							<i class="fab fa-facebook text-5xl"></i>
						</div>
					</a>
					<!-- Facebook -->
					<!-- Twitter -->
					<a class="cursor-pointer items-center" href="#" target="_blank">
						<div
							class="text-white hover:text-blue-400 rounded-full hover:scale-105 transform transition-all duration-500">
							<i class="fab fa-twitter text-5xl"></i>
						</div>
					</a>
					<!-- Twitter -->
					<!-- Instagram -->
					<a class="cursor-pointer items-center" href="#" target="_blank">
						<div
							class="text-white hover:text-pink-600 rounded-full hover:scale-105 transform transition-all duration-500">
							<i class="fab fa-instagram text-5xl"></i>
						</div>
					</a>
					<!-- Instagram -->
				</div>
			</div>
		</div>
		<div class="row-span-2">
			<h1 class="text-1xl md:text-2xl text-white mb-5">My posts</h1>
			<div class="grid grid-cols-3 px-10 gap-2">
				<div class="flex justify-center items-center">
					<a class="cursor-pointer" href="#">
						<div class="hover:scale-105 transform transition-all duration-500">
							<img class="h-30 rounded-lg"
								src="https://cdn.pixabay.com/photo/2020/07/21/16/24/landscape-5426755_960_720.jpg" alt="image" />
						</div>
					</a>
				</div>
				<div class="flex justify-center items-center">
					<a class="cursor-pointer" href="#">
						<div class="hover:scale-105 transform transition-all duration-500">
							<img class="h-30 rounded-lg"
								src="https://cdn.pixabay.com/photo/2020/07/21/16/24/landscape-5426755_960_720.jpg" alt="image" />
						</div>
					</a>
				</div>
				<div class="flex justify-center items-center">
					<a class="cursor-pointer" href="#">
						<div class="hover:scale-105 transform transition-all duration-500">
							<img class="h-30 rounded-lg"
								src="https://cdn.pixabay.com/photo/2020/07/21/16/24/landscape-5426755_960_720.jpg" alt="image" />
						</div>
					</a>
				</div>
			</div>
		</div>
	</div>
</div>

How to build a Grid template rows 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 Grid template rows component

  • bg-indigo-800
  • dark:bg-light_secondary
  • py-5
  • px-5
  • grid
  • grid-rows-2
  • gap-5
  • text-1xl
  • md:text-2xl
  • text-white
  • mb-5
  • grid-cols-3
  • gap-2
  • px-10
  • flex
  • mt-5
  • hover:text-blue-600
  • text-5xl
  • hover:text-blue-400
  • hover:text-pink-600
  • h-30

21 steps to build a Grid template rows component with Tailwind CSS

  1. Control the background color of an element to indigo-800 using the bg-indigo-800 utilities.

  2. Control the background color of an element to light_secondary using the dark:bg-light_secondary utilities in dark theme.

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

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

  5. Use grid to create a grid container.

  6. Use grid to create a grid container.

  7. To specify the width between columns, you can use the gap-5 utilities.

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

  9. Control the text color of an element to 2xl at only medium screen sizes using the md:text-2xl utilities.

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

  11. Control the margin on bottom side of an element to 1.25rem using the mb-5 utilities.

  12. Use grid to create a grid container.

  13. To specify the width between columns, you can use the gap-2 utilities.

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

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

  16. Control the margin on top side of an element to 1.25rem using the mt-5 utilities.

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

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

  19. Control the text color of an element to blue-400 on hover using the hover:text-blue-400 utilities.

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

  21. Use h-30 to set an element to a fixed height(7.5rem).

Conclusion

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