Here's a comprehensive 3D portfolio implementation using React, Three.js, and Tailwind CSS. This code features a 3D scene with interactive elements and smooth animations:
// App.js
import React, { useRef } from 'react';
import { Canvas } from '@react-three/fiber';
import { OrbitControls, Stars, Float } from '@react-three/drei';
import { motion } from 'framer-motion';
// 3D Model Component
const BoxModel = () => {
return (
<Float speed={3} rotationIntensity={2} floatIntensity={2}>
<mesh>
<boxGeometry args={[1.5, 1.5, 1.5]} />
<meshStandardMaterial color="#6366f1" metalness={0.8} roughness={0.2} />
</mesh>
</Float>
);
};
// Navigation Component
const Navigation = () => {
return (
<nav className="fixed top-0 w-full z-50 p-6">
<div className="flex justify-between items-center max-w-7xl mx-auto">
<motion.div
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
className="text-2xl font-bold text-indigo-500"
>
DevPortfolio
</motion.div>
<div className="flex space-x-8">
{['Home', 'Projects', 'Skills', 'Contact'].map((item) => (
<motion.a
key={item}
href={`#${item.toLowerCase()}`}
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.9 }}
className="text-white hover:text-indigo-400 transition-colors"
>
{item}
</motion.a>
))}
</div>
</div>
</nav>
);
};
// Hero Section
const HeroSection = () => {
return (
<section className="h-screen relative">
<Canvas className="absolute top-0 left-0">
<ambientLight intensity={0.5} />
<pointLight position={[10, 10, 10]} />
<BoxModel />
<OrbitControls enableZoom={false} />
<Stars radius={100} depth={50} count={5000} factor={4} />
</Canvas>
<div className="absolute inset-0 bg-gradient-to-b from-black/70 to-black/90 flex items-center">
<div className="max-w-7xl mx-auto px-6">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.2 }}
className="text-center"
>
<h1 className="text-6xl font-bold text-white mb-4">
Hi, I'm <span className="text-indigo-500">Alex</span>
</h1>
<h2 className="text-3xl text-gray-300 mb-8">
Frontend Developer & 3D Enthusiast
</h2>
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
className="bg-indigo-600 text-white px-8 py-4 rounded-full text-lg font-semibold"
>
View My Work
</motion.button>
</motion.div>
</div>
</div>
</section>
);
};
// Project Card Component
const ProjectCard = ({ title, description }) => {
return (
<motion.div
whileHover={{ y: -10, boxShadow: '0 20px 25px -5px rgba(99, 102, 241, 0.3)' }}
className="bg-gray-800 p-6 rounded-xl border border-gray-700"
>
<div className="bg-gray-700 h-48 rounded-lg mb-4 flex items-center justify-center">
<div className="bg-indigo-500/20 w-full h-full rounded-lg flex items-center justify-center">
<span className="text-indigo-500 text-5xl">3D</span>
</div>
</div>
<h3 className="text-xl font-bold text-white mb-2">{title}</h3>
<p className="text-gray-400">{description}</p>
<button className="mt-4 text-indigo-400 hover:text-indigo-300 transition-colors">
View Project →
</button>
</motion.div>
);
};
// Projects Section
const ProjectsSection = () => {
return (
<section id="projects" className="py-20 bg-gray-900">
<div className="max-w-7xl mx-auto px-6">
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
className="text-center mb-16"
>
<h2 className="text-4xl font-bold text-white mb-4">My Projects</h2>
<div className="w-20 h-1 bg-indigo-500 mx-auto"></div>
</motion.div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<ProjectCard
title="3D E-Commerce Experience"
description="Interactive shopping experience with Three.js and React"
/>
<ProjectCard
title="WebGL Data Visualization"
description="Complex data represented in 3D space with animations"
/>
<ProjectCard
title="VR Portfolio Concept"
description="Browser-based VR portfolio using WebXR"
/>
</div>
</div>
</section>
);
};
// Skills Section
const SkillsSection = () => {
const skills = [
{ name: 'React', level: 90 },
{ name: 'Three.js', level: 85 },
{ name: 'JavaScript', level: 95 },
{ name: 'Tailwind CSS', level: 90 },
{ name: 'WebGL', level: 75 },
{ name: 'Node.js', level: 80 },
];
return (
<section id="skills" className="py-20">
<div className="max-w-7xl mx-auto px-6">
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
className="text-center mb-16"
>
<h2 className="text-4xl font-bold text-white mb-4">My Skills</h2>
<div className="w-20 h-1 bg-indigo-500 mx-auto"></div>
</motion.div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-10">
{skills.map((skill, index) => (
<motion.div
key={skill.name}
initial={{ opacity: 0, x: index % 2 === 0 ? -20 : 20 }}
whileInView={{ opacity: 1, x: 0 }}
viewport={{ once: true }}
transition={{ delay: index * 0.1 }}
>
<div className="flex justify-between mb-2">
<span className="text-lg font-medium text-white">{skill.name}</span>
<span className="text-lg text-indigo-500">{skill.level}%</span>
</div>
<div className="h-3 bg-gray-700 rounded-full overflow-hidden">
<motion.div
initial={{ width: 0 }}
whileInView={{ width: `${skill.level}%` }}
viewport={{ once: true }}
transition={{ duration: 1, delay: 0.3 }}
className="h-full bg-indigo-500 rounded-full"
/>
</div>
</motion.div>
))}
</div>
</div>
</section>
);
};
// Contact Section
const ContactSection = () => {
return (
<section id="contact" className="py-20 bg-gray-900">
<div className="max-w-7xl mx-auto px-6">
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
className="text-center mb-16"
>
<h2 className="text-4xl font-bold text-white mb-4">Get In Touch</h2>
<div className="w-20 h-1 bg-indigo-500 mx-auto"></div>
</motion.div>
<div className="max-w-3xl mx-auto">
<motion.div
whileHover={{ scale: 1.02 }}
className="bg-gray-800 p-8 rounded-xl border border-gray-700"
>
<form className="space-y-6">
<div>
<label className="block text-gray-400 mb-2">Name</label>
<input
type="text"
className="w-full bg-gray-700 text-white rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-indigo-500"
/>
</div>
<div>
<label className="block text-gray-400 mb-2">Email</label>
<input
type="email"
className="w-full bg-gray-700 text-white rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-indigo-500"
/>
</div>
<div>
<label className="block text-gray-400 mb-2">Message</label>
<textarea
rows="5"
className="w-full bg-gray-700 text-white rounded-lg px-4 py-3 focus:outline-none focus:ring-2 focus:ring-indigo-500"
></textarea>
</div>
<motion.button
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
className="w-full bg-indigo-600 text-white py-4 rounded-lg font-semibold"
>
Send Message
</motion.button>
</form>
</motion.div>
</div>
</div>
</section>
);
};
// Footer
const Footer = () => {
return (
<footer className="py-10 border-t border-gray-800">
<div className="max-w-7xl mx-auto px-6 text-center">
<div className="flex justify-center space-x-6 mb-6">
{['twitter', 'github', 'linkedin', 'dribbble'].map((platform) => (
<motion.a
key={platform}
href="#"
whileHover={{ y: -5, color: '#6366f1' }}
className="text-gray-400"
>
<span className="sr-only">{platform}</span>
<div className="w-6 h-6 bg-current rounded-full"></div>
</motion.a>
))}
</div>
<p className="text-gray-500">
© {new Date().getFullYear()} My 3D Portfolio. All rights reserved.
</p>
</div>
</footer>
);
};
// Main App Component
function App() {
const scrollRef = useRef(null);
return (
<div className="min-h-screen bg-gray-950 text-white" ref={scrollRef}>
<Navigation />
<HeroSection />
<ProjectsSection />
<SkillsSection />
<ContactSection />
<Footer />
</div>
);
}
export default App;
To run this application, you'll need to install the following dependencies:
npm install three @react-three/fiber @react-three/drei framer-motion
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Then configure your tailwind.config.js:
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {
colors: {
gray: {
950: '#0a0a12',
}
}
},
},
plugins: [],
}
And add to your index.css:
@tailwind base;
@tailwind components;
@tailwind utilities;
html {
scroll-behavior: smooth;
}
body {
overflow-x: hidden;
}
Key features of this portfolio:
-
3D Scene:
- Interactive 3D cube with floating animation
- Star background with depth effect
- Orbit controls for camera movement
-
Interactive Elements:
- Hover animations on cards and buttons
- Smooth scroll navigation
- Animated skill bars
- Interactive 3D model
-
Modern UI:
- Dark theme with indigo accents
- Responsive design for all screen sizes
- Glass-morphism inspired cards
- Animated section transitions
-
Components:
- 3D model with rotation and float effects
- Animated navigation
- Project cards with hover effects
- Skill progress bars
- Contact form with interactive elements
-
Performance:
- Optimized animations using Framer Motion
- Efficient Three.js rendering
- Tailwind CSS for minimal CSS footprint
To enhance this further, you could:
- Add more complex 3D models using GLTFLoader
- Implement scroll-based animations
- Add particle effects in the background
- Include actual project showcases with images/videos
- Add dark/light mode toggle
Remember to customize the content, colors, and 3D models to match your personal style and brand!