Spotlight card
A card lit by a spotlight that follows the pointer, border included.
$
pnpm dlx shadcn@latest add https://lodeui.com/r/spotlight-card.jsonEdge-fast
Served from 30 regions.
Private by default
Encrypted at rest and in transit.
Zero config
Works with your stack today.
components/examples/spotlight-card-demo.tsx
"use client";
import { Cpu, Lock, Zap } from "lucide-react";
import { SpotlightCard } from "@/components/ui/spotlight-card";
const items = [
{ icon: Zap, t: "Edge-fast", d: "Served from 30 regions." },
{ icon: Lock, t: "Private by default", d: "Encrypted at rest and in transit." },
{ icon: Cpu, t: "Zero config", d: "Works with your stack today." },
];
export default function SpotlightCardDemo() {
return (
<div className="grid w-full max-w-3xl gap-3 sm:grid-cols-3">
{items.map(({ icon: Icon, t, d }) => (
<SpotlightCard key={t} className="p-6">
<Icon className="size-5" />
<p className="mt-4 font-medium">{t}</p>
<p className="mt-1 text-sm text-muted-foreground">{d}</p>
</SpotlightCard>
))}
</div>
);
}When to use
- Feature grids and pricing cards on marketing pages.
When not to use
- Dense app UI where hover effects distract.
Installation
$
pnpm dlx shadcn@latest add https://lodeui.com/r/spotlight-card.json1Copy the source into your project
components/ui/spotlight-card.tsx"use client"; import * as React from "react"; import { cn } from "@/lib/utils"; export interface SpotlightCardProps extends React.HTMLAttributes<HTMLDivElement> { /** Any CSS color for the light. */ color?: string; size?: number; } /** A card lit by a soft spotlight that follows the pointer, including on its border. */ export function SpotlightCard({ color = "color-mix(in oklab, var(--foreground) 10%, transparent)", size = 360, className, children, ...props }: SpotlightCardProps) { const ref = React.useRef<HTMLDivElement>(null); const onMove = (e: React.PointerEvent) => { const el = ref.current; if (!el) return; const r = el.getBoundingClientRect(); el.style.setProperty("--sx", `${e.clientX - r.left}px`); el.style.setProperty("--sy", `${e.clientY - r.top}px`); }; return ( <div ref={ref} onPointerMove={onMove} className={cn("group relative overflow-hidden rounded-xl border border-border bg-card", className)} style={{ "--spot": color, "--spot-size": `${size}px` } as React.CSSProperties} {...props} > <div aria-hidden className="pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:hidden" style={{ background: "radial-gradient(var(--spot-size) circle at var(--sx) var(--sy), var(--spot), transparent 60%)" }} /> <div aria-hidden className="pointer-events-none absolute inset-0 rounded-[inherit] opacity-0 transition-opacity duration-300 group-hover:opacity-100 motion-reduce:hidden" style={{ padding: 1, background: "radial-gradient(calc(var(--spot-size) * 0.6) circle at var(--sx) var(--sy), color-mix(in oklab, var(--foreground) 35%, transparent), transparent 60%)", WebkitMask: "linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)", WebkitMaskComposite: "xor", maskComposite: "exclude", }} /> <div className="relative">{children}</div> </div> ); }
Usage
Import it from @/components/ui/spotlight-card after installing.
example.tsx
import { SpotlightCard } from "@/components/ui/spotlight-card";
export function Feature() {
return <SpotlightCard className="p-6"><h3>Fast by default</h3></SpotlightCard>;
}API reference
SpotlightCard
A card lit by a soft light that follows the pointer, including on its border.
| Prop | Type | Default | Description |
|---|---|---|---|
| color | string | 10% foreground | Light color. |
| size | number | 360 | Light radius in px. |
Accessibility
- The light layers are aria-hidden and hidden under reduced motion.
Motion
- Follows the pointer; fades in on hover.
Responsive behavior
- Touch screens just see the card.
Performance
- Updates CSS variables, not React state.
Notes for AI
- Put interactive content inside as normal.
This page as Markdown, for assistants and coding agents:
/components/spotlight-card/markdownThe full library index for assistants is at /llms.txt.
Lode222 doc pagesllms.txt