Now, create a components directory in the root of your Nuxt project (if it doesn't exist). Inside this directory, create the following files:
1. components/TheHeader.vue
vue
<template>
<header class="bg-white shadow">
<div class="max-w-7xl mx-auto px-4 py-4 flex justify-between items-center">
<!-- Logo/Brand -->
<h1 class="text-xl font-bold text-indigo-600">MyLanding</h1>
<!-- Navigation Links -->
<nav class="hidden md:flex">
<a href="#features" class="mx-2 text-gray-700 hover:text-indigo-600 transition duration-300">Features</a>
<a href="#contact" class="mx-2 text-gray-700 hover:text-indigo-600 transition duration-300">Contact</a>
</nav>
<!-- Mobile Menu Button (Optional, for a more complex header) -->
<!-- For this simple example, we'll keep it basic -->
</div>
</header>
</template>
<script setup>
// No specific script needed for this simple header component
</script>
2. components/HeroSection.vue
vue
<template>
<section class="bg-white">
<div class="max-w-7xl mx-auto px-4 py-16 text-center">
<!-- Main Heading -->
<h2 class="text-4xl font-extrabold text-gray-900 sm:text-5xl md:text-6xl">
Welcome to Our Amazing Product
</h2>
<!-- Subheading -->
<p class="mt-4 text-lg text-gray-600 max-w-xl mx-auto">
A simple, beautiful landing page to showcase your product or service with clarity and style.
</p>
<!-- Call to Action Button -->
<div class="mt-8">
<a
href="#contact"
class="inline-block px-8 py-3 bg-indigo-600 text-white font-semibold rounded-lg shadow-md hover:bg-indigo-700 transition duration-300 ease-in-out transform hover:-translate-y-1"
>
Get Started Today
</a>
</div>
</div>
</section>
</template>
<script setup>
// No specific script needed for this simple hero section component
</script>
3. components/FeaturesSection.vue
vue
<template>
<section id="features" class="bg-gray-100 py-20">
<div class="max-w-7xl mx-auto px-4">
<!-- Section Title -->
<h3 class="text-3xl font-bold text-gray-800 text-center mb-12">Key Features</h3>
<!-- Feature Cards -->
<div class="grid grid-cols-1 md:grid-cols-3 gap-10">
<!-- Feature Card 1 -->
<div class="bg-white p-8 rounded-lg shadow-lg text-center transition duration-300 ease-in-out transform hover:scale-105">
<div class="text-indigo-600 mb-4 text-4xl">🚀</div>
<h4 class="text-xl font-semibold text-gray-800 mb-3">Blazing Fast Performance</h4>
<p class="text-gray-600 leading-relaxed">
Experience lightning-fast load times and a seamless user experience, optimized for all devices.
</p>
</div>
<!-- Feature Card 2 -->
<div class="bg-white p-8 rounded-lg shadow-lg text-center transition duration-300 ease-in-out transform hover:scale-105">
<div class="text-indigo-600 mb-4 text-4xl">🎨</div>
<h4 class="text-xl font-semibold text-gray-800 mb-3">Intuitive Design</h4>
<p class="text-gray-600 leading-relaxed">
A clean, modern, and user-friendly interface that makes navigating your product a breeze.
</p>
</div>
<!-- Feature Card 3 -->
<div class="bg-white p-8 rounded-lg shadow-lg text-center transition duration-300 ease-in-out transform hover:scale-105">
<div class="text-indigo-600 mb-4 text-4xl">💡</div>
<h4 class="text-xl font-semibold text-gray-800 mb-3">Easy Integration</h4>
<p class="text-gray-600 leading-relaxed">
Seamlessly integrate with your existing workflows and tools for maximum efficiency.
</p>
</div>
</div>
</div>
</section>
</template>
<script setup>
// No specific script needed for this simple features section component
</script>
4. components/ContactSection.vue
vue
<template>
<section id="contact" class="bg-white py-20">
<div class="max-w-7xl mx-auto px-4 text-center">
<!-- Section Title -->
<h3 class="text-3xl font-bold text-gray-800 mb-4">Have Questions?</h3>
<!-- Subtitle/Description -->
<p class="text-lg text-gray-600 mb-8 max-w-2xl mx-auto">
We're here to help! Feel free to reach out to us for any inquiries or to learn more about how we can assist you.
</p>
<!-- Contact Button -->
<a
href="mailto:hello@example.com"
class="inline-block px-8 py-3 bg-indigo-600 text-white font-semibold rounded-lg shadow-md hover:bg-indigo-700 transition duration-300 ease-in-out"
>
Contact Us Now
</a>
</div>
</section>
</template>
<script setup>
// No specific script needed for this simple contact section component
</script>
Now, update your main page file (pages/index.vue) to use these components. Nuxt 3 automatically imports components from the components/ directory, so you don't need explicit imports here.
vue
<template>
<div class="min-h-screen bg-gray-50 font-sans antialiased">
<!-- Header Component -->
<TheHeader />
<!-- Hero Section Component -->
<HeroSection />
<!-- Features Section Component -->
<FeaturesSection />
<!-- Contact Section Component -->
<ContactSection />
<!-- Footer Component -->
<TheFooter />
</div>
</template>
<script setup>
// useHead is used to set the page title and meta description for SEO
useHead({
title: 'My Landing Page - Simple & Effective',
meta: [
{ name: 'description', content: 'Discover a simple, elegant landing page built with Nuxt 3 and Tailwind CSS.' }
],
// Add body attributes if needed, e.g. for font-family
bodyAttrs: {
class: 'bg-gray-50'
}
})
</script>
You should now see your landing page, nicely structured with individual components. This approach is much cleaner and makes it easier to manage and update different parts of your page.