NCSS/Snake Engine™ Series
Box Snake Background
A premium, high-performance UI component built with Tailwind CSS and React.
Preview
Loading 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";45export default function BoxSnakeBackground({6 children,7 color = "#6366f1", // Indigo 5008 backgroundColor = "#000000"9}) {10 return (11 <div12 className="relative w-full h-full min-h-[300px] flex items-center justify-center overflow-hidden rounded-2xl"13 style={{ backgroundColor }}14 >15 {/* The glowing box border */}16 <div className="absolute inset-4 rounded-xl border border-white/5 overflow-hidden">1718 {/* Snake Top */}19 <motion.div20 className="absolute top-0 left-0 h-[2px] w-[30%]"21 style={{22 background: `linear-gradient(90deg, transparent, ${color}, transparent)`,23 boxShadow: `0 0 10px ${color}, 0 0 20px ${color}`24 }}25 animate={{ x: ["-100%", "400%"] }}26 transition={{ duration: 4, repeat: Infinity, ease: "linear" }}27 />2829 {/* Snake Right */}30 <motion.div31 className="absolute top-0 right-0 w-[2px] h-[30%]"32 style={{33 background: `linear-gradient(180deg, transparent, ${color}, transparent)`,34 boxShadow: `0 0 10px ${color}, 0 0 20px ${color}`35 }}36 animate={{ y: ["-100%", "400%"] }}37 transition={{ duration: 4, repeat: Infinity, ease: "linear", delay: 1 }}38 />3940 {/* Snake Bottom */}41 <motion.div42 className="absolute bottom-0 right-0 h-[2px] w-[30%]"43 style={{44 background: `linear-gradient(270deg, transparent, ${color}, transparent)`,45 boxShadow: `0 0 10px ${color}, 0 0 20px ${color}`46 }}47 animate={{ x: ["400%", "-100%"] }}48 transition={{ duration: 4, repeat: Infinity, ease: "linear", delay: 2 }}49 />5051 {/* Snake Left */}52 <motion.div53 className="absolute bottom-0 left-0 w-[2px] h-[30%]"54 style={{55 background: `linear-gradient(360deg, transparent, ${color}, transparent)`,56 boxShadow: `0 0 10px ${color}, 0 0 20px ${color}`57 }}58 animate={{ y: ["400%", "-100%"] }}59 transition={{ duration: 4, repeat: Infinity, ease: "linear", delay: 3 }}60 />61 </div>6263 <div className="relative z-10 w-full h-full flex flex-col items-center justify-center p-8 text-center">64 {children || (65 <h2 className="text-3xl font-bold text-white tracking-widest uppercase" style={{ textShadow: `0 0 20px ${color}` }}>66 Box Snake67 </h2>68 )}69 </div>70 </div>71 );72}73