- Published on
The Ninja Guide To How To Create A Header With Tailwind CSS Better

- What is Tailwind CSS?
- The description of header ui component
- Why use Tailwind CSS to build a header ui component?
- The preview of header ui component
- The source code of header ui component
- How to build a header with Tailwind CSS?
- Install tailwind css of verion 2.1.4
- All the unility class needed to build a header component
- 8 steps to build a header 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 header ui component
At the begin of page
Why use Tailwind CSS to build a header ui component?
- It can make the building process of header ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in header component file.
The preview of header ui component
Free download of the header's source code
The source code of header ui component
<style>
.bannerFondo {
height: 400px;
}
.orse {
background-color: #128386
}
</style>
<div>
<div class="bannerFondo orse"></div>
<div class="-mt-64 mb-10">
<div class="w-full text-center">
<p class="text-sm tracking-widest text-white uppercase">message</p>
<h1 class="font-bold text-5xl text-white uppercase">
header
</h1>
</div>
</div>
</div>
<!-- <div class="overflow-x-hidden bg-gray-100">
if used at begin of page try to rap body with this div
</div> -->
How to build a header with Tailwind CSS?
Install tailwind css of verion 2.1.4
Use the script
html tag to import the script of Tailwind CSS of the version 2.1.4
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to build a header component
-mt-64
mb-10
w-full
text-center
text-sm
text-white
text-5xl
bg-gray-100
8 steps to build a header component with Tailwind CSS
Control the margin on top side of an element to -16rem using the
-mt-64
utilities.Control the margin on bottom side of an element to 2.5rem using the
mb-10
utilities.Use
w-full
to set an element to a 100% based width.Control the text color of an element to center using the
text-center
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the text color of an element to white using the
text-white
utilities.Control the text color of an element to 5xl using the
text-5xl
utilities.Control the background color of an element to gray-100 using the
bg-gray-100
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to build a header components, learn and follow along to implement your own components.