Iridescent Foil
A holographic sheen for cards and badges that shifts as the pointer moves, as if the surface were tilted toward the light.
Overview
Iridescent Foil gives a surface the look of thin-film foil. Soft bands of cyan, lilac, rose, and pale gold slide across it, with most of the color held in one glint that follows the light. A few fine sparkles catch the light inside the glint.
With the pointer over the surface, the light follows the pointer and the whole surface tilts slightly toward it. At rest, the light drifts slowly. Use it on one special surface, such as a membership card, a plan badge, an achievement, or a pricing tier, rather than on every card.
Installation
Usage
Iridescent Foil is the surface itself: give it the card's size, background, border, and radius, and put the content inside it.
import { IridescentFoil } from "honestui/shaders"
<IridescentFoil className="aspect-[1.586] w-full max-w-sm rounded-2xl border bg-card">
<div className="flex size-full flex-col justify-between p-6">
<span className="text-sm font-medium">Honest Pro</span>
<span className="text-lg font-medium">March 2024</span>
</div>
</IridescentFoil>Under or over the content
By default the sheen is drawn under the children, like a foil background printed beneath the text. Set layer="over" to draw it over the children as well, like a laminate. The sheen never receives pointer events in either layer, so links and buttons inside keep working.
Prefer under for anything people need to read. Over the content, the sheen lowers the contrast of text at its brightest point; if you use over, keep intensity low and check contrast where the glint passes over text.
Accessibility
The sheen is decorative and its canvas is hidden from assistive technology. The children stay normal HTML.
The tilt follows a mouse or pen, not touch, so scrolling on a phone does not tip the card. The drift stops while the surface is offscreen or the tab is hidden. When the user prefers reduced motion, the drift stops and the surface does not tilt; the sheen still moves with the pointer, since the person is moving it. Without WebGL2 the surface shows only its own background.