Works natively with Cursor. Add npx -y bare-ui-mcp to your MCP settings.

Spotlight Card

A beautiful interactive card that casts a soft radial glow matching your mouse movement. Highly engaging, zero dependencies.

Hover Me

Move your mouse around this card to see the spotlight effect in action. It calculates the relative position and applies a CSS gradient mask.

🔥

Brand Colors

You can easily pass a custom rgba color to the spotlightColor prop to match your brand theme perfectly.

Installation

1. Add the CSS to your global stylesheet:

css
/* Spotlight Card */
.bare-spotlight-card {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  transition: border-color 0.3s ease;
}

.bare-spotlight-card-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 1;
}

.bare-spotlight-card > * {
  position: relative;
  z-index: 2;
}

2. Copy the React component into your project:

tsx
"use client";

import React, { useRef, useState, MouseEvent } from "react";

export interface SpotlightCardProps extends React.HTMLAttributes<HTMLDivElement> {
  children: React.ReactNode;
  spotlightColor?: string;
}

export const SpotlightCard = ({
  children,
  className = "",
  spotlightColor = "rgba(255, 255, 255, 0.1)",
  ...props
}: SpotlightCardProps) => {
  const divRef = useRef<HTMLDivElement>(null);
  const [position, setPosition] = useState({ x: 0, y: 0 });
  const [opacity, setOpacity] = useState(0);

  const handleMouseMove = (e: MouseEvent<HTMLDivElement>) => {
    if (!divRef.current) return;

    const div = divRef.current;
    const rect = div.getBoundingClientRect();

    setPosition({ x: e.clientX - rect.left, y: e.clientY - rect.top });
  };

  const handleFocus = () => {
    setOpacity(1);
  };

  const handleBlur = () => {
    setOpacity(0);
  };

  const handleMouseEnter = () => {
    setOpacity(1);
  };

  const handleMouseLeave = () => {
    setOpacity(0);
  };

  return (
    <div
      ref={divRef}
      onMouseMove={handleMouseMove}
      onFocus={handleFocus}
      onBlur={handleBlur}
      onMouseEnter={handleMouseEnter}
      onMouseLeave={handleMouseLeave}
      className={`bare-spotlight-card ${className}`}
      {...props}
    >
      <div
        className="bare-spotlight-card-glow"
        style={{
          opacity,
          background: `radial-gradient(600px circle at ${position.x}px ${position.y}px, ${spotlightColor}, transparent 40%)`,
        }}
      />
      {children}
    </div>
  );
};

Usage

tsx
import { SpotlightCard } from '@/components/ui/spotlight-card';

export default function MyComponent() {
  return (
    <SpotlightCard
      className="p-6 max-w-sm"
      spotlightColor="rgba(255, 255, 255, 0.1)"
    >
      <h3>Interactive Card</h3>
      <p>Content goes here. Notice the subtle glow effect!</p>
    </SpotlightCard>
  );
}