CSS  

Design a Landing Pages in Tailwind CSS

Introduction

Tailwind CSS has gained popularity for its utility-first approach and flexibility in building modern web interfaces. The Landing pages are often the first point of interaction between the users and a product or service, making them crucial for conveying information effectively and driving conversions.

Preview

aq3-(1)

Prerequisites

To create landing pages using Tailwind CSS, basic knowledge of HTML and CSS is required. Familiarity with Tailwind CSS utility classes is recommended for efficient development.

Steps

  • Set Up Tailwind CSS: Install Tailwind CSS in your project using npm or yarn. Follow the official documentation for the installation instructions.

  • Create HTML Structure: Design the layout of your landing page using HTML.

  • Add Tailwind CSS Classes: Utilize Tailwind CSS utility classes to style your HTML elements.

  • Customize Styles: Tailwind CSS provides customization options through configuration files. Adjust colors, fonts, spacing, breakpoints, and other design tokens according to your project's branding and requirements.

  • Responsive Design: Ensure that your landing page is responsive across different screen sizes by leveraging Tailwind CSS's responsive utility classes.

  • Add Interactivity: Enhance user experience by adding interactive elements such as buttons, navigation menus, sliders, modals, and animations. Tailwind CSS offers utility classes for common interactive components.

  • Optimize for Performance: Optimize your landing page for performance by removing unused CSS classes and minimizing file size. Tailwind CSS provides built-in tools for purging unused styles.

Example

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>The Tailwind Landing Page</title>
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
    <style>
        .bg-custom-purple {
            background-color: #7C3AED;
        }

        .bg-custom-pink {
            background-color: #F472B6;
        }

        .bg-custom-blue {
            background-color: #60A5FA;
        }

        .bg-custom-green {
            background-color: #34D399;
        }
        .btn {
            transition: all 0.3s ease;
        }

        .btn:hover {
            transform: translateY(-2px);
        }
        .hamburger-menu {
            display: none;
        }

        @media (max-width: 768px) {
            .hamburger-menu {
                display: block;
            }

            .navbar-items {
                display: none;
            }

            .navbar-items.active {
                display: block;
            }
        }
    </style>
</head>
<body class="bg-gray-100 font-sans leading-normal tracking-normal">
    <header class="bg-white shadow">
        <div class="container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center">
            <a href="#" class="flex title-font font-medium items-center text-gray-900 mb-4 md:mb-0">
                <span class="ml-3 text-xl">Tailwind Landing</span>
            </a>
            <nav class="md:ml-auto md:mr-auto flex flex-wrap items-center text-base justify-center navbar-items">
                <a href="#" class="mr-5 hover:text-gray-900">Home</a>
                <a href="#" class="mr-5 hover:text-gray-900">Features</a>
                <a href="#" class="mr-5 hover:text-gray-900">Pricing</a>
                <a href="#" class="mr-5 hover:text-gray-900">About</a>
                <a href="#" class="mr-5 hover:text-gray-900">Contact</a>
            </nav>
            <button
                class="inline-flex items-center bg-gray-200 border-0 py-1 px-3 focus:outline-none hover:bg-gray-300 rounded text-base mt-4 md:mt-0 btn">Get
                Started</button>
            <div class="hamburger-menu md:hidden ml-auto">
                <svg class="h-6 w-6 cursor-pointer" fill="none" stroke="currentColor" viewBox="0 0 24 24"
                    xmlns="http://www.w3.org/2000/svg">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        d="M4 6h16M4 12h16m-7 6h7"></path>
                </svg>
            </div>
        </div>
    </header>
    <section class="text-gray-700 body-font bg-custom-purple">
        <div class="container mx-auto flex px-5 py-24 items-center justify-center flex-col">
            <div class="text-center lg:w-2/3 w-full">
                <h1 class="title-font sm:text-4xl text-3xl mb-4 font-medium text-white">Tailwind Landing Page</h1>
                <p class="mb-8 leading-relaxed text-white">A landing page is known as the lead capture page, static page or destination page which is designed for a specific task and appears because of an online advertisement or a search engine optimization result. When the user arrives on a landing page it is free from all distractions like the home page and mainly aims to capture a visitor’s information through that form and make them feel comfortable that the website has the solution to their problems.</p>
                <div class="flex justify-center">
                    <button
                        class="inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg btn">Get
                        Started</button>
                    <button
                        class="ml-4 inline-flex text-gray-700 bg-gray-200 border-0 py-2 px-6 focus:outline-none hover:bg-gray-300 hover:text-gray-800 rounded text-lg btn">Learn
                        More</button>
                </div>
            </div>
        </div>
    </section>
    <footer class="bg-gray-200">
        <div class="container mx-auto py-4 px-5 flex flex-wrap flex-col sm:flex-row">
            <p class="text-gray-500 text-sm text-center sm:text-left">© 2024 Tailwind Landing —
                <a href="https://twitter.com/knyttneve" class="text-gray-600 ml-1" rel="noopener noreferrer"
                    target="_blank">@knyttneve</a>
            </p>
            <span class="inline-flex sm:ml-auto sm:mt-0 mt-2 justify-center sm:justify-start">
                <a href="#" class="text-gray-500">
                    <svg fill="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        class="w-5 h-5" viewBox="0 0 24 24">
                        <path
                            d="M5 12h14M12 5l7 7-7 7"></path>
                    </svg>
                </a>
                <a href="#" class="ml-3 text-gray-500">
                    <svg fill="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                        class="w-5 h-5" viewBox="0 0 24 24">
                        <rect width="20" height="20" x="2" y="2" rx="5" ry="5"></rect>
                        <path
                            d="M8 2L20 2 20 20 8 20z"></path>
                        <line x1="12" y1="18" x2="12" y2="12"></line>
                        <line x1="12" y1="8" x2="12.01" y2="8"></line>
                    </svg>
                </a>
                <a href="#" class="ml-3 text-gray-500">
                    <svg fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
                        stroke-width="2" class="w-5 h-5" viewBox="0 0 24 24">
                        <rect width="20" height="20" x="2" y="2" rx="5" ry="5"></rect>
                        <path
                            d="M17.5 13l-5 5L7 14"></path>
                        <path
                            d="M7 10v4l3-2"></path>
                    </svg>
                </a>
                <a href="#" class="ml-3 text-gray-500">
                    <svg fill="currentColor" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
                        stroke-width="0" class="w-5 h-5" viewBox="0 0 24 24">
                        <path stroke="none"
                            d="M0 0h24v24H0z"></path>
                        <circle cx="12" cy="12" r="9"></circle>
                        <path
                            d="M9 12l2 2l4 -4"></path>
                    </svg>
                </a>
            </span>
        </div>
    </footer>
    <script>
        document.querySelector('.hamburger-menu').addEventListener('click', function () {
            document.querySelector('.navbar-items').classList.toggle('active');
        });
    </script>
</body>
</html>

Output

aq3-(1)