Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 76

Vue & Tailwind Product Page Mini-Project

Recommended resources

Hello! Welcome to your next lesson.

In our previous lessons, you've built a solid foundation in styling Vue applications with Tailwind CSS. You've integrated Tailwind into a Vite project, organized your styles using layers (@layer), and even extended Tailwind's power by using the @tailwindcss/forms plugin.

Today, we put all those skills together. This lesson is a mini-project where you will build a responsive product landing page using Vue and Tailwind CSS. This project will directly address the learning outcome by guiding you to create the essential sections of a landing page: a hero section, feature cards, and a footer.

This is a hands-on project that mirrors a common real-world task for a front-end developer. It's a fantastic opportunity to apply what you've learned and see how quickly you can build a professional-looking UI with the utility-first workflow you've been practicing.


Part 1: Project Setup and Planning

Every new project starts with a clean setup. We'll create a new Vue project and install Tailwind CSS. This will be a good refresher of the steps we took in earlier lessons.

Step 1: Create a New Vue + Vite Project

Open your Fedora terminal and run the official create-vue command. When prompted, you can name your project vue-landing-page and select "No" for all the optional features like Router and Pinia, as we won't need them for this specific project.

npm create vue@latest

Follow the prompts, then navigate into your new project directory and install the dependencies:

cd vue-landing-page
npm install

Step 2: Install and Configure Tailwind CSS

Next, we'll install Tailwind and its dependencies and create the necessary configuration files.

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

Now, configure your tailwind.config.js to tell Tailwind which files to scan for utility classes. This is a crucial step for the production build process.

// tailwind.config.js
/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}", // This ensures it scans all your Vue components
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

Finally, create a main CSS file, add the Tailwind directives, and import it into your main.js.

  1. Create src/assets/main.css.
  2. Add the directives to src/assets/main.css:
    @tailwind base;
    @tailwind components;
    @tailwind utilities;
    
  3. In src/main.js, replace the existing CSS import with your new one:
    // src/main.js
    import { createApp } from 'vue'
    import App from './App.vue'
    import './assets/main.css' // Import Tailwind's styles
    
    createApp(App).mount('#app')
    

For a quick reminder on these steps, the "Vue 3 + Vite + Tailwind (Recommended)" section in the Windframe article is an excellent reference.

How to Install Tailwind CSS in Vue.js

This article from Windframe provides a clear, step-by-step guide for this setup process. It also has a great section explaining why Tailwind and Vue are such a powerful combination, which aligns with your goal of understanding best practices.

Briefly review 'Method 1: Vue 3 + Vite + Tailwind (Recommended)' to refresh your memory of the setup process. The 'Why Tailwind Works So Well with Vue' section is also a great read.

Step 3: Clean Up and Plan

Before we build, let's look at our goal. A typical landing page has a clear structure.

Flowbite Product Landing Page Example
A professional landing page example. Notice the distinct Hero, Features, and Footer sections.

For this project, we'll build everything inside the main App.vue component to keep things focused. In a larger application, you would break each of these sections into its own dedicated Vue component (TheHeader.vue, HeroSection.vue, etc.), but for this 60-minute project, a single file is perfect.

Start by cleaning up src/App.vue. Remove all the boilerplate content inside the <template> and <style> blocks, leaving you with a blank canvas.



Part 2: The Project Walkthrough

To guide our build, we'll follow a fantastic video tutorial that creates a modern landing page using HTML and Tailwind CSS. Your task will be to watch each segment and implement the structure and styles within your App.vue component.

Build a Modern Landing Page With Tailwind CSS

This video by John Komarnicki is the blueprint for our project. It covers the exact sections we need to build. We will use it as a guide for the HTML structure and Tailwind classes.

Watch the first 5 minutes (00:00 - 04:54) to get an overview of the landing page we're about to build.

Customizing Your Tailwind Theme

A key part of any project is setting up a custom theme. The video demonstrates how to add custom colors, fonts, and screen sizes to tailwind.config.js. Let's do that now.

Build a Modern Landing Page With Tailwind CSS

Watch this segment to see how to customize the tailwind.config.js file. This is a critical step for creating a unique design and not just using Tailwind's defaults.

Watch from 04:54 to 23:22. Pay close attention to how he: Adds a custom font (Poppins) from Google Fonts. Adds custom brand colors under theme.extend.colors. Configures the container class to be centered by default. \nFollow along and add similar customizations to your own tailwind.config.js file.

After making changes to tailwind.config.js, you may need to restart your Vite development server (npm run dev) for the changes to take effect.



Part 3: Building the Page Sections

Now, let's build the page, section by section. For each part, you'll watch the corresponding video segment to understand the structure and classes, then implement it in your App.vue file.

Task 1: Build the Hero Section

The hero section is the first thing a user sees. It needs to be engaging and clearly communicate the product's value.

Build a Modern Landing Page With Tailwind CSS

This part of the video walks through creating the entire hero section, including the title, paragraph, call-to-action buttons, and the responsive image layout.

Watch from 00:38:50 to 01:01:24. Focus on how flexbox (flex, flex-col-reverse, lg:flex-row) is used to create a responsive layout that stacks on mobile and sits side-by-side on larger screens.

Your Turn:

  1. Inside the <template> of App.vue, create a <section> element.
  2. Following the video's guidance, build out the hero section's HTML structure and apply the Tailwind utility classes.
  3. Remember to place your images in the public/ directory (e.g., public/images/) and reference them with a leading slash in your <img> tags (e.g., src="/images/hero-bg.png"). You can find placeholder images online or use ones from your own projects.

Task 2: Build the Feature Cards

Feature sections are used to highlight key benefits. Here, we'll build a section with cards that have an alternating layout on desktop.

Build a Modern Landing Page With Tailwind CSS

Next, let's build the feature cards. This segment is excellent for learning how to create complex, responsive layouts that change order.

Watch from 01:01:24 to 01:31:47. Pay attention to the use of flex-row-reverse to alternate the layout of the feature cards. Also, notice the use of grid for the 'download' cards, which is another powerful layout technique.

Your Turn:

  1. Below your hero section, add another <section> for the features.
  2. Build out one feature card first, making sure it's fully responsive.
  3. Duplicate the card and use lg:flex-row-reverse to create the alternating layout effect shown in the video.

Task 3: Build the Footer

Finally, every page needs a footer for navigation links and social media icons.

Build a Modern Landing Page With Tailwind CSS

The final piece is the footer. This segment shows how to create a responsive footer with flexbox.

Watch from 01:43:23 to 01:49:27. Observe how flex-col is used for the mobile layout and md:flex-row is used to transition to a horizontal layout on medium screens.

Your Turn:

  1. Add a <footer> element at the end of your App.vue template.
  2. Implement the branding, navigation, and social media links as shown. You can get icons from a library like Font Awesome by including its CDN link in your index.html.


Part 4: A Note on Reusable Styles

In the video, the instructor creates reusable button classes using the @apply directive.

Build a Modern Landing Page With Tailwind CSS

This is a great technique for styles you use repeatedly, like buttons. It helps keep your HTML clean.

Briefly re-watch from 00:45:07 to 00:52:05. The instructor defines .btn and .btn-purple classes in his CSS file using @apply.

This connects directly to our last lesson on CSS layers. You can add these button styles to your src/assets/main.css file within the components layer, just as we discussed.

/* src/assets/main.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer components {
  .btn {
    @apply shadow-md py-3 px-6 rounded-md transition duration-300;
  }
  .btn-purple {
    @apply bg-bookmark-purple text-white;
  }
  .btn-white {
    @apply bg-bookmark-white text-black;
  }
}

This is a powerful best practice that keeps your markup clean (<button class="btn btn-purple">) and centralizes your component styles.



Conclusion

Excellent work! You have successfully built a complete, responsive landing page by applying your Vue and Tailwind skills to a practical project. You've gone from a blank slate to a finished product, translating a design into functional, styled components.

Key Takeaways:

  • You can rapidly build UIs by translating an HTML/CSS guide into a Vue component structure.
  • The combination of responsive prefixes (like lg:) and layout utilities (Flexbox, Grid) is the key to creating adaptive designs in Tailwind.
  • Customizing your tailwind.config.js is essential for establishing a unique brand identity.
  • Extracting reusable styles into component classes (using @apply within @layer) is a best practice that leads to cleaner and more maintainable code.

Next Lesson: We are now ready to tackle the Final Challenge Project. This will be a larger, full-stack front-end application where you will be responsible for defining the scope, designing the component architecture, managing state, handling routing, and more. This landing page project was the perfect warm-up for the exciting challenge ahead