Published on

A Complete Guide To Build A Responsive vertical timeline With Tailwind CSS

Responsive vertical timeline

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 Responsive vertical timeline ui component

A responsive timeline created using css grid and flexbox.

Why use Tailwind CSS to make a Responsive vertical timeline ui component?

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

The preview of Responsive vertical timeline ui component

Free download of the Responsive vertical timeline's source code

The source code of Responsive vertical timeline ui component

<div class="container">
          <div
            class="flex flex-col md:grid grid-cols-9 mx-auto p-2 text-blue-50"
          >
            <!-- left -->
            <div class="flex flex-row-reverse md:contents">
              <div
                class="bg-blue-500 col-start-1 col-end-5 p-4 rounded-xl my-4 ml-auto shadow-md"
              >
                <h3 class="font-semibold text-lg mb-1">Lorem ipsum</h3>
                <p class="leading-tight text-justify">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi,
                  quaerat?
                </p>
              </div>
              <div class="col-start-5 col-end-6 md:mx-auto relative mr-10">
                <div class="h-full w-6 flex items-center justify-center">
                  <div class="h-full w-1 bg-blue-800 pointer-events-none"></div>
                </div>
                <div
                  class="w-6 h-6 absolute top-1/2 -mt-3 rounded-full bg-blue-500 shadow"
                ></div>
              </div>
            </div>
            <!-- right -->
            <div class="flex md:contents">
              <div class="col-start-5 col-end-6 mr-10 md:mx-auto relative">
                <div class="h-full w-6 flex items-center justify-center">
                  <div class="h-full w-1 bg-blue-800 pointer-events-none"></div>
                </div>
                <div
                  class="w-6 h-6 absolute top-1/2 -mt-3 rounded-full bg-blue-500 shadow"
                ></div>
              </div>
              <div
                class="bg-blue-500 col-start-6 col-end-10 p-4 rounded-xl my-4 mr-auto shadow-md"
              >
                <h3 class="font-semibold text-lg mb-1">Lorem ipsum</h3>
                <p class="leading-tight text-justify">
                  Lorem ipsum, dolor sit amet consectetur adipisicing elit.
                  Vitae, facilis.
                </p>
              </div>
            </div>
            <!-- left -->
            <div class="flex flex-row-reverse md:contents">
              <div
                class="bg-blue-500 col-start-1 col-end-5 p-4 rounded-xl my-4 ml-auto shadow-md"
              >
                <h3 class="font-semibold text-lg mb-1">Lorem ipsum</h3>
                <p class="leading-tight text-justify">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi,
                  quaerat?
                </p>
              </div>
              <div class="col-start-5 col-end-6 md:mx-auto relative mr-10">
                <div class="h-full w-6 flex items-center justify-center">
                  <div class="h-full w-1 bg-blue-800 pointer-events-none"></div>
                </div>
                <div
                  class="w-6 h-6 absolute top-1/2 -mt-3 rounded-full bg-blue-500 shadow"
                ></div>
              </div>
            </div>
            <!-- left -->
            <div class="flex flex-row-reverse md:contents">
              <div
                class="bg-blue-500 col-start-1 col-end-5 p-4 rounded-xl my-4 ml-auto shadow-md"
              >
                <h3 class="font-semibold text-lg mb-1">Lorem ipsum</h3>
                <p class="leading-tight text-justify">
                  Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi,
                  quaerat?
                </p>
              </div>
              <div class="col-start-5 col-end-6 md:mx-auto relative mr-10">
                <div class="h-full w-6 flex items-center justify-center">
                  <div class="h-full w-1 bg-blue-800 pointer-events-none"></div>
                </div>
                <div
                  class="w-6 h-6 absolute top-1/2 -mt-3 rounded-full bg-blue-500 shadow"
                ></div>
              </div>
            </div>
            <!-- right -->
            <div class="flex md:contents">
              <div class="col-start-5 col-end-6 mr-10 md:mx-auto relative">
                <div class="h-full w-6 flex items-center justify-center">
                  <div class="h-full w-1 bg-blue-800 pointer-events-none"></div>
                </div>
                <div
                  class="w-6 h-6 absolute top-1/2 -mt-3 rounded-full bg-blue-500 shadow"
                ></div>
              </div>
              <div
                class="bg-blue-500 col-start-6 col-end-10 p-4 rounded-xl my-4 mr-auto shadow-md"
              >
                <h3 class="font-semibold text-lg mb-1">Lorem ipsum</h3>
                <p class="leading-tight text-justify">
                  Lorem ipsum, dolor sit amet consectetur adipisicing elit.
                  Vitae, facilis.
                </p>
              </div>
            </div>
          </div>
        </div>

How to make a Responsive vertical timeline with Tailwind CSS?

Install tailwind css of verion 2.0.2

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

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

All the unility class needed to make a Responsive vertical timeline component

  • flex
  • flex-col
  • md:grid
  • grid-cols-9
  • mx-auto
  • p-2
  • text-blue-50
  • flex-row-reverse
  • md:contents
  • bg-blue-500
  • p-4
  • my-4
  • ml-auto
  • text-lg
  • mb-1
  • text-justify
  • md:mx-auto
  • relative
  • mr-10
  • h-full
  • w-6
  • w-1
  • bg-blue-800
  • h-6
  • absolute
  • top-1/2
  • -mt-3
  • mr-auto

28 steps to make a Responsive vertical timeline component with Tailwind CSS

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

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

  3. Use grid to create a grid container at only medium screen sizes.

  4. Use grid to create a grid container.

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

  6. Control the padding on all sides of an element to 0.5rem using the p-2 utilities.

  7. Control the text color of an element to blue-50 using the text-blue-50 utilities.

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

  9. Use contents to create a “phantom” container whose children act like direct children of the parert at only medium screen sizes.

  10. Control the background color of an element to blue-500 using the bg-blue-500 utilities.

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

  12. Control the vertical margin of an element to 1rem using the my-4 utilities.

  13. Control the margin on left side of an element to auto using the ml-auto utilities.

  14. Control the text color of an element to lg using the text-lg utilities.

  15. Control the margin on bottom side of an element to 0.25rem using the mb-1 utilities.

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

  17. Control the horizontal margin of an element to auto at only medium screen sizes using the md:mx-auto utilities.

  18. Use relative to position an element according to the normal flow of the document.

  19. Control the margin on right side of an element to 2.5rem using the mr-10 utilities.

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

  21. Use w-6 to set an element to a fixed width(1.5rem).

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

  23. Control the background color of an element to blue-800 using the bg-blue-800 utilities.

  24. Use h-6 to set an element to a fixed height(1.5rem).

  25. Use absolute to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.

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

  27. Control the margin on top side of an element to -0.75rem using the -mt-3 utilities.

  28. Control the margin on right side of an element to auto using the mr-auto utilities.

Conclusion

The above is a step-by-step tutorial on how to use Tailwind CSS to make a Responsive vertical timeline components, learn and follow along to implement your own components.