File size: 1,126 Bytes
a27839e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"use client";

import { useCallback } from "react";
import Particles from "react-tsparticles";
import type { Engine } from "tsparticles-engine";
import { loadStarsPreset } from "tsparticles-preset-stars";

const AnimatedBackground = () => {
  const particlesInit = useCallback(async (engine: Engine) => {
    // This function is compatible with the v2 engine provided by react-tsparticles
    await loadStarsPreset(engine);
  }, []);

  const options = {
    preset: "stars",
    background: {
      color: {
        value: "#0d1117",
      },
    },
    particles: {
      color: {
        value: "#ffffff",
      },
      links: {
        enable: false,
      },
      move: {
        enable: true,
        speed: 0.5,
        direction: "bottom",
        random: false,
        straight: true,
        outModes: {
          default: "out",
        },
      },
      size: {
        value: { min: 1, max: 2.5 },
      },
    },
  };

  return (
    <div className="fixed inset-0 -z-10">
      <Particles id="tsparticles" init={particlesInit} options={options as any} />
    </div>
  );
};

export default AnimatedBackground;