Skip to documentation content

Spotlight

A soft light that follows the pointer across a container and catches the borders of the cards inside it.

spotlight-demo

Overview

Spotlight adds a quiet glow under the pointer as it moves across a container. Cards inside it, rendered with SpotlightCard, light up along the part of their border nearest the pointer, even before the pointer reaches them, so a grid of cards reads as one lit surface. It suits feature grids, pricing tiers, and dashboards where a little depth helps without moving anything.

The surface glow follows the pointer with a light spring. Card borders update once per frame from a single listener on the container, so a large grid does not attach a handler to every card. Set glow={false} to light only the card borders.

Installation

npx honestui@latest add spotlight

Usage

import { Spotlight, SpotlightCard } from "@/components/animated/spotlight"

<Spotlight className="grid grid-cols-2 gap-3">
  <SpotlightCard className="p-4">Edge functions</SpotlightCard>
  <SpotlightCard className="p-4">Managed storage</SpotlightCard>
</Spotlight>

Colors accept any CSS color, including color-mix() and variables. The defaults are tints of --foreground, so the light works in both themes.

Accessibility

The light is decorative and hidden from assistive technology; the cards and their content are unchanged. It responds only to a mouse or trackpad: on touch devices and when the user prefers reduced motion, the cards render as plain bordered cards. Do not rely on the light to show focus or selection; style those states on the cards themselves.

API Reference

Spotlight

PropTypeDefaultDescription
sizenumber420Diameter of the light in px.
colorstring–Glow color on the container surface.
borderColorstring–Color of the light on card borders. Defaults to --foreground at 60%.
cardColorstring–Faint fill inside a card under the pointer.
glowbooleantrueShow the glow on the container surface.
classNamestring–Classes for the container, such as its grid layout.

SpotlightCard

PropTypeDefaultDescription
classNamestring–Classes for the card. It has a border, a card background, and rounded corners by default.