# Distortion Image

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

```tsx
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

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, DistortionImage } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { DistortionImage } from '@brand-studio/ui';
```

```tsx
<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

| Prop | Type | Default |
|---|---|---|
| `asset` | `ImageAsset` | – |
| `strength?` | `number` | `1` |
| `sizes?` | `string` | – |
| `className?` | `string` | `''` |

Source: https://brandstudio.js.org/docs/components/distortion-image/
