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 verifiedUses 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.jsonMethod 02 · Copy and paste
- 1. No extra dependencies — React and Tailwind CSS only.
- 2. Copy the source from the Code tab into
components/ui/spotlight-card.tsx. - 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.
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
| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | 360 | Spotlight diameter in px. |
| accent | string | "#FF7448" | Light colour for the glow and border highlight. |
| opacity | number | 0.16 | Inner glow strength (0–1). 0 leaves only the border highlight. |
| borderGlow | boolean | true | Light the 1px border under the pointer. |
| fadeDuration | number | 400 | Fade in / out duration in ms. |
| rounded | number | 20 | Corner radius in px. |
| ...props | HTMLAttributes<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
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.