A spotlight-new component from Aceternity UI.
From Aceternity UI
1"use client";
2import React from "react";
3import { motion } from "motion/react";
4
5type SpotlightProps = {
6 gradientFirst?: string;
7 gradientSecond?: string;
8 gradientThird?: string;
9 translateY?: number;
10 width?: number;
11 height?: number;
12 smallWidth?: number;
13 duration?: number;
14 xOffset?: number;
15};
16
17export const Spotlight = ({
18 gradientFirst = "radial-gradient(68.54% 68.72% at 55.02% 31.46%, hsla(210, 100%, 85%, .08) 0, hsla(210, 100%, 55%, .02) 50%, hsla(210, 100%, 45%, 0) 80%)",
19 gradientSecond = "radial-gradient(50% 50% at 50% 50%, hsla(210, 100%, 85%, .06) 0, hsla(210, 100%, 55%, .02) 80%, transparent 100%)",
20 gradientThird = "radial-gradient(50% 50% at 50% 50%, hsla(210, 100%, 85%, .04) 0, hsla(210, 100%, 45%, .02) 80%, transparent 100%)",
21 translateY = -350,
22 width = 560,
23 height = 1380,
24 smallWidth = 240,
25 duration = 7,
26 xOffset = 100,
27}: SpotlightProps = {}) => {
28 return (
29 <motion.div
30 initial={{
31 opacity: 0,
32 }}
33 animate={{
34 opacity: 1,
35 }}
36 transition={{
37 duration: 1.5,
38 }}
39 className="pointer-events-none absolute inset-0 h-full w-full"
40 >
41 <motion.div
42 animate={{
43 x: [0, xOffset, 0],
44 }}
45 transition={{
46 duration,
47 repeat: Infinity,
48 repeatType: "reverse",
49 ease: "easeInOut",
50 }}
51 className="absolute top-0 left-0 w-screen h-screen z-40 pointer-events-none"
52 >
53 <div
54 style={{
55 transform: `translateY(${translateY}px) rotate(-45deg)`,
56 background: gradientFirst,
57 width: `${width}px`,
58 height: `${height}px`,
59 }}
60 className={`absolute top-0 left-0`}
61 />
62
63 <div
64 style={{
65 transform: "rotate(-45deg) translate(5%, -50%)",
66 background: gradientSecond,
67 width: `${smallWidth}px`,
68 height: `${height}px`,
69 }}
70 className={`absolute top-0 left-0 origin-top-left`}
71 />
72
73 <div
74 style={{
75 transform: "rotate(-45deg) translate(-180%, -70%)",
76 background: gradientThird,
77 width: `${smallWidth}px`,
78 height: `${height}px`,
79 }}
80 className={`absolute top-0 left-0 origin-top-left`}
81 />
82 </motion.div>
83
84 <motion.div
85 animate={{
86 x: [0, -xOffset, 0],
87 }}
88 transition={{
89 duration,
90 repeat: Infinity,
91 repeatType: "reverse",
92 ease: "easeInOut",
93 }}
94 className="absolute top-0 right-0 w-screen h-screen z-40 pointer-events-none"
95 >
96 <div
97 style={{
98 transform: `translateY(${translateY}px) rotate(45deg)`,
99 background: gradientFirst,
100 width: `${width}px`,
101 height: `${height}px`,
102 }}
103 className={`absolute top-0 right-0`}
104 />
105
106 <div
107 style={{
108 transform: "rotate(45deg) translate(-5%, -50%)",
109 background: gradientSecond,
110 width: `${smallWidth}px`,
111 height: `${height}px`,
112 }}
113 className={`absolute top-0 right-0 origin-top-right`}
114 />
115
116 <div
117 style={{
118 transform: "rotate(45deg) translate(180%, -70%)",
119 background: gradientThird,
120 width: `${smallWidth}px`,
121 height: `${height}px`,
122 }}
123 className={`absolute top-0 right-0 origin-top-right`}
124 />
125 </motion.div>
126 </motion.div>
127 );
128};
129