Hover List Preview
Point at a row and its picture shows in one frame that follows the pointer, wiping to the next picture as you move down the list. Panel mode, keyboard and touch thumbnails included.
View codeFour ways for an image to answer the pointer, inside its own frame: a slow zoom, coming into focus, rounding off, or drifting with the cursor.
With your AI
Say it to your AI. It gets the exact code below, not its best guess, and knows where it goes.
Add Kodza Image Hover to my product thumbnails.
claude mcp add -t http kodza https://kodza.dev/api/mcp
<a class="kodza-image-hover" href="#">
<img src="https://kodza.dev/media/kz-block-1400.webp" alt="A tall concrete slab standing alone, its long shadow stretching toward the viewer" loading="lazy" />
</a>
<a class="kodza-image-hover kodza-image-hover--focus" href="#">
<img src="https://kodza.dev/media/kz-columns-1400.webp" alt="A row of square concrete pillars under a flat roof, casting striped shadows" loading="lazy" />
</a>
<a class="kodza-image-hover kodza-image-hover--round" href="#">
<img src="https://kodza.dev/media/kz-arch-1400.webp" alt="A concrete wall with a round-topped opening, sunlight pouring through it onto the ground" loading="lazy" />
</a>
<a class="kodza-image-hover kodza-image-hover--parallax" href="#">
<img src="https://kodza.dev/media/kz-stack-1400.webp" alt="Three concrete slabs stacked at slightly different angles" loading="lazy" />
</a>
/* Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license */
/* Kodza — Image Hover
Four ways for an image to answer the pointer, always inside its own frame:
(default) a slow zoom
--focus soft at rest, it comes into focus
--round the corners round off and the frame draws in a little
--parallax the image drifts with the pointer (with the small script)
Everything is tuned with the --kz-image-* variables. */
.kodza-image-hover {
--kz-image-ratio: 4 / 5;
--kz-image-radius: 4px;
--kz-image-zoom: 1.08;
--kz-image-duration: 1.1s;
--kz-image-ease: cubic-bezier(0.22, 1, 0.36, 1);
--kz-image-placeholder: rgba(10, 10, 10, 0.06);
position: relative;
display: block;
aspect-ratio: var(--kz-image-ratio);
overflow: hidden;
border-radius: var(--kz-image-radius);
background: var(--kz-image-placeholder);
clip-path: inset(0 round var(--kz-image-radius));
transition: clip-path var(--kz-image-duration) var(--kz-image-ease);
}
.kodza-image-hover img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
transform: scale(1.001);
transition: transform var(--kz-image-duration) var(--kz-image-ease), filter var(--kz-image-duration) var(--kz-image-ease);
}
.kodza-image-hover:hover img,
.kodza-image-hover:focus-visible img {
transform: scale(var(--kz-image-zoom));
}
.kodza-image-hover:focus-visible {
outline: 2px solid currentColor;
outline-offset: 4px;
}
/* Focus: blurred and slightly enlarged at rest, sharp under the pointer */
.kodza-image-hover--focus img {
filter: blur(8px);
transform: scale(1.06);
}
.kodza-image-hover--focus:hover img,
.kodza-image-hover--focus:focus-visible img {
filter: none;
transform: scale(1);
}
/* Round: the frame draws in and its corners round off */
.kodza-image-hover--round:hover,
.kodza-image-hover--round:focus-visible {
clip-path: inset(4% round 34%);
}
.kodza-image-hover--round:hover img,
.kodza-image-hover--round:focus-visible img {
transform: scale(1.02);
}
/* Parallax: the image is a little larger than its frame and follows the pointer */
.kodza-image-hover--parallax img {
transform: scale(1.14) translate(calc(var(--kz-x, 0) * -4%), calc(var(--kz-y, 0) * -4%));
transition-duration: 0.7s;
}
.kodza-image-hover--parallax:hover img,
.kodza-image-hover--parallax:focus-visible img {
transform: scale(1.14) translate(calc(var(--kz-x, 0) * -4%), calc(var(--kz-y, 0) * -4%));
}
@media (prefers-reduced-motion: reduce) {
.kodza-image-hover,
.kodza-image-hover img {
transition-duration: 0.01ms !important;
}
.kodza-image-hover--parallax img {
transform: scale(1.14) !important;
}
}
/* kodza-guard 6bf4c085e98c — generated by Kodza, do not edit.
Theme guard: keeps a site's own CSS (WordPress themes, Bootstrap, CSS resets…) off this
component. :not(#_) is always true and weighs as much as an id, so these lines win over
theme rules made of classes and tags. Customise the component through its --kz-* variables. */
/* What the browser gives, where the component sets it only in some states: at the lowest weight, so its own rules below put it back */
:where(.kodza-image-hover):not(#_) {
outline: revert;
outline-offset: revert;
}
/* What the browser gives, on everything the component leaves to it */
.kodza-image-hover:not(#_) {
border: revert;
padding: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
box-shadow: revert;
appearance: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
.kodza-image-hover img:where(:not([class*="kodza-"])):not(#_) {
border: revert;
margin: revert;
padding: revert;
border-radius: revert;
outline: revert;
text-decoration: revert;
list-style: revert;
box-sizing: revert;
float: revert;
position: revert;
background-color: revert;
background-image: revert;
box-shadow: revert;
outline-offset: revert;
appearance: revert;
max-width: revert;
max-height: revert;
color: revert;
font-family: revert;
font-size: revert;
font-weight: revert;
font-style: revert;
line-height: revert;
letter-spacing: revert;
text-transform: revert;
text-underline-offset: revert;
text-align: revert;
text-indent: revert;
text-shadow: revert;
vertical-align: revert;
}
/* The component's own rules, one step stronger: real buttons and fields, what it sets on tags themes style (links, lists, headings, images…), and the root width (a theme may narrow it, never widen it) */
.kodza-image-hover:not(#_) {
position: relative;
display: block;
border-radius: var(--kz-image-radius);
background: var(--kz-image-placeholder);
transition: clip-path var(--kz-image-duration) var(--kz-image-ease);
}
.kodza-image-hover img:not(#_) {
display: block;
transition: transform var(--kz-image-duration) var(--kz-image-ease), filter var(--kz-image-duration) var(--kz-image-ease);
}
.kodza-image-hover:focus-visible:not(#_) {
outline: 2px solid currentColor;
outline-offset: 4px;
}
.kodza-image-hover--parallax img:not(#_) {
transition-duration: 0.7s;
}
@media (prefers-reduced-motion: reduce) {
.kodza-image-hover:not(#_),
.kodza-image-hover img:not(#_) {
transition-duration: 0.01ms !important;
}
}
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Kodza — Image Hover
// Only needed for the --parallax variant: gives the image the pointer's position
// in its frame (-1 to 1 on each axis), and sends it back to the centre on leave.
(() => {
const SELECTOR = '.kodza-image-hover--parallax';
// One instance. Everything it starts is tied to `signal`, so kodza:destroy stops it all
function mount(frame, signal) {
frame.addEventListener('pointermove', (event) => {
const rect = frame.getBoundingClientRect();
frame.style.setProperty('--kz-x', (((event.clientX - rect.left) / rect.width) * 2 - 1).toFixed(3));
frame.style.setProperty('--kz-y', (((event.clientY - rect.top) / rect.height) * 2 - 1).toFixed(3));
}, { signal });
frame.addEventListener('pointerleave', () => {
frame.style.setProperty('--kz-x', 0);
frame.style.setProperty('--kz-y', 0);
}, { signal });
}
// Kodza lifecycle, the same in every component: `kodza:init` starts the instances inside
// event.detail.root (the whole page by default), `kodza:destroy` stops them and puts their
// markup back. For themes and apps that swap content without a page load.
const instances = new WeakMap();
const find = (scope = document) => [scope, ...scope.querySelectorAll(SELECTOR)].filter((el) => el.matches?.(SELECTOR));
const init = (scope) => find(scope).forEach((root) => {
if (root.classList.contains('is-ready')) return; // already running, maybe from another copy of this script
const controller = new AbortController();
instances.set(root, { controller, html: root.innerHTML, attrs: [...root.attributes].map((a) => [a.name, a.value]) });
mount(root, controller.signal);
root.classList.add('is-ready');
});
const destroy = (scope) => find(scope).forEach((root) => {
const instance = instances.get(root);
if (!instance) return;
instances.delete(root);
instance.controller.abort();
[...root.attributes].forEach((a) => root.removeAttribute(a.name));
instance.attrs.forEach(([name, value]) => root.setAttribute(name, value));
root.innerHTML = instance.html;
});
document.addEventListener('kodza:init', (event) => init(event.detail?.root));
document.addEventListener('kodza:destroy', (event) => destroy(event.detail?.root));
init();
// Loaded in <head>, the script runs before the markup exists: once more when it is parsed
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => init(), { once: true });
})();
'use client';
// Kodza — Image Hover, for React. From https://kodza.dev/components/image-scale/
// Kodza License: free to use, client work included. Not to resell or redistribute, ported or not: https://kodza.dev/docs/#print-license
// Next to this file: image-scale.css and image-scale.js, the component's CSS and JS from Kodza, as they are.
// Yours to edit: the markup is plain JSX below.
// The script changes this markup once React has rendered it (it adds layers, splits text, moves
// nodes), so React must not patch it afterwards. When a prop changes, the key gives React a fresh
// element: kodza:destroy stops the script on the old one, kodza:init starts it on the new one.
import { useRef, useEffect, type ComponentPropsWithoutRef, type ComponentRef, type CSSProperties } from 'react';
import './image-scale.css';
type Variant = "focus" | "parallax" | "round";
export type ImageHoverProps = Omit<ComponentPropsWithoutRef<'a'>, "children" | "variant" | "vars"> & {
/** Modifier class(es): .kodza-image-hover--focus, .kodza-image-hover--parallax, .kodza-image-hover--round (default: parallax, the one the script runs on; [] for none) */
variant?: Variant | Variant[];
/** Settings, as CSS variables on the root */
vars?: {
/** default: 4 / 5 */
"--kz-image-ratio"?: string | number;
/** default: 4px */
"--kz-image-radius"?: string | number;
/** default: 1.08 */
"--kz-image-zoom"?: string | number;
/** default: 1.1s */
"--kz-image-duration"?: string | number;
/** default: cubic-bezier(0.22, 1, 0.36, 1) */
"--kz-image-ease"?: string | number;
/** default: rgba(10, 10, 10, 0.06) */
"--kz-image-placeholder"?: string | number;
};
className?: string;
};
export function ImageHover({ variant = "parallax", vars, className, style, ...rest }: ImageHoverProps) {
const ref = useRef<ComponentRef<'a'>>(null);
const classes = ["kodza-image-hover", ...([] as string[]).concat(variant ?? []).map((v) => `kodza-image-hover--${v}`), className].filter(Boolean).join(' ');
// Everything the markup is made of: when it changes, React gets a fresh element (see the top)
const key = JSON.stringify([classes, vars, style, rest]);
// Starts the script on this element once React has rendered it, stops it when it goes
useEffect(() => {
const root = ref.current;
let live = true;
// @ts-ignore: a plain script, no types to find
import('./image-scale.js').then(() => {
if (live) document.dispatchEvent(new CustomEvent('kodza:init', { detail: { root } }));
});
return () => {
live = false;
document.dispatchEvent(new CustomEvent('kodza:destroy', { detail: { root } }));
};
}, [key]);
return (
<a href="#" key={key} {...rest} className={classes} style={{ ...vars, ...style } as CSSProperties} ref={ref}>
<img src="https://kodza.dev/media/kz-stack-1400.webp" alt="Three concrete slabs stacked at slightly different angles" loading="lazy" />
</a>
);
}
Checked
Robots poked at it before you did. Every component goes through the same checks, and again each time it changes.