Build a landing page with Tailwind CSS in 5 minutes using Flowbite

by:

Softwares


Greetings to all developers!

I’m one of the founders and project maintainers of the Flowbite Library, one of the most popular collection of UI components built on top of the Tailwind CSS framework.

Today I am happy to show you what we’ve been working on the past few months and I will also show you how you can create a simple landing page with the Flowbite Blocks system and Tailwind CSS.

Here’s a screenshot of the landing page that we’ll build:

You can also check out these helpful links for reference:

Let’s get started then!

Flowbite Blocks – Tailwind UI components

First of all, let me introduce you the system that you will work with in this tutorial.

Using the utility classes from Tailwind CSS and the interactive components from the core Flowbite Library we have built over 120+ website sections featuring hero sections, advanced headers (navigation), CTA sections, cookie consent modal, and many more!

Tailwind UI components - Flowbite Blocks

Some of them are actually free to use under the MIT license while some other can be accessed via the Flowbite Pro license.

Here’s an overview of the block categories that are readily available:

These website sections can be easily used to build landing pages and marketing oriented websites by copy-pasting the code using the Flowbite Blocks interface.

Let me show you show you can work build a landing page in just a few minutes!

Building a landing page in Tailwind CSS

The first section that we need to use is a header component, so let’s check out the Tailwind CSS Header component from Flowbite Blocks.

Tailwind CSS Header - Flowbite

As you can see, there’s a “Requires Flowbite” label just above this block which means that we need to install Flowbite via NPM to make sure that the hamburger toggle works on responsive view.

Follow this quickstart guide from the Flowbite Library to install it on your project.

Install Flowbite as a dependency using NPM by running the following command:

npm i flowbite
Enter fullscreen mode

Exit fullscreen mode

Require Flowbite as a plugin inside the tailwind.config.js file:

module.exports = 

    plugins: [
        require('flowbite/plugin')
    ]


Enter fullscreen mode

Exit fullscreen mode

Include the main JavaScript file to make interactive elements work:

<script src="../path/to/flowbite/dist/flowbite.js"></script>
Enter fullscreen mode

Exit fullscreen mode

Make sure that you copy over the tailwind.config.js file generated by the block system so that the primary class will be available:

/** @type import('tailwindcss').Config */
module.exports = {
  content: ["index.html", "./node_modules/flowbite/**/*.js"],
  darkMode: 'class',
  theme: 
    extend: 
      colors: 
        primary:  "50": "#eff6ff", "100": "#dbeafe", "200": "#bfdbfe", "300": "#93c5fd", "400": "#60a5fa", "500": "#3b82f6", "600": "#2563eb", "700": "#1d4ed8", "800": "#1e40af", "900": "#1e3a8a" 
      
    ,
  ,
  plugins: [
    require('flowbite/plugin')
  ],
}
Enter fullscreen mode

Exit fullscreen mode

Here’s where you can get it:

Tailwind CSS config file

After you’ve pulled in the project, head back to the header block on Flowbite Blocks and click on the “Show code” button and then on the “Copy code” button on the right side to save it in your clipboard.

Now head over to your own project and copy-paste it just after the beginning of your <body> tag.

Choosing a hero section

The next step we need to take is choose from one of the Tailwind CSS Hero Sections from Flowbite.

I will choose the second one with the mobile mockup:

Tailwind CSS Hero - Flowbite

Let’s add this right after the navigation bar inside your project.

Customer logos

It’s a good idea to also showcase the companies using your project so we’re going to take at the customer logos blocks and choose the first one:

Tailwind CSS Logos - Flowbite

We can add this section right after the hero section.

Choosing a feature section

A nice way to explain what your website is about can be done by choosing one of the Tailwind CSS Feature Sections sections from Flowbite Blocks.

I like the first one because I can also use the icons as a visual description:

Tailwind CSS Feature - Flowbite

Let’s add this after the customer logo section.

Additional content

You should usually show at least 2-3 sections which explains what your website is about so choosing from the feature or content sections is advisable.

Let’s take two content sections from Flowbite Blocks and add them right after the feature section:

Tailwind CSS Content - Flowbite

Let’s take this one too where we can also add a link:

Tailwind CSS Content - Flowbite

We’re almost ready! Next up we need to finish the page using a CTA (call to action) section to encourage the user to do something!

CTA section

Luckily, there is a huge collection of CTA sections coded with Tailwind CSS inside the Flowbite Blocks system.

Let’s use this one which looks pretty good just before the footer:

Tailwind CSS CTA - Flowbite

Choosing a footer

Of course we also need to choose a footer that will be used to round up the landing page. The good news is that there are a lot of Tailwind CSS Footer to choose from.

I really like the first one so let’s choose this one:

Tailwind CSS Footer - Flowbite

Awesome! Let’s take a look how this landing page looks:

Tailwind CSS Landing Page

You can also check out these helpful links for reference:

If you liked this tutorial make sure to give it a tweet or let me know the comments section what you think!



Source link

Leave a Reply

Your email address will not be published.