- Published on
What You Need To Make A Hero With Image With Tailwind CSS

- What is Tailwind CSS?
- The description of Hero With Image ui component
- Why use Tailwind CSS to make a Hero With Image ui component?
- The preview of Hero With Image ui component
- The source code of Hero With Image ui component
- How to make a Hero With Image with Tailwind CSS?
- Install tailwind css of verion 2.2.19
- All the unility class needed to make a Hero With Image component
- 76 steps to make a Hero With Image component with Tailwind CSS
- Conclusion
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 Hero With Image ui component
Hero with image form merakiui.com
Why use Tailwind CSS to make a Hero With Image ui component?
- It can make the building process of Hero With Image ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Hero With Image component file.
The preview of Hero With Image ui component
Free download of the Hero With Image's source code
The source code of Hero With Image ui component
<section class="bg-white dark:bg-gray-800">
<nav class="container p-6 mx-auto lg:flex lg:justify-between lg:items-center">
<div class="flex items-center justify-between">
<div>
<a class="text-2xl font-bold text-gray-800 dark:text-white lg:text-3xl hover:text-gray-700 dark:hover:text-gray-300" href="#">Brand</a>
</div>
<!-- Mobile menu button -->
<div class="flex lg:hidden">
<button type="button"
class="text-gray-500 hover:text-gray-600 focus:outline-none focus:text-gray-600"
aria-label="toggle menu">
<svg viewBox="0 0 24 24" class="w-6 h-6 fill-current">
<path fill-rule="evenodd"
d="M4 5h16a1 1 0 0 1 0 2H4a1 1 0 1 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2zm0 6h16a1 1 0 0 1 0 2H4a1 1 0 0 1 0-2z">
</path>
</svg>
</button>
</div>
</div>
<!-- Mobile Menu open: "block", Menu closed: "hidden" -->
<div class="flex flex-col mt-4 space-y-2 lg:-mx-6 lg:mt-0 lg:flex-row lg:space-y-0">
<a class="text-gray-700 dark:text-gray-200 lg:px-6 dark:hover:text-blue-400 hover:text-blue-500"
href="#">Home</a>
<a class="text-gray-700 dark:text-gray-200 lg:px-6 dark:hover:text-blue-400 hover:text-blue-500"
href="#">Components</a>
<a class="text-gray-700 dark:text-gray-200 lg:px-6 dark:hover:text-blue-400 hover:text-blue-500"
href="#">Pricing</a>
<a class="text-gray-700 dark:text-gray-200 lg:px-6 dark:hover:text-blue-400 hover:text-blue-500"
href="#">Contact</a>
<a class="text-gray-700 dark:text-gray-200 lg:px-6 dark:hover:text-blue-400 hover:text-blue-500"
href="#">FAQ</a>
</div>
<a class="block h-10 px-5 py-2 mt-4 text-sm text-center text-gray-700 capitalize transition-colors duration-200 transform border rounded-md dark:hover:bg-gray-700 dark:text-white lg:mt-0 hover:bg-gray-100 lg:w-auto"
href="#">
Contact Us
</a>
</nav>
<div class="container flex flex-col px-6 py-10 mx-auto space-y-6 lg:h-[32rem] lg:py-16 lg:flex-row lg:items-center">
<div class="w-full lg:w-1/2">
<div class="lg:max-w-lg">
<h1 class="text-3xl font-bold tracking-wide text-gray-800 dark:text-white lg:text-5xl">
Easiest way to create your website
</h1>
<div class="mt-8 space-y-5">
<p class="flex items-center -mx-2 text-gray-700 dark:text-gray-200">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 mx-2 text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="mx-2">Clean and Simple Layout</span>
</p>
<p class="flex items-center -mx-2 text-gray-700 dark:text-gray-200">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 mx-2 text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="mx-2">Just Copy Paste Codeing</span>
</p>
<p class="flex items-center -mx-2 text-gray-700 dark:text-gray-200">
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 mx-2 text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="mx-2">Easy to Use</span>
</p>
</div>
</div>
<div class="w-full mt-8 bg-transparent border rounded-md lg:max-w-sm dark:border-gray-700 focus-within:border-blue-400 focus-within:ring focus-within:ring-blue-300 dark:focus-within:border-blue-400 focus-within:ring-opacity-40">
<form class="flex flex-col lg:flex-row">
<input type="email" placeholder="Enter your email address" class="flex-1 h-10 px-4 py-2 m-1 text-gray-700 placeholder-gray-400 bg-transparent border-none appearance-none dark:text-gray-200 focus:outline-none focus:placeholder-transparent focus:ring-0" />
<button type="button" class="h-10 px-4 py-2 m-1 text-white transition-colors duration-200 transform bg-blue-500 rounded-md hover:bg-blue-400 focus:outline-none focus:bg-blue-400">
Join Us
</button>
</form>
</div>
</div>
<div class="flex items-center justify-center w-full h-96 lg:w-1/2">
<img class="object-cover w-full h-full mx-auto rounded-md lg:max-w-2xl" src="https://images.unsplash.com/photo-1543269664-7eef42226a21?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80" alt="glasses photo">
</div>
</div>
</section>
<div class="fixed inset-x-0 lg:inset-x-auto bottom-6 lg:right-8 xl:right-10 xl:bottom-8">
<div class="lg:w-72 px-6 lg:px-0">
<div class="p-2 bg-blue-600 rounded-lg shadow-lg sm:p-3">
<div class="flex flex-wrap items-center justify-between">
<a target="_blank" href="https://www.buymeacoffee.com/khatabwedaa" class="flex items-center flex-1 w-0">
<span class="flex p-2 bg-blue-800 rounded-lg">
<svg class="h-6 w-6 text-white" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.12954 3.00772C5.48563 2.38457 6.14831 2 6.86603 2H17.134C17.8517 2 18.5144 2.38457 18.8704 3.00772L20.0133 5.00772C20.6612 6.14163 20.0618 7.51107 18.9235 7.89532C18.9276 7.97661 18.9269 8.0591 18.9209 8.14249L18.0638 20.1425C17.989 21.1891 17.1181 22 16.0689 22H7.9311C6.88182 22 6.01094 21.1891 5.93618 20.1425L5.07904 8.14249C5.07308 8.0591 5.07231 7.97661 5.07645 7.89531C3.93813 7.51105 3.33874 6.14162 3.98668 5.00772L5.12954 3.00772ZM7.07396 8L7.28824 11H16.7117L16.926 8H7.07396ZM7.71681 17L7.9311 20H16.0689L16.2831 17H7.71681ZM18.2768 6L17.134 4L6.86603 4L5.72317 6H18.2768Z" fill="currentColor"></path>
</svg>
</span>
<p class="ml-3 font-medium tracking-wide text-white truncate">
By me a coffee
</p>
</a>
</div>
</div>
</div>
</div>
How to make a Hero With Image with Tailwind CSS?
Install tailwind css of verion 2.2.19
Use the script
html tag to import the script of Tailwind CSS of the version 2.2.19
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to make a Hero With Image component
bg-white
dark:bg-gray-800
p-6
mx-auto
lg:flex
flex
text-2xl
text-gray-800
dark:text-white
lg:text-3xl
hover:text-gray-700
lg:hidden
text-gray-500
hover:text-gray-600
focus:text-gray-600
w-6
h-6
flex-col
mt-4
lg:-mx-6
lg:mt-0
lg:flex-row
text-gray-700
dark:text-gray-200
lg:px-6
hover:text-blue-500
block
h-10
px-5
py-2
text-sm
text-center
hover:bg-gray-100
lg:w-auto
px-6
py-10
lg:h-[32rem]
lg:py-16
w-full
lg:w-1/2
lg:max-w-lg
text-3xl
lg:text-5xl
mt-8
-mx-2
mx-2
text-blue-500
bg-transparent
lg:max-w-sm
dark:border-gray-700
focus-within:border-blue-400
flex-1
px-4
m-1
border-none
text-white
bg-blue-500
hover:bg-blue-400
focus:bg-blue-400
h-96
h-full
lg:max-w-2xl
fixed
bottom-6
lg:right-8
xl:right-10
xl:bottom-8
lg:w-72
lg:px-0
p-2
bg-blue-600
sm:p-3
flex-wrap
w-0
bg-blue-800
ml-3
76 steps to make a Hero With Image component with Tailwind CSS
Control the background color of an element to white using the
bg-white
utilities.Control the background color of an element to gray-800 using the
dark:bg-gray-800
utilities in dark theme.Control the padding on all sides of an element to 1.5rem using the
p-6
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Use
flex
to create a block-level flex container at only large screen sizes.Use
flex
to create a block-level flex container.Control the text color of an element to 2xl using the
text-2xl
utilities.Control the text color of an element to gray-800 using the
text-gray-800
utilities.Control the text color of an element to white in dark theme using the
dark:text-white
utilities.Control the text color of an element to 3xl at only large screen sizes using the
lg:text-3xl
utilities.Control the text color of an element to gray-700 on hover using the
hover:text-gray-700
utilities.Use
hidden
to set an element to display: none and remove it from the page layout at only large screen sizes.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Control the text color of an element to gray-600 on hover using the
hover:text-gray-600
utilities.Control the text color of an element to gray-600 on focus using the
focus:text-gray-600
utilities.Use
w-6
to set an element to a fixed width(1.5rem).Use
h-6
to set an element to a fixed height(1.5rem).Use
flex
to create a block-level flex container.Control the margin on top side of an element to 1rem using the
mt-4
utilities.Control the horizontal margin of an element to -1.5rem at only large screen sizes using the
lg:-mx-6
utilities.Control the margin on top side of an element to 0rem at only large screen sizes using the
lg:mt-0
utilities.Use
flex
to create a block-level flex container at only large screen sizes.Control the text color of an element to gray-700 using the
text-gray-700
utilities.Control the text color of an element to gray-200 in dark theme using the
dark:text-gray-200
utilities.Control the horizontal padding of an element to 1.5rem at only large screen sizes using the
lg:px-6
utilities.Control the text color of an element to blue-500 on hover using the
hover:text-blue-500
utilities.Use
inline
utilities to put the element on its own line and fill its parent.Use
h-10
to set an element to a fixed height(2.5rem).Control the horizontal padding of an element to 1.25rem using the
px-5
utilities.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the text color of an element to center using the
text-center
utilities.Control the background color of an element to gray-100 using the
hover:bg-gray-100
utilities on hover.The
w-auto
utility can be useful if you need to remove an element’s assigned width under a specific condition, like at a particular breakpoint.Control the horizontal padding of an element to 1.5rem using the
px-6
utilities.Control the vertical padding of an element to 2.5rem using the
py-10
utilities.Use
lg:h-[32rem]
to set an element to a fixed height([32rem]) at only large screen sizes.Control the vertical padding of an element to 4rem at only large screen sizes using the
lg:py-16
utilities.Use
w-full
to set an element to a 100% based width.Use
lg:w-1/2
to set an element to a fixed width(1/2) at only large screen sizes.Set the maximum width/height of an element using the
lg:max-w-lg
utilities at only large screen sizes.Control the text color of an element to 3xl using the
text-3xl
utilities.Control the text color of an element to 5xl at only large screen sizes using the
lg:text-5xl
utilities.Control the margin on top side of an element to 2rem using the
mt-8
utilities.Control the horizontal margin of an element to -0.5rem using the
-mx-2
utilities.Control the horizontal margin of an element to 0.5rem using the
mx-2
utilities.Control the text color of an element to blue-500 using the
text-blue-500
utilities.Control the background color of an element to transparent using the
bg-transparent
utilities.Set the maximum width/height of an element using the
lg:max-w-sm
utilities at only large screen sizes.Control the border color of an element to gray-700 using the
dark:border-gray-700
utilities in dark theme.Control the border color of an element to blue-400 using the
focus-within:border-blue-400
utilitiesundefined.Use
flex
to create a block-level flex container.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the margin on all sides of an element to 0.25rem using the
m-1
utilities.Control the border color of an element to none using the
border-none
utilities.Control the text color of an element to white using the
text-white
utilities.Control the background color of an element to blue-500 using the
bg-blue-500
utilities.Control the background color of an element to blue-400 using the
hover:bg-blue-400
utilities on hover.Control the background color of an element to blue-400 using the
focus:bg-blue-400
utilities on focus.Use
h-96
to set an element to a fixed height(24rem).Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Set the maximum width/height of an element using the
lg:max-w-2xl
utilities at only large screen sizes.Use
fixed
to position an element relative to the browser window.Use the
bottom-6
utilities to set the bottom position of a positioned element to 1.5rem.Use the
lg:right-8
utilities to set the right position of a positioned element to 2rem at only large screen sizes.Use the
xl:right-10
utilities to set the right position of a positioned element to 2.5rem at only extremely large screen sizes.Use the
xl:bottom-8
utilities to set the bottom position of a positioned element to 2rem at only extremely large screen sizes.Use
lg:w-72
to set an element to a fixed width(18rem) at only large screen sizes.Control the horizontal padding of an element to 0rem at only large screen sizes using the
lg:px-0
utilities.Control the padding on all sides of an element to 0.5rem using the
p-2
utilities.Control the background color of an element to blue-600 using the
bg-blue-600
utilities.Control the padding on all sides of an element to 0.75rem at only small screen sizes using the
sm:p-3
utilities.Use
flex
to create a block-level flex container.Use
w-0
to set an element to a fixed width(0rem).Control the background color of an element to blue-800 using the
bg-blue-800
utilities.Control the margin on left side of an element to 0.75rem using the
ml-3
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to make a Hero With Image components, learn and follow along to implement your own components.