Skip to content
iraankPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Neon Flow — Interactive 3D Tubes Background Component

A React component that renders an interactive 3D tubes background using Three.js, with smooth animations powered by Framer Motion and GSAP.

Features

✨ Three.js 3D Effect — Liquid shader background with animated monolyth (icosahedron)
🎨 Interactive — Cursor tracking and click-to-randomize colors
⚡ Optimized — Loaded via CDN, no large bundled dependencies
🎭 Framer Motion — Smooth reveal animations and magnetic CTA
📱 Responsive — Works on all screen sizes

Tech Stack

  • React 18 + TypeScript
  • Next.js 14 (App Router)
  • Tailwind CSS (styling)
  • Framer Motion (animations)
  • Three.js (via CDN) — threejs-components library

Quick Start

1. Install Dependencies

npm install
# or
yarn install

2. Set Up Tailwind CSS (if not already done)

npx tailwindcss init -p

This creates tailwind.config.js and postcss.config.js.

3. Configure TypeScript Paths

In tsconfig.json, ensure you have:

{
  "compilerOptions": {
    "paths": {
      "@/*": ["./*"]
    }
  }
}

4. Run Development Server

npm run dev
# or
yarn dev

Visit http://localhost:3000 to see the component in action.

Component Usage

Basic Example

import { TubesBackground } from '@/components/ui/neon-flow';

export default function Page() {
  return (
    <TubesBackground>
      <div className="flex items-center justify-center h-full">
        <h1 className="text-6xl text-white">Your Content Here</h1>
      </div>
    </TubesBackground>
  );
}

Props

Prop Type Default Description
children React.ReactNode undefined Content to render above the background
className string undefined Additional CSS classes for the container
enableClickInteraction boolean true Allow color randomization on click

How It Works

  1. Canvas Setup — The component creates a canvas element for Three.js
  2. Shader Loading — Loads threejs-components library from CDN
  3. 3D Rendering — Renders liquid shader background + animated icosahedron
  4. Interaction — Tracks cursor movement and handles click events
  5. Overlay — Content is rendered in a z-10 overlay above the 3D effect

Customization

Change Colors

Edit neon-flow.tsx, update the TubesCursor configuration:

const app = TubesCursor(canvasRef.current, {
  tubes: {
    colors: ["#your", "#custom", "#colors"],
    lights: {
      intensity: 200,
      colors: ["#light1", "#light2", "#light3", "#light4"]
    }
  }
});

Adjust Animation Speed

Modify the shader parameters in the CDN library configuration (limited by external library).

Browser Support

  • Chrome 90+
  • Firefox 88+
  • Safari 15+
  • Edge 90+

Requires WebGL 2.0 support.

File Structure

neon-flow/
├── app/
│   ├── globals.css          # Global Tailwind styles
│   ├── layout.tsx           # Root layout
│   └── page.tsx             # Demo page
├── components/
│   └── ui/
│       └── neon-flow.tsx    # Main component
├── lib/
│   └── utils.ts             # cn() utility function
├── package.json
├── tsconfig.json
├── tailwind.config.js
├── next.config.js
├── postcss.config.js
└── README.md

Notes

  • The Three.js library is loaded dynamically from CDN (threejs-components@0.0.19)
  • Canvas resizes automatically on window resize
  • Uses pointer-events-none on canvas to allow interaction with overlay content
  • TypeScript support is fully configured

License

MIT


Built for Vlad Yasko's Skill Library 🚀

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages