Published on

The 5 Really Obvious Ways To Build A Gradient Grid Hero With Tailwind CSS Better That You Ever Did

Gradient grid hero

What is Tailwind CSS?

Tailwind CSS is a utility-first CSS framework that helps developers create responsive and customizable user interfaces quickly. It provides a set of pre-defined CSS classes that can be used to style HTML elements without writing any custom CSS. Tailwind CSS is gaining popularity among developers because of its simplicity, flexibility, and ease of use.

The description of Gradient grid hero ui component

A Gradient grid hero is a UI component that is commonly used in web design to create an attractive and engaging hero section. It consists of a full-width background image or video with a gradient overlay and text or call-to-action buttons overlaid on top. The gradient overlay adds depth and dimension to the background image or video, making it more visually appealing.

Why use Tailwind CSS to create a Gradient grid hero ui component?

Tailwind CSS provides a set of pre-defined gradient classes that can be used to create a Gradient grid hero quickly and easily. These classes allow developers to customize the gradient colors, direction, and opacity without writing any custom CSS. Tailwind CSS also provides a responsive design system that makes it easy to create a Gradient grid hero that looks great on all devices.

The preview of Gradient grid hero ui component

To create a Gradient grid hero with Tailwind CSS, we can use the following code:

<div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-48">
    <h1 class="text-4xl font-bold text-white">Welcome to my website</h1>
    <p class="mt-4 text-xl text-white">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    <a href="#" class="mt-8 bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded-full">Get started</a>
  </div>
</div>
{{__placeholder1__}}

This code creates a Gradient grid hero with a background gradient that goes from purple to pink to red. The hero section contains a heading, a paragraph, and a call-to-action button. The bg-gradient-to-r class is used to specify the gradient direction, which in this case is from left to right. The from-purple-400, via-pink-500, and to-red-500 classes are used to specify the gradient colors.

Free download of the Gradient grid hero's source code

The source code of Gradient grid hero ui component

To create a Gradient grid hero with Tailwind CSS, we can use the following code:

<div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-48">
    <h1 class="text-4xl font-bold text-white">Welcome to my website</h1>
    <p class="mt-4 text-xl text-white">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    <a href="#" class="mt-8 bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded-full">Get started</a>
  </div>
</div>
{{__placeholder2__}}

This code creates a Gradient grid hero with a background gradient that goes from purple to pink to red. The hero section contains a heading, a paragraph, and a call-to-action button. The bg-gradient-to-r class is used to specify the gradient direction, which in this case is from left to right. The from-purple-400, via-pink-500, and to-red-500 classes are used to specify the gradient colors.

<div class="flex flex-col  mx-auto -mt-20 overflow-hidden bg-gradient-to-r from-yellow-500 to-yellow-500">
  <div class="relative z-20 flex w-full min-h-screen px-5 pt-20 mx-auto sm:px-12 sm:h-screen max-w-7xl sm:pt-0 lg:px-0">
    <div class="w-full md:w-2/3">
      <div class="flex flex-col items-start justify-center w-full h-full pb-20">
        <div class="relative w-full lg:pl-10">
          <div class="flex items-center justify-center bg-white rounded-lg w-12 h-12 sm:rounded-xl">
            <svg class="w-12 h-12" fill="none">
              <path d="m.848 15.848 5.304 5.304L11 16.304l4.848 4.848 5.304-5.304L16.304 11l4.848-4.848L15.848.848 11 5.696 6.152.848.848 6.152 5.696 11 .848 15.848Zm30 0 5.304 5.304L41 16.304l4.848 4.848 5.304-5.304L46.304 11l4.848-4.848L45.848.848 41 5.696 36.152.848l-5.304 5.304L35.696 11l-4.848 4.848ZM11 37.25v7.5h30v-7.5H11Z" fill="#000" />
            </svg>
          </div>
          <h1 class="relative z-0 w-full max-w-md py-2 text-4xl font-black text-left text-white sm:py-5 sm:text-6xl" data-unsp-sanitized="clean">Side Title</h1>
        </div>

        <div class="flex flex-col items-start my-4 text-left lg:pl-10">
          <p class="max-w-md mb-10 text-base font-light text-gray-200 sm:text-lg lg:text-xl dark:text-dark-200">Lorem ipsum dolor sit amet consectetur adipisicing elit. Ab laborum deleniti eius aliquam tenetur quisquam maiores tempora odit, distinctio ex porro dolore atque nulla a dolorum similique ratione voluptas consequatur.</p>

          <div class="relative flex flex-col items-center justify-start w-full space-y-5 sm:w-auto lg:space-y-0 lg:space-x-5 lg:flex-row">
            <a href="#" class="flex items-center justify-center w-full px-8 py-3 text-base font-medium leading-6 text-white text-blue-600 transition duration-150 ease-in-out border border-transparent rounded-lg sm:w-auto sm:rounded-full bg-blue-50 xl:px-10 hover:bg-white focus:outline-none focus:border-blue-700 focus:shadow-outline-blue md:py-4 xl:text-xl" data-unsp-sanitized="clean">
                <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207" />
                </svg>
              btn
            </a>
            <a href="#" class="flex items-center justify-center w-full px-8 py-3 text-base font-medium leading-6 text-white text-blue-600 transition duration-150 ease-in-out border border-transparent rounded-lg sm:w-auto sm:rounded-full bg-blue-50 xl:px-10 hover:bg-white focus:outline-none focus:border-blue-700 focus:shadow-outline-blue md:py-4 xl:text-xl" data-unsp-sanitized="clean">
            <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13l-3 3m0 0l-3-3m3 3V8m0 13a9 9 0 110-18 9 9 0 010 18z" />
            </svg>
              Launch The App
            </a>
          </div>
        </div>
      </div>
    </div>

    <div class="relative w-0 md:w-1/2"></div>
  </div>
  <div class="absolute  top-0 left-0 z-0 flex items-start justify-center w-full h-screen overflow-hidden opacity-75">
    <div class="relative z-20 w-1/2">
      <div class="absolute top-0 left-0 w-full h-screen bg-gradient-to-r from-yellow-500 to-yellow-500"></div>
    </div>
    <div class="relative z-10 w-1/2 ">
      <div class="absolute top-0 right-0 hidden w-full h-full sm:block">
        <div class="flex items-center justify-center w-screen h-screen transform scale-75 -rotate-12 -translate-x-80 sm:-translate-x-64 sm:scale-125 md:scale-125 min-w-persp md:-translate-x-24">
          <div class="flex flex-col flex-wrap items-start justify-start w-full h-screen mx-auto space-x-3 space-y-3 transformPerspective">
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm mt-3 ml-3">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
            <div class="h-auto bg-gray-200 bg-cover rounded-lg overflow-hidden bg-top-center w-auto max-w-sm">
              <img src="https://source.unsplash.com/640x390/?tech,app" class="object-cover w-full h-auto" />
            </div>
          </div>
        </div>
      </div>
      <div class="absolute top-0 left-0 z-50 w-full h-screen bg-gradient-to-r from-yellow-500 t to-transparent"></div>
    </div>
  </div>
</div>

How to create a Gradient grid hero with Tailwind CSS?

To create a Gradient grid hero with Tailwind CSS, follow these steps:

  1. Create a new HTML file and add the following code:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Gradient grid hero with Tailwind CSS</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
</head>
<body>
  <div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
    <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-48">
      <h1 class="text-4xl font-bold text-white">Welcome to my website</h1>
      <p class="mt-4 text-xl text-white">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
      <a href="#" class="mt-8 bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded-full">Get started</a>
    </div>
  </div>
</body>
</html>
  1. Add the Tailwind CSS stylesheet to your HTML file by adding the following code to the head section:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
  1. Create a new div element with the bg-gradient-to-r class to create a Gradient grid hero with a right-to-left gradient. You can also use the bg-gradient-to-l class to create a left-to-right gradient.
<div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
  <!-- Hero content goes here -->
</div>
  1. Add the from-, via-, and to- classes to specify the gradient colors. You can use any of the pre-defined color names or HEX codes.
<div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
  <!-- Hero content goes here -->
</div>
  1. Add the hero content inside the div element. You can use any HTML elements, such as headings, paragraphs, or buttons.
<div class="bg-gradient-to-r from-purple-400 via-pink-500 to-red-500">
  <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-48">
    <h1 class="text-4xl font-bold text-white">Welcome to my website</h1>
    <p class="mt-4 text-xl text-white">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    <a href="#" class="mt-8 bg-white hover:bg-gray-100 text-gray-800 font-bold py-2 px-4 rounded-full">Get started</a>
  </div>
</div>
  1. Customize the hero content by adding Tailwind CSS classes to the HTML elements. You can use any of the pre-defined classes or create your own custom classes.

Conclusion

Creating a Gradient grid hero with Tailwind CSS is a simple and effective way to add an attractive and engaging hero section to your website. With Tailwind CSS, you can customize the gradient colors, direction, and opacity without writing any custom CSS. The responsive design system also makes it easy to create a Gradient grid hero that looks great on all devices.