Micro-interactions

Holofoil

Holographic trading-card foil over real content. The diffraction band travels against the tilt while the specular follows it, and the flake only lights where the rainbow currently falls — which is what stops the whole thing reading as one gradient sliding around.

Install

# Holofoil needs no npm packages

Then copy 2 files into your project:

  • components/registry/holofoil/holofoil.tsx
  • hooks/use-animation-loop.ts

Props

PropTypeDefaultDescription
maxTiltnumber14Maximum lean at the card's edge. The tilt is only the carrier here — set it to zero and the foil still moves, because the bands are driven by pointer position rather than by the rotation.
perspectivenumber800Depth of the projection. Lower exaggerates the lean; the value that reads as expensive is nearly always further away than instinct suggests.
foil"rainbow" | "reverse" | "cosmic" | "linear" | "none""rainbow"Which diffraction pattern the laminate carries. Rainbow is the repeating twelve-stop spectrum a real holographic sheet produces — it repeats rather than running one rainbow across the card. Reverse runs it the other way so the band travels against the tilt, which is what most people actually recognise as foil.
foilIntensitynumber0.75Strength of the diffraction band. Past about one it stops being laminate and starts being a sticker.
sparklenumber0.5Density of the flake. It is masked by the diffraction band rather than laid over the card, and that coupling is the entire reason the specks read as suspended inside the laminate instead of as dust on your screen.
glarenumber0.45The broad specular band, kept separate from the foil on purpose. Foil is diffraction and moves against the tilt; glare is reflection and follows it. Running both, opposed, is what gives the surface a material.
idleDriftnumber0.2How much the foil keeps moving with no pointer on it, on two incommensurate rates so the idle never settles into an obvious period. A card in a case is never quite still, and a completely dead card in a grid reads as an image rather than an object.
settlenumber0.12Seconds the card takes to catch up to the pointer. Near zero it is welded to the cursor and reads as a texture map; too high and it lags far enough that the foil stops feeling attached to your hand.
blendMode"color-dodge" | "screen" | "overlay" | "hard-light" | "plus-lighter""color-dodge"How the foil composites onto whatever you wrapped. Colour-dodge behaves like real foil — it blows out where the card is already bright and does almost nothing in the shadows. Screen is the safe one on a light card.
sheenColorstring (hex)"#a855f7"The colour carried by the specular sheen.

What It Demonstrates

Hover effect
Visual change when the cursor moves over an element.
3D tilt / Flip
Rotate in 3D space (rotateX / rotateY) to add depth.
Perspective
How strong the 3D effect looks — a lower value exaggerates depth, like the viewer is closer.
Idle animation
Subtle motion that plays while an element is just sitting there, waiting to be interacted with.
Compositing
Letting the GPU move or fade an element on its own layer without redoing layout or paint.
Hardware acceleration
Animating transform and opacity lets the GPU keep motion smooth.

Related Components

Appears In