Image Annotator

View as Markdown

Numbered notes pinned to places on a picture, listed beside it, such as feedback on a design or a bug on a screenshot.

Click the picture to add a note.
A checkout page: a card form with a Pay button, and the order beside it

3 open notes

  1. Priya Raman2h ago

    The Pay button looks disabled while it isn't. Use the accent color.

  2. Wei Chen1h ago

    Card number needs the card brand's mark once it's typed.

  3. Tomás García20m ago

    This line fails contrast. Darken it, and link the terms.

Press Add a note to place one with the keyboard.

When to use

Numbered notes pinned to places on a picture, listed beside it, such as feedback on a design or a bug on a screenshot. Use Canvas instead when people draw and arrange shapes, not leave notes on a fixed picture.

Usage

import { ImageAnnotator, type ImageNote } from "./ui/uicontext/components/ImageAnnotator.ts"
export const Review = <M>(h: Html.H<M>, src: string, notes: ReadonlyArray<ImageNote>, onAdd: (x: number, y: number, text: string) => M, onResolve: (id: string, resolved: boolean) => M) =>	ImageAnnotator(h, {		props: { label: "Design review", src, alt: "The design under review", notes },		onEmit: {			RequestedAdd: ({ x, y, text }) => onAdd(x, y, text),			RequestedResolve: ({ id, resolved }) => onResolve(id, resolved),		},	})

Examples

Read only

readOnly keeps the notes for reading: no adding, no resolving.

Read only
The checkout page as the customer saw it

2 open notes

  1. Customer

    Pressed Pay three times, nothing happened.

  2. Support

    Total is right; the card was charged once.

API reference

Props

ImageAnnotator props
NameTypeDescription
labelrequiredstringWhat the picture is: "Checkout screen, v3".
srcrequiredstring—
altrequiredstring—
notesrequiredImageNote[]—
readOnlybooleanNotes can't be added or resolved: a review that's closed.
localestringFor the counts; the browser's by default.

Events

ImageAnnotator events
EventPayloadDescription
RequestedAdd{ x: number; y: number; text: string }A note was written: where it goes and what it says.
RequestedResolve{ id: string; resolved: boolean }Resolve or Reopen was pressed on a note.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/image-annotator

Source