Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 16, 2022 09:49 am GMT

How to build a Tailwind CSS timeline component with Flowbite

I've been using Tailwind CSS to build websites and the power of the utility classes coupled with the components from Flowbite makes it so much more easier and fun!

I've started a tutorial series on how to create some of the most commonly used UI components using the classes from Tailwind CSS, and today I want to show you how to build a timeline component.

Here's a preview of how it will look:

Tailwind CSS timeline

Let's get started!

Tailwind CSS timeline

First of all we need to set up the basic HTML markup. We'll use a <ol> element.

<ol>                      <li>        <time>February 2022</time>        <h3>Application UI code in Tailwind CSS</h3>        <p>Get access to over 20+ pages including a dashboard layout, charts, kanban board, calendar, and pre-order E-commerce & Marketing pages.</p>    </li>    <li>        <time>March 2022</time>        <h3>Marketing UI design in Figma</h3>        <p>All of the pages and components are first designed in Figma and we keep a parity between the two versions even as we update the project.</p>    </li>    <li>        <time>April 2022</time>        <h3>E-Commerce UI code in Tailwind CSS</h3>        <p>Get started with dozens of web components and interactive elements built on top of Tailwind CSS.</p>    </li></ol>

Awesome! Let's now style the spacing, typography, and colors of the elements inside the timeline.

<ol class="relative border-l border-gray-200">                      <li class="mb-10 ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white"></div>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Application UI code in Tailwind CSS</h3>        <p class="mb-4 text-base font-normal text-gray-500">Get access to over 20+ pages including a dashboard layout, charts, kanban board, calendar, and pre-order E-commerce & Marketing pages.</p>    </li>    <li class="mb-10 ml-4">        <time class="mb-1 text-sm font-normal leading-none text-gray-400">March 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Marketing UI design in Figma</h3>        <p class="text-base font-normal text-gray-500">All of the pages and components are first designed in Figma and we keep a parity between the two versions even as we update the project.</p>    </li>    <li class="ml-4">        <time class="mb-1 text-sm font-normal leading-none text-gray-400">April 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">E-Commerce UI code in Tailwind CSS</h3>        <p class="text-base font-normal text-gray-500">Get started with dozens of web components and interactive elements built on top of Tailwind CSS.</p>    </li></ol>

Already looking much better. Let's now add the dots and a CTA button link.

<ol class="relative border-l border-gray-200">                      <li class="mb-10 ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400">February 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Application UI code in Tailwind CSS</h3>        <p class="mb-4 text-base font-normal text-gray-500">Get access to over 20+ pages including a dashboard layout, charts, kanban board, calendar, and pre-order E-commerce & Marketing pages.</p>        <a href="#" class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">Learn more <svg class="w-3 h-3 ml-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></a>    </li>    <li class="mb-10 ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400">March 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Marketing UI design in Figma</h3>        <p class="text-base font-normal text-gray-500">All of the pages and components are first designed in Figma and we keep a parity between the two versions even as we update the project.</p>    </li>    <li class="ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400">April 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">E-Commerce UI code in Tailwind CSS</h3>        <p class="text-base font-normal text-gray-500">Get started with dozens of web components and interactive elements built on top of Tailwind CSS.</p>    </li></ol>

Great job! The timeline component should now look like in the preview picture.

Lastly, let's also apply some of the dark variant classes for the dark mode.

Note: check out this tutorial on how to set dark mode with Tailwind CSS and Flowbite.

<ol class="relative border-l border-gray-200 dark:border-gray-700">                      <li class="mb-10 ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white dark:border-gray-900 dark:bg-gray-700"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500">February 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Application UI code in Tailwind CSS</h3>        <p class="mb-4 text-base font-normal text-gray-500 dark:text-gray-400">Get access to over 20+ pages including a dashboard layout, charts, kanban board, calendar, and pre-order E-commerce & Marketing pages.</p>        <a href="#" class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-2 focus:ring-blue-700 focus:text-blue-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">Learn more <svg class="w-3 h-3 ml-2" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M12.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-2.293-2.293a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg></a>    </li>    <li class="mb-10 ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white dark:border-gray-900 dark:bg-gray-700"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500">March 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">Marketing UI design in Figma</h3>        <p class="text-base font-normal text-gray-500 dark:text-gray-400">All of the pages and components are first designed in Figma and we keep a parity between the two versions even as we update the project.</p>    </li>    <li class="ml-4">        <div class="absolute w-3 h-3 bg-gray-200 rounded-full -left-1.5 border border-white dark:border-gray-900 dark:bg-gray-700"></div>        <time class="mb-1 text-sm font-normal leading-none text-gray-400 dark:text-gray-500">April 2022</time>        <h3 class="text-lg font-semibold text-gray-900 dark:text-white">E-Commerce UI code in Tailwind CSS</h3>        <p class="text-base font-normal text-gray-500 dark:text-gray-400">Get started with dozens of web components and interactive elements built on top of Tailwind CSS.</p>    </li></ol>

The timeline should look like this in dark mode:

Tailwind CSS dark mode timeline

This Tailwind CSS timeline component is part of an open source library of Tailwind CSS components called Flowbite.

You can find more timeline component styles and variants and also a full set of other elements such as buttons, dropdowns, modals, tooltips, and more.

Flowbite - Tailwind CSS timeline
Flowbite - Tailwind CSS Components


Original Link: https://dev.to/themesberg/how-to-build-a-tailwind-css-timeline-component-with-flowbite-5638

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To