Distortion Image

An image that ripples and splits its colour around the pointer, then settles.

A cobalt ceramic cup of coffee on a brushed steel counter in morning light.
The cobalt cup. Move the pointer across it.
import { DistortionImage } from '@brand-studio/ui';
import { cup } from '@/demos/assets';

export default function DistortionImageDemo() {
  return (
    <figure style={{ width: '100%', maxWidth: 560, margin: 0 }}>
      <DistortionImage asset={cup} sizes="560px" className="demo-distort" />
      <figcaption style={{ marginTop: 12, fontSize: 14, color: 'var(--bs-muted)' }}>The cobalt cup. Move the pointer across it.</figcaption>
      <style>{'.demo-distort { aspect-ratio: 4 / 3; }'}</style>
    </figure>
  );
}

Installation

pnpm add @brand-studio/ui

Usage

import { DistortionImage } from '@brand-studio/ui';
<DistortionImage asset={cup} className="cup" /> // .cup { aspect-ratio: 4 / 3; }

Give it a size with CSS; the image covers the box and keeps its focal point. The image must be served from the same origin, or with CORS headers, for WebGL to read it.

Accessibility

  • The picture underneath is an ordinary image with its alt text; the canvas over it is hidden from screen readers.
  • The effect only answers a mouse, so touch, pen and keyboard users see the still image.
  • It is off under reduced motion and without WebGL.

API Reference

PropTypeDefault
assetImageAsset–
strength?number1
sizes?string–
className?string''

Still, Deskhand and Hollis are fictional brands. The coffee photographs are original generated artwork. @brand-studio/ui is MIT licensed.