Ir al contenido
Español
Tarjeta con foco de luz viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

Two decorative layers sit inside each card: a glow (solid colour under a radial mask) and a border light (a radial gradient revealed only on the 1px ring around the card). JS writes the pointer position to CSS variables, throttled with rAF. SpotlightGroup reads every card's position once and writes coordinates relative to each card, so one pointer lights several cards. Scrolling while hovering recomputes.

Úsalo para

  • Feature cards on a landing page, three or four in a row (use SpotlightGroup).
  • Pricing cards and product blocks on a dark theme that need a tactile feel.
  • Card grids where it helps to show where the pointer is, such as category entries.

Busca otra opción cuando

  • Mobile: there is no hover, so never rely on the light to convey information.
  • Dense admin lists and tables: the effect distracts.
  • Cards with gradient, dashed or thick borders: the border light only fits a 1px edge.

Uso

import { SpotlightCard, SpotlightGroup } from './SpotlightCard.jsx'

// A single card
<SpotlightCard size={320} intensity={0.7}>
  <h3>Instant sync</h3>
  <p>Changes reach every device in 2 seconds</p>
</SpotlightCard>

// In a group: the borders of neighbouring cards light up together
<SpotlightGroup color="#ffffff" style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 12 }}>
  {features.map((f) => (
    <SpotlightCard key={f.id}>{f.title}</SpotlightCard>
  ))}
</SpotlightGroup>

Propiedades

PropiedadTipoPor defectoQué hace
sizenumber320Spot diameter in px. Cards inside a SpotlightGroup inherit the group's value.
intensitynumber0.7Strength from 0 to 1. Controls the glow (× 0.3) and the border light.
colorstring'var(--ds-accent)'Colour of the light. White works best on dark backgrounds.
childrenReactNode—Card content. By default the card has 20px padding, a 24px radius and no border: a hairline ring and a soft shadow (--ds-shadow-card) lift it, and the border light runs on that ring. Override with className or style.
...restHTMLAttributes<HTMLDivElement>—Other attributes go to the root <div> (same for SpotlightCard and SpotlightGroup).

Accesibilidad

  • Both light layers are aria-hidden decoration and do not affect screen readers or the keyboard.
  • Only mouse and pen respond; touch screens (hover: none) show nothing.
  • The light changes brightness only, with no movement, so it stays on under reduced motion; content contrast never depends on it.

Movimiento

Lights up in 160ms ease-out and fades in 360ms standard; pointer following is throttled to one update per frame.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

SpotlightCard.jsxspotlight-card.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Tarjetas
Tarjeta con borde animado viene con Pro. La vista previa aparece al desbloquearlo.
Borde con haz de luz viene con Pro. La vista previa aparece al desbloquearlo.
Tarjeta con hoja de datos viene con Pro. La vista previa aparece al desbloquearlo.