NCSS/AI Interface Collection
Digital Brain Animation
A premium, high-performance UI component built with Tailwind CSS and React.
Preview
Installation
Add the required dependencies if you haven't already:
1npm install framer-motion clsx tailwind-merge
Copy and paste the following code into your project:
1"use client";23import { motion } from "framer-motion";4import { useEffect, useState } from "react";56const Node = ({ x, y, delay }) => (7 <motion.circle8 cx={x}9 cy={y}10 r="4"11 fill="#8b5cf6"12 initial={{ opacity: 0.2, scale: 0.8 }}13 animate={{ opacity: [0.2, 1, 0.2], scale: [0.8, 1.2, 0.8] }}14 transition={{ duration: 2, delay, repeat: Infinity, ease: "easeInOut" }}15 />16);1718const Connection = ({ x1, y1, x2, y2, delay }) => (19 <motion.line20 x1={x1}21 y1={y1}22 x2={x2}23 y2={y2}24 stroke="#8b5cf6"25 strokeWidth="1.5"26 initial={{ pathLength: 0, opacity: 0 }}27 animate={{ pathLength: [0, 1, 1], opacity: [0, 0.5, 0] }}28 transition={{ duration: 3, delay, repeat: Infinity, ease: "easeInOut" }}29 />30);3132export default function DigitalBrainAnimation() {33 const [mounted, setMounted] = useState(false);3435 useEffect(() => {36 setMounted(true);37 }, []);3839 if (!mounted) return null;4041 // Manually plotted nodes to vaguely resemble a brain hemisphere42 const nodes = [43 { x: 150, y: 50 }, { x: 200, y: 40 }, { x: 250, y: 60 },44 { x: 120, y: 100 }, { x: 180, y: 90 }, { x: 230, y: 110 }, { x: 280, y: 100 },45 { x: 100, y: 160 }, { x: 160, y: 150 }, { x: 210, y: 160 }, { x: 270, y: 150 }, { x: 310, y: 140 },46 { x: 130, y: 220 }, { x: 190, y: 210 }, { x: 250, y: 220 }, { x: 290, y: 190 },47 { x: 170, y: 270 }, { x: 220, y: 260 }, { x: 260, y: 240 }48 ];4950 // Random connections51 const connections = [];52 for (let i = 0; i < nodes.length; i++) {53 for (let j = i + 1; j < nodes.length; j++) {54 const dist = Math.hypot(nodes[i].x - nodes[j].x, nodes[i].y - nodes[j].y);55 if (dist < 80) {56 connections.push({ n1: nodes[i], n2: nodes[j], delay: Math.random() * 2 });57 }58 }59 }6061 return (62 <div className="relative w-full h-[400px] flex items-center justify-center bg-[#030303] rounded-2xl border border-white/5 overflow-hidden">6364 {/* Background glow */}65 <div className="absolute inset-0 flex items-center justify-center pointer-events-none">66 <div className="w-[300px] h-[300px] bg-violet-600/10 rounded-full blur-[100px]" />67 </div>6869 <svg width="400" height="320" className="relative z-10" viewBox="0 0 400 320">70 {/* Draw connections */}71 {connections.map((conn, idx) => (72 <Connection73 key={`conn-${idx}`}74 x1={conn.n1.x}75 y1={conn.n1.y}76 x2={conn.n2.x}77 y2={conn.n2.y}78 delay={conn.delay}79 />80 ))}8182 {/* Draw nodes */}83 {nodes.map((n, idx) => (84 <Node key={`node-${idx}`} x={n.x} y={n.y} delay={Math.random() * 2} />85 ))}86 </svg>8788 <div className="absolute bottom-6 left-6 z-20">89 <h3 className="text-xl font-bold text-white tracking-wide">Neural Engine</h3>90 <p className="text-sm text-violet-400">Processing nodes active...</p>91 </div>92 </div>93 );94}95