- Published on
How to Create A website landing page With Tailwind CSS?

- What is Tailwind CSS?
- The description of website landing page ui component
- Why use Tailwind CSS to build a website landing page ui component?
- The preview of website landing page ui component
- The source code of website landing page ui component
- How to build a website landing page with Tailwind CSS?
- Install tailwind css of verion 3.0.18
- All the unility class needed to build a website landing page component
- 124 steps to build a website landing page 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 website landing page ui component
Website landing page tailwindcss
Why use Tailwind CSS to build a website landing page ui component?
- It can make the building process of website landing page ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in website landing page component file.
The preview of website landing page ui component
Free download of the website landing page's source code
The source code of website landing page ui component
<!-- Section 1 -->
<section class="w-full px-6 pb-12 antialiased bg-white">
<div class="mx-auto max-w-7xl">
<nav
class="relative z-50 h-24 select-none"
x-data="{ showMenu: false }"
>
<div
class="container relative flex flex-wrap items-center justify-between h-24 mx-auto overflow-hidden font-medium border-b border-gray-200 md:overflow-visible lg:justify-center sm:px-4 md:px-2"
>
<div class="flex items-center justify-start w-1/4 h-full pr-4">
<a href="#_" class="inline-block py-4 md:py-0">
<span class="p-1 text-xl font-black leading-none text-gray-900"
><span>tailwind</span
><span class="text-indigo-600">.</span></span
>
</a>
</div>
<div
class="top-0 left-0 items-start hidden w-full h-full p-4 text-sm bg-gray-900 bg-opacity-50 md:items-center md:w-3/4 md:absolute lg:text-base md:bg-transparent md:p-0 md:relative md:flex"
:class="{'flex fixed': showMenu, 'hidden': !showMenu }"
>
<div
class="flex-col w-full h-auto overflow-hidden bg-white rounded-lg md:bg-transparent md:overflow-visible md:rounded-none md:relative md:flex md:flex-row"
>
<a
href="#_"
class="inline-flex items-center block w-auto h-16 px-6 text-xl font-black leading-none text-gray-900 md:hidden"
>tails<span class="text-indigo-600">.</span></a
>
<div
class="flex flex-col items-start justify-center w-full space-x-6 text-center lg:space-x-8 md:w-2/3 md:mt-0 md:flex-row md:items-center"
>
<a
href="#_"
class="inline-block w-full py-2 mx-0 ml-6 font-medium text-left text-indigo-600 md:ml-0 md:w-auto md:px-0 md:mx-2 lg:mx-3 md:text-center"
>Home</a
>
<a
href="#_"
class="inline-block w-full py-2 mx-0 font-medium text-left text-gray-700 md:w-auto md:px-0 md:mx-2 hover:text-indigo-600 lg:mx-3 md:text-center"
>Features</a
>
<a
href="#_"
class="inline-block w-full py-2 mx-0 font-medium text-left text-gray-700 md:w-auto md:px-0 md:mx-2 hover:text-indigo-600 lg:mx-3 md:text-center"
>Blog</a
>
<a
href="#_"
class="inline-block w-full py-2 mx-0 font-medium text-left text-gray-700 md:w-auto md:px-0 md:mx-2 hover:text-indigo-600 lg:mx-3 md:text-center"
>Contact</a
>
<a
href="#_"
class="absolute top-0 left-0 hidden py-2 mt-6 ml-10 mr-2 text-gray-600 lg:inline-block md:mt-0 md:ml-2 lg:mx-3 md:relative"
>
<svg
class="inline w-5 h-5"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
></path>
</svg>
</a>
</div>
<div
class="flex flex-col items-start justify-end w-full pt-4 md:items-center md:w-1/3 md:flex-row md:py-0"
>
<a
href="#"
class="w-full px-6 py-2 mr-0 text-gray-700 md:px-0 lg:pl-2 md:mr-4 lg:mr-5 md:w-auto"
>Sign In</a
>
<a
href="#_"
class="inline-flex items-center w-full px-6 py-3 text-sm font-medium leading-4 text-white bg-indigo-600 md:px-3 md:w-auto md:rounded-full lg:px-5 hover:bg-indigo-500 focus:outline-none md:focus:ring-2 focus:ring-0 focus:ring-offset-2 focus:ring-indigo-600"
>Sign Up</a
>
</div>
</div>
</div>
<div
@click="showMenu = !showMenu"
class="absolute right-0 flex flex-col items-center items-end justify-center w-10 h-10 bg-white rounded-full cursor-pointer md:hidden hover:bg-gray-100"
>
<svg
class="w-6 h-6 text-gray-700"
x-show="!showMenu"
fill="none"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
viewBox="0 0 24 24"
stroke="currentColor"
x-cloak=""
>
<path d="M4 6h16M4 12h16M4 18h16"></path>
</svg>
<svg
class="w-6 h-6 text-gray-700"
x-show="showMenu"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
x-cloak=""
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M6 18L18 6M6 6l12 12"
></path>
</svg>
</div>
</div>
</nav>
<!-- Main Hero Content -->
<div
class="container max-w-lg px-4 py-32 mx-auto text-left md:max-w-none md:text-center"
>
<h1
class="text-5xl font-extrabold leading-10 tracking-tight text-left text-gray-900 md:text-center sm:leading-none md:text-6xl lg:text-7xl"
>
<span class="inline md:block">Start Crafting Your</span>
<span
class="relative mt-2 text-transparent bg-clip-text bg-gradient-to-br from-indigo-600 to-indigo-500 md:inline-block"
>Next Great Idea</span
>
</h1>
<div
class="mx-auto mt-5 text-gray-500 md:mt-12 md:max-w-lg md:text-center lg:text-lg"
>
Simplifying the creation of landing pages, blog pages, application
pages and so much more!
</div>
<div class="flex flex-col items-center mt-12 text-center">
<span class="relative inline-flex w-full md:w-auto">
<a
href="#_"
class="inline-flex items-center justify-center w-full px-8 py-4 text-base font-bold leading-6 text-white bg-indigo-600 border border-transparent rounded-full md:w-auto hover:bg-indigo-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-600"
>
Purchase Now
</a>
<span
class="absolute top-0 right-0 px-2 py-1 -mt-3 -mr-6 text-xs font-medium leading-tight text-white bg-green-400 rounded-full"
>only $15/mo</span
>
</span>
<a href="#" class="mt-3 text-sm text-indigo-500">Learn More</a>
</div>
</div>
<!-- End Main Hero Content -->
</div>
</section>
How to build a website landing page with Tailwind CSS?
Install tailwind css of verion 3.0.18
Use the script
html tag to import the script of Tailwind CSS of the version 3.0.18
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a website landing page component
w-full
px-6
pb-12
bg-white
mx-auto
max-w-7xl
relative
z-50
h-24
flex
flex-wrap
overflow-hidden
border-b
border-gray-200
md:overflow-visible
sm:px-4
md:px-2
justify-start
w-1/4
h-full
pr-4
inline-block
py-4
md:py-0
p-1
text-xl
text-gray-900
text-indigo-600
top-0
left-0
hidden
p-4
text-sm
bg-gray-900
bg-opacity-50
md:w-3/4
md:absolute
lg:text-base
md:bg-transparent
md:p-0
md:relative
md:flex
fixed
flex-col
h-auto
md:flex-row
inline-flex
block
w-auto
h-16
md:hidden
text-center
md:w-2/3
md:mt-0
py-2
mx-0
ml-6
text-left
md:ml-0
md:w-auto
md:px-0
md:mx-2
lg:mx-3
md:text-center
text-gray-700
hover:text-indigo-600
absolute
mt-6
ml-10
mr-2
text-gray-600
lg:inline-block
md:ml-2
inline
w-5
h-5
pt-4
md:w-1/3
mr-0
lg:pl-2
md:mr-4
lg:mr-5
py-3
text-white
bg-indigo-600
md:px-3
lg:px-5
hover:bg-indigo-500
right-0
w-10
h-10
hover:bg-gray-100
w-6
h-6
max-w-lg
px-4
py-32
md:max-w-none
text-5xl
md:text-6xl
lg:text-7xl
md:block
mt-2
text-transparent
bg-clip-text
bg-gradient-to-br
md:inline-block
mt-5
text-gray-500
md:mt-12
md:max-w-lg
lg:text-lg
mt-12
px-8
text-base
border-transparent
px-2
py-1
-mt-3
-mr-6
text-xs
bg-green-400
mt-3
text-indigo-500
124 steps to build a website landing page component with Tailwind CSS
Use
w-full
to set an element to a 100% based width.Control the horizontal padding of an element to 1.5rem using the
px-6
utilities.Control the padding on bottom side of an element to 3rem using the
pb-12
utilities.Control the background color of an element to white using the
bg-white
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Set the maximum width/height of an element using the
max-w-7xl
utilities.Use
relative
to position an element according to the normal flow of the document.Control the stack order (or three-dimensional positioning) of an element to 50 in Tailwind, regardless of order it has been displayed, using the
z-50
utilities.Use
h-24
to set an element to a fixed height(6rem).Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Control the border color of an element to b using the
border-b
utilities.Control the border color of an element to gray-200 using the
border-gray-200
utilities.Use
overflow-visible
to prevent content within an element from being clipped at only medium screen sizes. Note that any content that overflows the bounds of the element will then be visible.Control the horizontal padding of an element to 1rem at only small screen sizes using the
sm:px-4
utilities.Control the horizontal padding of an element to 0.5rem at only medium screen sizes using the
md:px-2
utilities.Use
justify-start
to justify items against the start of the container’s main axis.Use
w-1/4
to set an element to a fixed width(1/4).Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Control the padding on right side of an element to 1rem using the
pr-4
utilities.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent.Control the vertical padding of an element to 1rem using the
py-4
utilities.Control the vertical padding of an element to 0rem at only medium screen sizes using the
md:py-0
utilities.Control the padding on all sides of an element to 0.25rem using the
p-1
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the text color of an element to gray-900 using the
text-gray-900
utilities.Control the text color of an element to indigo-600 using the
text-indigo-600
utilities.Use the
top-0
utilities to set the top position of a positioned element to 0rem.Use the
left-0
utilities to set the left position of a positioned element to 0rem.Use
hidden
to set an element to display: none and remove it from the page layout.Control the padding on all sides of an element to 1rem using the
p-4
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the background color of an element to gray-900 using the
bg-gray-900
utilities.Control the background color of an element to opacity-50 using the
bg-opacity-50
utilities.Use
md:w-3/4
to set an element to a fixed width(3/4) at only medium screen sizes.Use
absolute
to position an element outside of the normal flow of the document at only medium screen sizes, causing neighboring elements to act as if the element doesn’t exist.Control the text color of an element to base at only large screen sizes using the
lg:text-base
utilities.Control the background color of an element to transparent using the
md:bg-transparent
utilities at only medium screen sizes.Control the padding on all sides of an element to 0rem at only medium screen sizes using the
md:p-0
utilities.Use
relative
to position an element according to the normal flow of the document at only medium screen sizes.Use
flex
to create a block-level flex container at only medium screen sizes.Use
fixed
to position an element relative to the browser window.Use
flex
to create a block-level flex container.Use
h-auto
to set an element to a fixed height(auto).Use
flex
to create a block-level flex container at only medium screen sizes.Use
inline-flex
to create an inline flex container that flows with text.Use
inline
utilities to put the element on its own line and fill its parent.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.Use
h-16
to set an element to a fixed height(4rem).Use
hidden
to set an element to display: none and remove it from the page layout at only medium screen sizes.Control the text color of an element to center using the
text-center
utilities.Use
md:w-2/3
to set an element to a fixed width(2/3) at only medium screen sizes.Control the margin on top side of an element to 0rem at only medium screen sizes using the
md:mt-0
utilities.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.Control the horizontal margin of an element to 0rem using the
mx-0
utilities.Control the margin on left side of an element to 1.5rem using the
ml-6
utilities.Control the text color of an element to left using the
text-left
utilities.Control the margin on left side of an element to 0rem at only medium screen sizes using the
md:ml-0
utilities.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 0rem at only medium screen sizes using the
md:px-0
utilities.Control the horizontal margin of an element to 0.5rem at only medium screen sizes using the
md:mx-2
utilities.Control the horizontal margin of an element to 0.75rem at only large screen sizes using the
lg:mx-3
utilities.Control the text color of an element to center at only medium screen sizes using the
md:text-center
utilities.Control the text color of an element to gray-700 using the
text-gray-700
utilities.Control the text color of an element to indigo-600 on hover using the
hover:text-indigo-600
utilities.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.Control the margin on top side of an element to 1.5rem using the
mt-6
utilities.Control the margin on left side of an element to 2.5rem using the
ml-10
utilities.Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Control the text color of an element to gray-600 using the
text-gray-600
utilities.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent at only large screen sizes.Control the margin on left side of an element to 0.5rem at only medium screen sizes using the
md:ml-2
utilities.Use
inline
utilities to control the flow of text inside the element to wrap normally.Use
w-5
to set an element to a fixed width(1.25rem).Use
h-5
to set an element to a fixed height(1.25rem).Control the padding on top side of an element to 1rem using the
pt-4
utilities.Use
md:w-1/3
to set an element to a fixed width(1/3) at only medium screen sizes.Control the margin on right side of an element to 0rem using the
mr-0
utilities.Adjust the left padding of an element to 0.5rem at only large screen sizes using the
lg:pl-2
utilities classControl the margin on right side of an element to 1rem at only medium screen sizes using the
md:mr-4
utilities.Control the margin on right side of an element to 1.25rem at only large screen sizes using the
lg:mr-5
utilities.Control the vertical padding of an element to 0.75rem using the
py-3
utilities.Control the text color of an element to white using the
text-white
utilities.Control the background color of an element to indigo-600 using the
bg-indigo-600
utilities.Control the horizontal padding of an element to 0.75rem at only medium screen sizes using the
md:px-3
utilities.Control the horizontal padding of an element to 1.25rem at only large screen sizes using the
lg:px-5
utilities.Control the background color of an element to indigo-500 using the
hover:bg-indigo-500
utilities on hover.Use the
right-0
utilities to set the right position of a positioned element to 0rem.Use
w-10
to set an element to a fixed width(2.5rem).Use
h-10
to set an element to a fixed height(2.5rem).Control the background color of an element to gray-100 using the
hover:bg-gray-100
utilities on hover.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).Set the maximum width/height of an element using the
max-w-lg
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the vertical padding of an element to 8rem using the
py-32
utilities.Set the maximum width/height of an element using the
md:max-w-none
utilities at only medium screen sizes.Control the text color of an element to 5xl using the
text-5xl
utilities.Control the text color of an element to 6xl at only medium screen sizes using the
md:text-6xl
utilities.Control the text color of an element to 7xl at only large screen sizes using the
lg:text-7xl
utilities.Use
inline
utilities to put the element on its own line and fill its parent at only medium screen sizes.Control the margin on top side of an element to 0.5rem using the
mt-2
utilities.Control the text color of an element to transparent using the
text-transparent
utilities.Control the background color of an element to clip-text using the
bg-clip-text
utilities.Control the background color of an element to gradient-to-br using the
bg-gradient-to-br
utilities.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent at only medium screen sizes.Control the margin on top side of an element to 1.25rem using the
mt-5
utilities.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Control the margin on top side of an element to 3rem at only medium screen sizes using the
md:mt-12
utilities.Set the maximum width/height of an element using the
md:max-w-lg
utilities at only medium screen sizes.Control the text color of an element to lg at only large screen sizes using the
lg:text-lg
utilities.Control the margin on top side of an element to 3rem using the
mt-12
utilities.Control the horizontal padding of an element to 2rem using the
px-8
utilities.Control the text color of an element to base using the
text-base
utilities.Control the border color of an element to transparent using the
border-transparent
utilities.Control the horizontal padding of an element to 0.5rem using the
px-2
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the margin on top side of an element to -0.75rem using the
-mt-3
utilities.Control the margin on right side of an element to -1.5rem using the
-mr-6
utilities.Control the text color of an element to xs using the
text-xs
utilities.Control the background color of an element to green-400 using the
bg-green-400
utilities.Control the margin on top side of an element to 0.75rem using the
mt-3
utilities.Control the text color of an element to indigo-500 using the
text-indigo-500
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a website landing page components, learn and follow along to implement your own components.