Skip to content
Back to the lab

feSpecularLighting · the light follows the pointer

A rim light that follows the pointer

A highlight on the card's rim that follows the pointer; only the edge lights up. The top navigation uses the same effect.

Source · GitHub

This is how the top navigation does it: a 1.5px white ring whose filter uses feSpecularLighting with SourceAlpha as the surface and an fePointLight as the light, then feComposite in clips the highlight back to the ring's own alpha, so only the edge is lit. The light's x and y are in the ring's own filter coordinates, which is the cursor position minus the card's top-left corner; each pointermove eases them over 0.3s on power2.out so the light moves smoothly. On the navigation the light stays above the capsule's top edge and follows x only. The card here is wider, so the light follows both x and y, sits higher (z 36) and has a broader hotspot (exponent 12), and the whole rim shows a highlight as the pointer crosses. Mouse-type pointers only.

Source

Source files on GitHub:

Back to the lab