- Published on
The 5 Really Obvious Ways To Create A Header / Sidebar / Dashboard With Tailwind CSS Better That You Ever Did

- What is Tailwind CSS?
- The description of Header / Sidebar / Dashboard ui component
- Why use Tailwind CSS to create a Header / Sidebar / Dashboard ui component?
- The preview of Header / Sidebar / Dashboard ui component
- The source code of Header / Sidebar / Dashboard ui component
- How to create a Header / Sidebar / Dashboard with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to create a Header / Sidebar / Dashboard component
- 37 steps to create a Header / Sidebar / Dashboard 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 / Sidebar / Dashboard ui component
Basic structure for dashboard with header and sidebar
Why use Tailwind CSS to create a Header / Sidebar / Dashboard ui component?
- It can make the building process of Header / Sidebar / Dashboard ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Header / Sidebar / Dashboard component file.
The preview of Header / Sidebar / Dashboard ui component
Free download of the Header / Sidebar / Dashboard's source code
The source code of Header / Sidebar / Dashboard ui component
<div class="h-screen w-full bg-white relative flex overflow-hidden">
<!-- Sidebar -->
<aside class="h-full w-16 flex flex-col space-y-10 items-center justify-center relative bg-gray-800 text-white">
<!-- Profile -->
<div class="h-10 w-10 flex items-center justify-center rounded-lg cursor-pointer hover:text-gray-800 hover:bg-white hover:duration-300 hover:ease-linear focus:bg-white">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd" /></svg>
</div>
<!-- Courses -->
<div class="h-10 w-10 flex items-center justify-center rounded-lg cursor-pointer hover:text-gray-800 hover:bg-white hover:duration-300 hover:ease-linear focus:bg-white">
<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="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" /></svg>
</div>
<!-- Theme -->
<div class="h-10 w-10 flex items-center justify-center rounded-lg cursor-pointer hover:text-gray-800 hover:bg-white hover:duration-300 hover:ease-linear focus:bg-white">
<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="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" />
</svg>
</div>
<!-- Configuration -->
<div class="h-10 w-10 flex items-center justify-center rounded-lg cursor-pointer hover:text-gray-800 hover:bg-white hover:duration-300 hover:ease-linear focus:bg-white">
<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="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</div>
</aside>
<div class="w-full h-full flex flex-col justify-between">
<!-- Header -->
<header class="h-16 w-full flex items-center relative justify-end px-5 space-x-10 bg-gray-800">
<!-- Informação -->
<div class="flex flex-shrink-0 items-center space-x-4 text-white">
<!-- Texto -->
<div class="flex flex-col items-end ">
<!-- Nome -->
<div class="text-md font-medium ">Unknow Unknow</div>
<!-- Título -->
<div class="text-sm font-regular">Student</div>
</div>
<!-- Foto -->
<div class="h-10 w-10 rounded-full cursor-pointer bg-gray-200 border-2 border-blue-400"></div>
</div>
</header>
<!-- Main -->
<main class="max-w-full h-full flex relative overflow-y-hidden">
<!-- Container -->
<div class="h-full w-full m-4 flex flex-wrap items-start justify-start rounded-tl grid-flow-col auto-cols-max gap-4 overflow-y-scroll">
<!-- Container -->
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
<div class="w-96 h-60 rounded-lg flex-shrink-0 flex-grow bg-gray-400"></div>
</div>
</main>
</div>
</div>
How to create a Header / Sidebar / Dashboard 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 create a Header / Sidebar / Dashboard component
h-screen
w-full
bg-white
relative
flex
overflow-hidden
h-full
w-16
flex-col
bg-gray-800
text-white
h-10
w-10
hover:text-gray-800
hover:bg-white
focus:bg-white
h-6
w-6
h-16
px-5
flex-shrink-0
text-md
text-sm
bg-gray-200
border-2
border-blue-400
max-w-full
m-4
flex-wrap
justify-start
grid-flow-col
gap-4
overflow-y-scroll
w-96
h-60
flex-grow
bg-gray-400
37 steps to create a Header / Sidebar / Dashboard component with Tailwind CSS
Use
h-screen
to make an element span the entire height of the viewport.Use
w-full
to set an element to a 100% based width.Control the background color of an element to white using the
bg-white
utilities.Use
relative
to position an element according to the normal flow of the document.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.Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Use
w-16
to set an element to a fixed width(4rem).Use
flex
to create a block-level flex container.Control the background color of an element to gray-800 using the
bg-gray-800
utilities.Control the text color of an element to white using the
text-white
utilities.Use
h-10
to set an element to a fixed height(2.5rem).Use
w-10
to set an element to a fixed width(2.5rem).Control the text color of an element to gray-800 on hover using the
hover:text-gray-800
utilities.Control the background color of an element to white using the
hover:bg-white
utilities on hover.Control the background color of an element to white using the
focus:bg-white
utilities on focus.Use
h-6
to set an element to a fixed height(1.5rem).Use
w-6
to set an element to a fixed width(1.5rem).Use
h-16
to set an element to a fixed height(4rem).Control the horizontal padding of an element to 1.25rem using the
px-5
utilities.Use
flex
to create a block-level flex container.Control the text color of an element to md using the
text-md
utilities.Control the text color of an element to sm using the
text-sm
utilities.Control the background color of an element to gray-200 using the
bg-gray-200
utilities.Control the border color of an element to 0.5rem using the
border-2
utilities.Control the border color of an element to blue-400 using the
border-blue-400
utilities.Set the maximum width/height of an element using the
max-w-full
utilities.Control the margin on all sides of an element to 1rem using the
m-4
utilities.Use
flex
to create a block-level flex container.Use
justify-start
to justify items against the start of the container’s main axis.Use
grid
to create a grid container.To specify the width between columns, you can use the
gap-4
utilities.Use
overflow-y-scroll
to allow vertical scrolling and always show scrollbars unless always-visible scrollbars are disabled by the operating system.Use
w-96
to set an element to a fixed width(24rem).Use
h-60
to set an element to a fixed height(15rem).Use
flex
to create a block-level flex container.Control the background color of an element to gray-400 using the
bg-gray-400
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to create a Header / Sidebar / Dashboard components, learn and follow along to implement your own components.