Skip to main content
Clever Ops

Shader Image

A WebGL image surface (ogl) for React, ripple, pixelate, or sway displacement on hover, a token-drawn plate by default, and honest fallbacks to a plain image. Tailwind-themed, self-idling.

Preview & code

Loading Shader Image preview

Installation

pnpm dlx shadcn@latest add @cleverui/shader-image

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { ShaderImage } from '@/components/ui/shader-image'
Exampletsx
import { ShaderImage } from '@/components/ui/shader-image'

const programs = [
  { effect: 'ripple', note: 'radiating refraction' },
  { effect: 'pixelate', note: 'mosaic under the pointer' },
  { effect: 'sway', note: 'autonomous slow drift' },
] as const

export default function ShaderImageDemo() {
  return (
    <section className="bg-background py-16 sm:py-24">
      <div className="mx-auto max-w-6xl px-4 sm:px-6">
        <p className="font-mono text-[11px] uppercase tracking-[0.2em] text-muted-foreground sm:text-xs">
          Lab · WebGL material
        </p>
        <h2 className="mt-4 max-w-2xl text-3xl font-semibold tracking-tight text-balance text-foreground sm:text-4xl">
          One plate, three optics.
        </h2>
        <p className="mt-4 max-w-xl text-sm leading-relaxed text-muted-foreground sm:text-base">
          The same token-inked drafting plate run through three displacement programs, move
          across each surface. Touch devices receive the slow sway; browsers without WebGL get
          the plain image.
        </p>
        <div className="mt-10 grid gap-6 sm:grid-cols-3">
          {programs.map(({ effect, note }, i) => (
            <figure key={effect}>
              <ShaderImage
                effect={effect}
                className="aspect-[4/5] w-full rounded-2xl border border-border/60"
              />
              <figcaption className="mt-3 flex items-baseline justify-between gap-3">
                <span className="font-mono text-[11px] uppercase tracking-[0.2em] text-foreground">
                  {`0${i + 1} · ${effect}`}
                </span>
                <span className="text-xs text-muted-foreground">{note}</span>
              </figcaption>
            </figure>
          ))}
        </div>
      </div>
    </section>
  )
}

API reference

ShaderImage accepts the following props.

PropTypeDefaultDescription
srcstringimage url, omitted, the surface draws its own token-inked plate
altstringaccessible label; omit when purely decorative
effect'ripple' | 'pixelate' | 'sway''ripple'displacement program under fine pointers (coarse pointers always sway)
intensitynumber0.6displacement strength 0–1

…plus everything from React.HTMLAttributes<HTMLDivElement>: className, event handlers, aria attributes and the rest pass straight through.

Frequently asked questions

How do I install the Shader Image component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/shader-image`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Shader Image require?

Shader Image uses ogl on top of React and Tailwind CSS. You don't need to install it manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Shader Image to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services