Image Hotspots
ComponentsImage Hotspots
SectionsNew

Image Hotspots

Clickable image annotations with detail cards that stay inside the image and move below it on small screens.

USE IT FORShoppable room photographsArchitectural material annotationsProduct feature diagrams
React + CSS
Explore the full-width experienceOpen preview

Material study

Select a point to inspect
Coastal house with a rectangular concrete upper floor, recessed panoramic glazing, and a stone terrace
01

Concrete shell

Board-formed concrete preserves the grain and joins of its timber mould.

Live component. Go ahead, interact.
01

Installation

Run this in your shadcn-configured React project. The component and stylesheet are added together.

TERMINAL
npx shadcn@latest add http://localhost:5173/r/image-hotspots.json

This command uses the current site address. For localhost, keep this preview running on the same computer. Files follow your configured components alias.

02

Usage

Import the component and make the details your own.

TypeScript
import { ImageHotspots } from '@/components/anticraft/ImageHotspots';

export function Example() {
  return (
    <ImageHotspots
      image="/images/room.jpg"
      alt="Reading corner with an oak chair and a floor lamp"
      items={[
        {
          id: 'chair', label: 'Oak lounge chair', x: 0.35, y: 0.6,
          description: 'Solid oak frame with a woven linen seat.',
          price: '$480',
          action: { label: 'View chair', href: '/products/oak-lounge-chair' },
        },
        {
          id: 'lamp', label: 'Arc floor lamp', x: 0.76, y: 0.22,
          description: 'A brushed steel arm with an adjustable shade.',
        },
      ]}
    />
  );
}
03

Props

PropTypeDefaultDescription
image / altstringRequiredImage source and meaningful alternative text. The image preserves its intrinsic proportions without cropping, so marker positions stay aligned. Supply your own file for the example image path.
itemsImageHotspotItem[]RequiredAnnotations with unique id, accessible label, and normalized x/y coordinates from 0 to 1. Optional title replaces the visible label in the detail card. Optional description, preformatted price, and action { label, href } add information. Coordinates are clamped to the image edges; invalid numbers fall back to the centre.
defaultActiveIdstringundefinedInitially expanded annotation id. An unknown or removed id displays no card. Current content is derived from the supplied items, so edits do not leave stale detail text.
captionstringundefinedOptional image caption beneath the annotation area.
onActiveChange(item: ImageHotspotItem | null) => voidundefinedReceives the selected annotation after a visitor opens it, or null when they close it. Data changes do not notify. Pass callbacks from a Client Component in Next.js.
classNamestring''Additional classes. Theme with --ac-hotspots-surface, --ac-hotspots-ink, --ac-hotspots-muted, --ac-hotspots-accent, and --ac-hotspots-line. The component uses its container width, independent of the page viewport.
04

Motion & accessibility

Considered by default.

Click or activate a marker with Enter or Space to toggle its detail. One annotation is open at a time. Escape and the card’s Close button close it and return focus to its marker; clicking or focusing outside closes it without moving focus. The card is a nonmodal labelled region with ordinary links. At widths below 560px it sits beneath the image; larger containers clamp the measured card inside the image. Reduced motion removes the short entrance and marker transition. Use unique item ids and uncropped source images. The demo uses Anticraft’s existing fictional architectural study.

Use semantic content and meaningful labels in your composition. Check contrast and keyboard behavior with your own styles and content.