Build a Business Landing Page with React, Tailwind CSS and Framer Motion

A landing page is often the first thing visitors see when they discover your business.

A good landing page should:

  • Look professional
  • Work perfectly on mobile devices
  • Load quickly
  • Clearly explain your services
  • Build trust
  • Encourage users to take action

In this tutorial, we’ll build a modern landing page using:

  • React
  • Tailwind CSS
  • Framer Motion
  • Responsive Design
  • SEO-friendly HTML

The page will include:

✅ Hero Section

✅ Features / Services Section

✅ About Section

✅ Testimonials Section

✅ Call To Action Section

✅ Smooth Scrolling

✅ Framer Motion Animations

✅ Mobile Responsive Design

Project Structure

src/
├── components/
│ ├── Hero.jsx
│ ├── Features.jsx
│ ├── About.jsx
│ ├── Testimonials.jsx
│ └── CTA.jsx
├── App.jsx
└── index.css

Step 1: Create React Project

npx create-react-app landing-page
cd landing-page

Install dependencies:

npm install framer-motion
npm install -D tailwindcss

package.json
{
"name": "landing-page",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/dom": "^10.4.1",
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.1",
"@testing-library/user-event": "^13.5.0",
"framer-motion": "^12.40.0",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"tailwindcss": "^3.4.19",
"autoprefixer": "^10.5.0"
}
}

Step 2: Configure Tailwind

tailwind.config.js

module.exports = {
content: [
"./src/**/*.{js,jsx}"
],
theme: {
extend: {},
},
plugins: [],
}

postcss.config.js

module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};

src/index.css

@tailwind base;
@tailwind components;
@tailwind utilities;
html {
scroll-behavior: smooth;
}

Step 3: Hero Section

components/Hero.jsx

import { motion } from 'framer-motion';
export default function Hero() {
return (
<section id="hero" className='min-h-screen flex items-center justify-center bg-slate-900 text-white'>
<div className='text-center px-6'>
<motion.h1
initial={{ opacity: 0, y: -40 }}
animate={{ opacity: 1, y: 0}}
transition={{ duration: 0.8 }}
className="text-5xl font-bold">
Grow Your Business Faster
</motion.h1>
<motion.p
initial={{ opacity: 0 }}
animate={{ opacity: 1}}
transition={{ delay: 0.3 }}
className='mt-6 text-xl'>
Modern digital solutions for growing companies.
</motion.p>
<a href='#cta' className='inline-block mt-8 bg-blue-600 px-8 py-3 rounded-lg'>
Get Started
</a>
</div>
</section>
)
}

Step 4: Features Section

components/Features.jsx

import { motion } from 'framer-motion';
const features = [
"Web Development",
"Mobile Apps",
"SEO Optimization",
"Cloud Solutions"
];
export default function Features () {
return (
<section id="features" className='py-20 bg-gray-100'>
<div className='max-w-6xl mx-auto px-6'>
<h2 className='text-4xl font-bold text-center'>
Services
</h2>
<div className='grid md:grid-cols-2 gap-8 mt-12'>
{
features.map((item) => (
<motion.div
whileHover={{ scale: 1.05 }}
key={item}
className='bg-white p-6 rounded-xl shadow'>
<h3 className='text-xl font-semibold'>{item}</h3>
</motion.div>
))
}
</div>
</div>
</section>
)
}

Step 5: About Section

components/About.jsx

export default function About() {
return (
<section id='about' className="py-20">
<div className="max-w-4xl mx-auto px-6 text-center">
<h2 className="text-4xl font-bold">
About Us
</h2>
<p className="mt-6 text-lg">
We help business build modern
digital products that increase
growth and customer engagement.
</p>
</div>
</section>
)
}

Step 6: Testimonials Section

components/Testimonials.jsx

export default function Testimonials() {
const testimonials = [
{
name: "John",
text: "Amazing service and support."
},
{
name: "Sarah",
text: "Helped our company grow rapidly."
}
];
return (
<section id='testimonials' className="bg-gray-100 py-20">
<div className="max-w-6xl mx-auto px-6">
<h2 className="text-4xl font-bold text-center">
Testimonials
</h2>
<div className="grid md:grid-cols-2 gap-8 mt-12">
{testimonials.map((item) => (
<div
key={item.name}
className="bg-white p-6 rounded-xl shadow">
<p>{item.text}</p>
<h4 className="mt-4 font-bold">{item.name}</h4>
</div>
))}
</div>
</div>
</section>
)
}

Step 7: CTA Section

components/CTA.jsx

export default function CTA() {
return (
<section id="cta" className="py-20 bg-blue-600 text-white">
<div className="text-center px-6">
<h2 className="text-4xl font-bold">Ready To Grow?</h2>
<p className="mt-4">Let's discuss your next project.</p>
<button className="mt-8 bg-white text-blue-600 px-8 py-3 rounded-lg">
Contact Us
</button>
</div>
</section>
);
}

Step 8: Main App Component

App.jsx

import Hero from './components/Hero';
import Features from './components/Features';
import About from './components/About';
import Testimonials from './components/Testimonials';
import CTA from './components/CTA';
function App() {
return (
<>
<Hero />
<Features />
<About />
<Testimonials />
<CTA />
</>
);
}
export default App;

Step 9: SEO Optimization

public/index.html

<title>
Modern Business Landing Page
</title>
<meta
name="description"
content="Professional business landing page built using React and Tailwind CSS."
/>
<meta
name="keywords"
content="React, Tailwind CSS, Landing Page"
/>

Use semantic tags:

<header>
<section>
<main>
<footer>

instead of unnecessary divs.

Step 10: Deploy to Vercel

Install:

npm install -g vercel

Build project:

npm run build

Deploy:

vercel

Follow prompts.

You will receive:

https://your-project.vercel.app

Performance Tips

Lazy Load Components

const Hero = React.lazy(() =>
import("./Hero")
);

Optimize Images

Use:

WebP
AVIF

formats whenever possible.

Reduce Bundle Size

Remove unused libraries.

Use Tailwind Utility Classes

Avoid large custom CSS files.

What Makes a Landing Page Convert Better?

A high-converting landing page should:

✅ Clear headline

✅ Strong value proposition

✅ Social proof

✅ Testimonials

✅ Mobile-friendly layout

✅ Fast loading speed

✅ Clear call-to-action

Final Result

After completing this tutorial, you’ll have:

  • Fully Responsive Landing Page
  • Mobile-First Design
  • Smooth Scrolling
  • Framer Motion Animations
  • SEO-Friendly Structure
  • Production Deployment on Vercel
  • Clean React Component Architecture

This foundation can be used for:

  • Agency Websites
  • Startup Landing Pages
  • SaaS Products
  • Consulting Businesses
  • Portfolio Websites
  • Marketing Campaigns


💡 Found this tutorial helpful? Please Subscribe, If this content is helpful to You. Happy Coding! 🚀

rem vs px in CSS: What’s the Difference and When to Use Each?

When working with CSS, you often see units like px and rem.
But many developers get confused:

🤔 Should I use px or rem?

In this guide, you’ll learn:

  • What px and rem are
  • Key differences
  • Real-world use cases
  • When to use each (very important)

What is px in CSS?

px stands for pixels.

👉 It is a fixed unit, meaning it does not change based on screen size or user settings.


Example

h1 {
font-size: 16px;
}

👉 The font size will always be 16 pixels


What is rem in CSS?

rem stands for root em.

👉 It is a relative unit, based on the root (html) font size.


Example

html {
font-size: 16px;
}h1 {
font-size: 1rem;
}

👉 1rem = 16px


How rem Works

If:

html {
font-size: 16px;
}

Then:

rempx
1rem16px
2rem32px
0.5rem8px

Key Differences Between rem and px

Featurepxrem
TypeFixedRelative
Responsive❌ No✅ Yes
Based onScreen pixelsRoot font size
Accessibility❌ Poor✅ Better
ScalingNoYes

Why rem is Preferred in Modern CSS


🔹 1. Better Responsiveness

If root font size changes:

html {
font-size: 18px;
}

👉 All rem values scale automatically


🔹 2. Accessibility Support

Users can change browser font size → rem adjusts automatically

👉 Helps users with vision issues 👍


🔹 3. Consistent Design

You can control entire UI from one place (html)


When to Use px

Use px when you need precise control:

  • Borders
  • Shadows
  • Icons (fixed size)
  • Hairline elements

Example

border: 1px solid black;

When to Use rem

Use rem for:

  • Font sizes
  • Spacing (margin, padding)
  • Layout scaling

Example

p {
font-size: 1rem;
margin: 1.5rem;
}

Real-World Example


❌ Using px (Not Flexible)

.container {
padding: 20px;
}

✅ Using rem (Flexible)

.container {
padding: 1.25rem;
}

👉 Automatically adjusts with root font size


Common Mistakes


❌ Mixing units randomly

👉 Keep consistency


❌ Setting root font size incorrectly

html {
font-size: 10px;
}

👉 Use carefully


rem vs em (Quick Note)

  • rem → based on root
  • em → based on parent

👉 rem is easier to manage


Best Practice

👉 Use both together:

  • rem → layout & typography
  • px → borders & fine details

Real-World Use Cases

  • Responsive websites
  • Design systems
  • UI frameworks (like MUI)
  • Accessibility-friendly apps

Interview Tip

If asked:

“px vs rem?”

👉 Answer:

“px is fixed, while rem is relative to the root font size, making it more responsive and accessible.”


🏁 Final Summary

  • px = fixed unit
  • rem = scalable unit
  • Use rem for responsiveness
  • Use px for precision

👉 Modern CSS prefers rem


Related Articles

👉 Add these:


💡 Found this helpful? Subscribe to get simple CSS guides, real-world examples, and frontend tips. Happy Coding!

CSS Variables Explained: A Complete Guide with Examples (Beginner to Advanced)

CSS Variables (also called Custom Properties) are one of the most powerful features in modern CSS. They help you write clean, reusable, and maintainable styles.

In this guide, you’ll learn:

  • What CSS Variables are
  • Why we need them
  • How they work
  • Real-world examples
  • Best practices

What Are CSS Variables?

CSS Variables are custom values that you define and reuse in your CSS.

👉 They start with -- and are accessed using var().


Basic Example

:root {
--primary-color: blue;
}button {
background-color: var(--primary-color);
}

👉 Output:

  • Button background becomes blue

Why Do We Need CSS Variables?

Before CSS Variables, we had problems like:

❌ Repeating same values everywhere
❌ Difficult to update styles
❌ No dynamic theming


Example Without Variables

button {
background-color: blue;
}.header {
color: blue;
}

👉 If you want to change bluered, you must update everywhere ❌


With CSS Variables

:root {
--primary-color: blue;
}button {
background-color: var(--primary-color);
}.header {
color: var(--primary-color);
}

👉 Change once → updated everywhere ✅


How CSS Variables Work


🔹 Defining Variables

:root {
--main-color: green;
}

👉 :root = global scope


🔹 Using Variables

p {
color: var(--main-color);
}

Scope of CSS Variables


🔹 Global Scope

:root {
--color: red;
}

👉 Available everywhere


🔹 Local Scope

.card {
--color: blue;
}.card p {
color: var(--color);
}

👉 Only inside .card


Updating Variables Dynamically

You can update variables using JavaScript:

document.documentElement.style.setProperty('--primary-color', 'red');

👉 Instantly updates UI 🔥


Real-World Use Case: Theme Switching


Light Theme

:root {
--bg-color: white;
--text-color: black;
}

Dark Theme

.dark {
--bg-color: black;
--text-color: white;
}

Usage

body {
background-color: var(--bg-color);
color: var(--text-color);
}

👉 Just toggle .dark class → theme changes instantly


Fallback Values (Very Important)

color: var(--primary-color, red);

👉 If variable not defined → fallback to red


Advanced Example

:root {
--spacing: 10px;
}.container {
padding: calc(var(--spacing) * 2);
}

👉 Works with calculations 🔥


🆚 CSS Variables vs SCSS Variables

FeatureCSS VariablesSCSS Variables
Runtime change✅ Yes❌ No
Works in browser✅ Yes❌ Precompiled
Dynamic themes✅ Yes❌ No

Best Practices

  • Use meaningful names (--primary-color)
  • Define global variables in :root
  • Avoid overusing variables
  • Use for themes and reusable values

Where CSS Variables Are Used

  • React (MUI, Tailwind configs)
  • Theming systems
  • Design systems
  • Dark/light mode

Interview Tip

If asked:

“What are CSS variables?”

👉 Answer:

“CSS variables are reusable custom properties that allow dynamic styling and runtime updates in CSS.”


🏁 Final Summary

  • CSS Variables improve maintainability
  • They support dynamic updates
  • Useful for themes and reusable styles
  • Work directly in browser

Related Articles


💡 Found this helpful? Subscribe to get simple frontend tutorials, real-world examples, and developer tips. Happy Coding!