Creating a 3D interactive portfolio website using React, Tailwind CSS, and some 3D libraries like Three.js or React Three Fiber is a great idea! Below, I'll provide a simple starter example that includes:
React for the structure
Tailwind CSS for styling
React Three Fiber for 3D interactive elements
Step 1: Setup your React project with Tailwind CSS and React Three Fiber
If you haven't already, create a React app and install dependencies:
bash Copy code
npx create-react-app my-3d-portfolio
cd my-3d-portfolio
# Install Tailwind CSS
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
# Install React Three Fiber and Drei (helper components)
npm install @react-three/fiber @react-three/drei three
Configure Tailwind CSS by editing tailwind.config.js:
js Copy code
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Add Tailwind directives to src/index.css:
css Copy code
@tailwind base;
@tailwind components;
@tailwind utilities;
Step 2: Create a simple 3D interactive portfolio component
Here’s a minimal example of a 3D rotating cube with React Three Fiber and Tailwind CSS styling.
Create a new file src/components/Portfolio3D.js:
jsx Copy code
import React, { useRef } from "react";
import { Canvas, useFrame } from "@react-three/fiber";
import { OrbitControls } from "@react-three/drei";
function RotatingCube() {
const meshRef = useRef();
// Rotate the cube every frame
useFrame(() => {
if (meshRef.current) {
meshRef.current.rotation.x += 0.01;
meshRef.current.rotation.y += 0.01;
}
});
return (
<mesh ref={meshRef} scale={1.5}>
<boxGeometry args={[1, 1, 1]} />
<meshStandardMaterial color="#3b82f6" />
</mesh>
);
}
export default function Portfolio3D() {
return (
<div className="w-full h-screen bg-gradient-to-r from-purple-600 to-blue-500 flex flex-col items-center justify-center text-white">
<h1 className="text-4xl font-bold mb-8">My 3D Portfolio</h1>
<div className="w-96 h-96 bg-black rounded-lg shadow-lg">
<Canvas>
<ambientLight intensity={0.5} />
<pointLight position={[10, 10, 10]} />
<RotatingCube />
<OrbitControls enableZoom={true} />
</Canvas>
</div>
<p className="mt-8 max-w-xl text-center px-4">
This is a simple interactive 3D cube. Use your mouse to rotate and zoom.
</p>
</div>
);
}
Step 3: Use the component in your app
Replace the content of src/App.js with:
jsx Copy code
import React from "react";
import Portfolio3D from "./components/Portfolio3D";
function App() {
return <Portfolio3D />;
}
export default App;
Step 4: Run your app
Open http://localhost:3000 and you should see a rotating 3D cube you can interact with.
How to expand this?
Replace the cube with your own 3D models (GLTF/GLB) using @react-three/drei's <Model /> loader.
Add sections with your projects, skills, and contact info styled with Tailwind.
Animate elements on scroll with libraries like framer-motion.
Add more complex 3D scenes or interactive elements.
If you want, I can help you build out specific sections or add more advanced 3D features! Just ask.