Published on

How To Make A Layout With Header Sidebar And Rightbar With Tailwind CSS From Scratch

Tags
Layout With Header Sidebar And Rightbar

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 Layout With Header Sidebar And Rightbar ui component

Layout with header sidebar and rightbar

Why use Tailwind CSS to create a Layout With Header Sidebar And Rightbar ui component?

  • It can make the building process of Layout With Header Sidebar And Rightbar ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in Layout With Header Sidebar And Rightbar component file.

The preview of Layout With Header Sidebar And Rightbar ui component

Free download of the Layout With Header Sidebar And Rightbar's source code

The source code of Layout With Header Sidebar And Rightbar ui component

<div class="flex h-screen bg-green-300">
  <div class="flex-1 flex flex-col overflow-hidden">
    <header class="flex justify-between items-center bg-blue-300 p-4">
      <div class="flex">Left</div>
      <div class="flex">Right</div>
    </header>
    <div class="flex h-full">
      <nav class="flex w-72 h-full bg-pink-500">
        <div class="w-full flex mx-auto px-6 py-8">
          <div class="w-full h-full flex items-center justify-center text-gray-900 text-xl border-4 border-gray-900 border-dashed">Sidebar</div>
        </div>
      </nav>
      <main class="flex flex-col w-full bg-white overflow-x-hidden overflow-y-auto mb-14">
        <div class="flex w-full mx-auto px-6 py-8">
          <div class="flex flex-col w-full h-full text-gray-900 text-xl border-4 border-gray-900 border-dashed">
            <div class="flex w-full max-w-xl h-60 items-center justify-center mx-auto bg-green-400 border-b border-gray-600">Post</div>
            <div class="flex w-full max-w-xl h-60 items-center justify-center mx-auto bg-green-400 border-b border-gray-600">Post</div>
            <div class="flex w-full max-w-xl h-60 items-center justify-center mx-auto bg-green-400 border-b border-gray-600">Post</div>
            <div class="flex w-full max-w-xl h-60 items-center justify-center mx-auto bg-green-400 border-b border-gray-600">Post</div>
            <div class="flex w-full max-w-xl h-60 items-center justify-center mx-auto bg-green-400 border-b border-gray-600">Post</div>
          </div>
        </div>
      </main>
      <nav class="flex w-72 h-full bg-yellow-400">
        <div class="w-full flex mx-auto px-6 py-8">
          <div class="w-full h-full flex items-center justify-center text-gray-900 text-xl border-4 border-gray-900 border-dashed">Rightbar</div>
        </div>
      </nav>
    </div>
  </div>
</div>

<style>
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(13deg, #7bcfeb 14%, #e685d3 64%);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(13deg, #c7ceff 14%, #f9d4ff 64%);
}
::-webkit-scrollbar-track {
  background: #ffffff;
  border-radius: 10px;
  box-shadow: inset 7px 10px 12px #f0f0f0;
}
</style>

How to create a Layout With Header Sidebar And Rightbar with Tailwind CSS?

Install tailwind css of verion 2.1.0

Use the script html tag to import the script of Tailwind CSS of the version 2.1.0

<script src="https://cdn.tailwindcss.com"></script>

All the unility class needed to create a Layout With Header Sidebar And Rightbar component

  • flex
  • h-screen
  • bg-green-300
  • flex-1
  • flex-col
  • overflow-hidden
  • bg-blue-300
  • p-4
  • h-full
  • w-72
  • bg-pink-500
  • w-full
  • mx-auto
  • px-6
  • py-8
  • text-gray-900
  • text-xl
  • border-4
  • border-gray-900
  • border-dashed
  • bg-white
  • overflow-y-auto
  • mb-14
  • max-w-xl
  • h-60
  • bg-green-400
  • border-b
  • border-gray-600
  • bg-yellow-400

29 steps to create a Layout With Header Sidebar And Rightbar component with Tailwind CSS

  1. Use flex to create a block-level flex container.

  2. Use h-screen to make an element span the entire height of the viewport.

  3. Control the background color of an element to green-300 using the bg-green-300 utilities.

  4. Use flex to create a block-level flex container.

  5. Use flex to create a block-level flex container.

  6. Use overflow-hidden to clip any content within an element that overflows the bounds of that element.

  7. Control the background color of an element to blue-300 using the bg-blue-300 utilities.

  8. Control the padding on all sides of an element to 1rem using the p-4 utilities.

  9. Use h-full to set an element’s height to 100% of its parent, as long as the parent has a defined height.

  10. Use w-72 to set an element to a fixed width(18rem).

  11. Control the background color of an element to pink-500 using the bg-pink-500 utilities.

  12. Use w-full to set an element to a 100% based width.

  13. Control the horizontal margin of an element to auto using the mx-auto utilities.

  14. Control the horizontal padding of an element to 1.5rem using the px-6 utilities.

  15. Control the vertical padding of an element to 2rem using the py-8 utilities.

  16. Control the text color of an element to gray-900 using the text-gray-900 utilities.

  17. Control the text color of an element to xl using the text-xl utilities.

  18. Control the border color of an element to 1rem using the border-4 utilities.

  19. Control the border color of an element to gray-900 using the border-gray-900 utilities.

  20. Control the border color of an element to dashed using the border-dashed utilities.

  21. Control the background color of an element to white using the bg-white utilities.

  22. Use overflow-y-auto to allow vertical scrolling if needed.

  23. Control the margin on bottom side of an element to 3.5rem using the mb-14 utilities.

  24. Set the maximum width/height of an element using the max-w-xl utilities.

  25. Use h-60 to set an element to a fixed height(15rem).

  26. Control the background color of an element to green-400 using the bg-green-400 utilities.

  27. Control the border color of an element to b using the border-b utilities.

  28. Control the border color of an element to gray-600 using the border-gray-600 utilities.

  29. Control the background color of an element to yellow-400 using the bg-yellow-400 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to create a Layout With Header Sidebar And Rightbar components, learn and follow along to implement your own components.