Published on

6 Steps To Build A tabbar-responsive With Tailwind CSS Like A Pro In Under An Hour

tabbar-responsive

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 tabbar-responsive ui component

Responsive tabbar

Why use Tailwind CSS to create a tabbar-responsive ui component?

  • It can make the building process of tabbar-responsive ui component faster and more easily.
  • Enables building complex responsive layouts and components freely.
  • Minimum lines of CSS code in tabbar-responsive component file.

The preview of tabbar-responsive ui component

Free download of the tabbar-responsive's source code

The source code of tabbar-responsive ui component

<!-- full animate https://play.tailwindcss.com/kxQ0ePcRug  -->

<div id="side-bar" class="fixed lg:visible invisible -translate-x-48  lg:-translate-x-0 duration-300 ease-in-out h-5/6 w-48 top-10 rounded-xl bg-white shadow-lg py-3 pl-3">
  <div class="h-full flex flex-col justify-between">
    <img class="px-5 pt-3 mx-auto mb-10" src="https://v1.tailwindcss.com/_next/static/media/tailwindcss-logotype.5d127e1d767d06efa2b03fe4de5f3d84.svg" />

    <div class="hover:overflow-auto overflow-hidden">
      <div class="mb-10">
        <div class="text-sm text-gray-500">Overview</div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Overview</span>
        </div>
      </div>

      <div class="mb-10">
        <div class="text-sm text-gray-500">Header 1</div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 1</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 2</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 3</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 4</span>
        </div>
      </div>

      <div class="mb-10">
        <div class="text-sm text-gray-500">Header 2</div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 1</span>
        </div>
      </div>

      <div class="mb-10">
        <div class="text-sm text-gray-500">Header 3</div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 1</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 2</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 3</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 4</span>
        </div>
      </div>

      <div class="mb-10">
        <div class="text-sm text-gray-500">Header 4</div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 1</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 2</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 3</span>
        </div>
        <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
          <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
          <span class="text-gray-500">Menu 4</span>
        </div>
      </div>
    </div>

    <div class="mt-10">
      <div class="flex items-center hover:border-r-4 border-green-500 h-8 cursor-pointer">
        <i class="animate-pulse h-5 w-5 rounded-sm bg-gray-300 mr-2"></i>
        <span class="text-gray-500">Account Mgnt</span>
      </div>
    </div>

    <div class="mt-6">
      <div class="flex items-center cursor-pointer">
        <i class="animate-pulse h-5 w-5 rounded-full bg-gray-300 mr-2"></i>
        <span class="text-gray-500 truncate">Firstname Lastname</span>
        <i class="animate-pulse h-5 w-1 bg-gray-300 mx-3"></i>
      </div>
    </div>
    <div class="flex justify-end mt-2">
      <i class="text-green-500 font-bold bg-gray-200 px-3 py-1 rounded-full  text-right mr-3 cursor-pointer"><</i>
    </div>
  </div>
</div>

<div class="fixed top-1/2 bg-white left-4 visible lg:invisible lg:-translate-x-20 -translate-x-0 duration-300 ease-in-out rounded-lg shadow-lg">
  <div class="mx-1 my-10">
    <i class="text-green-500 font-bold text-center cursor-pointer bg-gray-200 px-3 py-2 rounded-full">></i>
  </div>
</div>

How to create a tabbar-responsive 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 tabbar-responsive component

  • fixed
  • lg:visible
  • invisible
  • h-5/6
  • w-48
  • top-10
  • bg-white
  • py-3
  • pl-3
  • h-full
  • flex
  • flex-col
  • px-5
  • pt-3
  • mx-auto
  • mb-10
  • hover:overflow-auto
  • overflow-hidden
  • text-sm
  • text-gray-500
  • hover:border-r-4
  • border-green-500
  • h-8
  • h-5
  • w-5
  • bg-gray-300
  • mr-2
  • mt-10
  • mt-6
  • w-1
  • mx-3
  • mt-2
  • text-green-500
  • bg-gray-200
  • px-3
  • py-1
  • text-right
  • mr-3
  • top-1/2
  • left-4
  • visible
  • lg:invisible
  • mx-1
  • my-10
  • text-center
  • py-2

46 steps to create a tabbar-responsive component with Tailwind CSS

  1. Use fixed to position an element relative to the browser window.

  2. Use visible to make an element visible at only large screen sizes. This is mostly useful for undoing the invisible utility at different screen sizes.

  3. Use invisible to hide an element, but still maintain its place in the DOM, affecting the layout of other elements.

  4. Use h-5/6 to set an element to a fixed height(5/6).

  5. Use w-48 to set an element to a fixed width(12rem).

  6. Use the top-10 utilities to set the top position of a positioned element to 2.5rem.

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

  8. Control the vertical padding of an element to 0.75rem using the py-3 utilities.

  9. Adjust the left padding of an element to 0.75rem using the pl-3 utilities class

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

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

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

  13. Control the horizontal padding of an element to 1.25rem using the px-5 utilities.

  14. Control the padding on top side of an element to 0.75rem using the pt-3 utilities.

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

  16. Control the margin on bottom side of an element to 2.5rem using the mb-10 utilities.

  17. Use overflow-auto to add scrollbars to an element in the event that its content overflows the bounds of that element on hover. Unlike .overflow-scroll, which always shows scrollbars, this utility will only show them if scrolling is necessary.

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

  19. Control the text color of an element to sm using the text-sm utilities.

  20. Control the text color of an element to gray-500 using the text-gray-500 utilities.

  21. Control the border color of an element to r-4 using the hover:border-r-4 utilities on hover.

  22. Control the border color of an element to green-500 using the border-green-500 utilities.

  23. Use h-8 to set an element to a fixed height(2rem).

  24. Use h-5 to set an element to a fixed height(1.25rem).

  25. Use w-5 to set an element to a fixed width(1.25rem).

  26. Control the background color of an element to gray-300 using the bg-gray-300 utilities.

  27. Control the margin on right side of an element to 0.5rem using the mr-2 utilities.

  28. Control the margin on top side of an element to 2.5rem using the mt-10 utilities.

  29. Control the margin on top side of an element to 1.5rem using the mt-6 utilities.

  30. Use w-1 to set an element to a fixed width(0.25rem).

  31. Control the horizontal margin of an element to 0.75rem using the mx-3 utilities.

  32. Control the margin on top side of an element to 0.5rem using the mt-2 utilities.

  33. Control the text color of an element to green-500 using the text-green-500 utilities.

  34. Control the background color of an element to gray-200 using the bg-gray-200 utilities.

  35. Control the horizontal padding of an element to 0.75rem using the px-3 utilities.

  36. Control the vertical padding of an element to 0.25rem using the py-1 utilities.

  37. Control the text color of an element to right using the text-right utilities.

  38. Control the margin on right side of an element to 0.75rem using the mr-3 utilities.

  39. Use the top-1/2 utilities to set the top position of a positioned element to 1/2.

  40. Use the left-4 utilities to set the left position of a positioned element to 1rem.

  41. Use visible to make an element visible. This is mostly useful for undoing the invisible utility at different screen sizes.

  42. Use invisible to hide an element, but still maintain its place in the DOM, affecting the layout of other elements at only large screen sizes.

  43. Control the horizontal margin of an element to 0.25rem using the mx-1 utilities.

  44. Control the vertical margin of an element to 2.5rem using the my-10 utilities.

  45. Control the text color of an element to center using the text-center utilities.

  46. Control the vertical padding of an element to 0.5rem using the py-2 utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to create a tabbar-responsive components, learn and follow along to implement your own components.