Skip to content
WANCRAFT

B.06Cards & Containers

Spotlight Card

A card that reveals a soft radial light — inner glow and border highlight — under the pointer.

ReactCSSTailwindbasic

Overview

Spotlight Card lights the area beneath the pointer with a radial glow and traces the same light along its 1px border using a masked layer. The pointer position is written straight to CSS custom properties, so moving across the card costs no React renders; leaving fades the light out smoothly. When keyboard focus enters the card, a centred spotlight marks where you are.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/spotlight-card.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/spotlight-card.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/spotlight-card.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
1 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { SpotlightCard } from "@/components/ui/spotlight-card";

export function SpotlightCardExample() {
  return (
    <SpotlightCard className="w-80 p-6">
      <h3 className="text-lg font-medium">Realtime sync</h3>
      <p className="mt-2 text-sm opacity-70">Every change lands everywhere in under 80ms.</p>
    </SpotlightCard>
  );
}

03Props

PropTypeDefaultDescription
sizenumber360Spotlight diameter in px.
accentstring"#FF7448"Light colour for the glow and border highlight.
opacitynumber0.16Inner glow strength (0–1). 0 leaves only the border highlight.
borderGlowbooleantrueLight the 1px border under the pointer.
fadeDurationnumber400Fade in / out duration in ms.
roundednumber20Corner radius in px.
...propsHTMLAttributes<HTMLDivElement>—Forwarded to the root <div> (className for size/padding, aria-*, etc.). The ref points to the root.

04Features

  • 01Inner radial glow plus a masked border highlight from the same light source
  • 02Pointer position stored in CSS variables — zero re-renders on move
  • 03Smooth fade out on leave with configurable duration
  • 04Centred spotlight when keyboard focus enters the card
  • 05Works with touch: the light follows a tap and fades after release
motion · tweeninput · pointerinput · hoverinput · focus

05Accessibility

  • Plain container with no added role; children keep their own semantics and tab order.
  • Keyboard focus (focus-visible) within the card switches on a centred spotlight as an extra focus cue; it switches off when focus leaves the card.
  • Both light layers are aria-hidden and ignore pointer events.
  • With prefers-reduced-motion the light appears and disappears without fading.

06Limitations

  • The light is decorative: keep a visible focus style on interactive children — the spotlight complements it, it does not replace it.