text follow

by smombartz

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Cursor with Circular Text</title>
  <style>
    body {
      margin: 0;
      height: 100vh;
      overflow: hidden;
      cursor: none; /* Hide default cursor */
    }

    .custom-cursor {
      position: fixed;
      pointer-events: none;
      z-index: 10000;
      transform: translate(-50%, -50%);
    }

    .dot {
      width: 10px;
      height: 10px;
      background-color: black;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
    }

    svg.circleText {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 100px; /* Adjust size of the text circle */
      height: 100px;
      pointer-events: none; /* Prevent SVG from interfering with mouse events */
    }

    text {
      font-size: 60px; /* Adjust font size to fit within the path */
      font-family: Roboto, sans-serif;
      fill: black;
    }
  </style>
</head>
<body>
  <div class="custom-cursor">
    <div class="dot"></div>
    <svg class="circleText" viewBox="0 0 600 600">
      <path id="textcircle" fill="none" stroke="none"
            d="M300,300m-150,0a150,150,0,1,1,300,0a150,150,0,1,1,-300,0">
      </path>
      <text dy="-5">  
        <textPath xlink:href="#textcircle">Who do you want to become?</textPath>
      </text>
    </svg>
  </div>

  <script>
    // Select the custom cursor element
    const customCursor = document.querySelector('.custom-cursor');

    // Listen for mouse movement and update the cursor's position
    document.addEventListener('mousemove', (e) => {
      customCursor.style.left = `${e.pageX}px`;
      customCursor.style.top = `${e.pageY}px`;
    });
  </script>
</body>
</html>