- Published on
Ways To Make A Sidebar Component With Tailwind CSS In 60 Minutes

- What is Tailwind CSS?
- The description of Sidebar Component ui component
- Why use Tailwind CSS to make a Sidebar Component ui component?
- The preview of Sidebar Component ui component
- The source code of Sidebar Component ui component
- How to make a Sidebar Component with Tailwind CSS?
- Install tailwind css of verion 2.2.4
- All the unility class needed to make a Sidebar Component component
- 22 steps to make a Sidebar Component 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 Sidebar Component ui component
Sidebar component
Why use Tailwind CSS to make a Sidebar Component ui component?
- It can make the building process of Sidebar Component ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Sidebar Component component file.
The preview of Sidebar Component ui component
Free download of the Sidebar Component's source code
The source code of Sidebar Component ui component
<nav class=" rounded-md w-72 h-screen flex-col justify-between">
<div class=" bg-white h-full">
<div class="flex justify-center py-10 shadow-sm pr-4">
<svg xmlns="http://www.w3.org/2000/svg" class="h-14 w-14 text-indigo-600" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />
</svg>
<div class="pl-2">
<p class="text-2xl font-bold text-indigo-600">VENUS</h1>
<span class="text-xs block text-gray-800">DASHBOARD</span>
</div>
</div>
<div class="pl-10">
<ul class="space-y-8 pt-10">
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2" />
</svg>
<a href="">Dashboard</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
<a href="">Activity</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3" />
</svg>
<a href="">Library</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
</svg>
<a href="">Security</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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="M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4" />
</svg>
<a href="">Schedules</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<a href="">Payouts</a>
</li>
<li class="flex space-x-4 items-center hover:text-indigo-600 cursor-pointer">
<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 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4" />
</svg>
<a href="">Settings</a>
</li>
</ul>
</div>
</div>
<div class="bg-white flex items-center space-x-4 pl-10 pb-10 hover:text-indigo-600 cursor-pointer">
<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="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
</svg>
<a href="/loguot">Logout</a>
</div>
</nav>
How to make a Sidebar Component 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 make a Sidebar Component component
w-72
h-screen
flex-col
bg-white
h-full
flex
py-10
pr-4
h-14
w-14
text-indigo-600
pl-2
text-2xl
text-xs
block
text-gray-800
pl-10
pt-10
hover:text-indigo-600
h-6
w-6
pb-10
22 steps to make a Sidebar Component component with Tailwind CSS
Use
w-72
to set an element to a fixed width(18rem).Use
h-screen
to make an element span the entire height of the viewport.Use
flex
to create a block-level flex container.Control the background color of an element to white using the
bg-white
utilities.Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.Use
flex
to create a block-level flex container.Control the vertical padding of an element to 2.5rem using the
py-10
utilities.Control the padding on right side of an element to 1rem using the
pr-4
utilities.Use
h-14
to set an element to a fixed height(3.5rem).Use
w-14
to set an element to a fixed width(3.5rem).Control the text color of an element to indigo-600 using the
text-indigo-600
utilities.Set the left padding of the element to 0.5rem using the
pl-2
utilities classControl the text color of an element to 2xl using the
text-2xl
utilities.Control the text color of an element to xs using the
text-xs
utilities.Use
inline
utilities to put the element on its own line and fill its parent.Control the text color of an element to gray-800 using the
text-gray-800
utilities.Set the left padding of the element to 2.5rem using the
pl-10
utilities classControl the padding on top side of an element to 2.5rem using the
pt-10
utilities.Control the text color of an element to indigo-600 on hover using the
hover:text-indigo-600
utilities.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).Control the padding on bottom side of an element to 2.5rem using the
pb-10
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to make a Sidebar Component components, learn and follow along to implement your own components.