Skip to content
Design System
GitHub

Text whose words point at places on a picture, as a vision-language model answers: a span highlights its boxes, a mark its words; `fromGrounding` reads a model's offsets and coordinates.

A worker in a high-visibility vest stands on the left of the aisle, beside a pallet of brown boxes. A yellow forklift is parked on the right, in front of the dark shelving.

Caption

Install
npx shadcn add @syncrobotic/grounded-text

Also installs: @syncrobotic/cn, @syncrobotic/annotated-image, @syncrobotic/use-reduced-motion, @syncrobotic/format-number

Overview

When to use

  • A vision-language model's caption, where each object's name matches a box.
  • A model's reasoning with grounding, where "8 zebras" is linked to 8 points.
  • A review or evaluation note beside an annotated frame.

Use something else

More examples

States and real uses. Each example is also a Storybook story and a visual regression test.

Reasoning

Narrow canvas

Two panels

Pinned

Many spans

Overlapping marks

Zh tw

Usage rules

  • For text that names places on a picture: a model's caption or reasoning, a review note. A picture with marks and no text is annotated-image.
  • Pass the model's offsets as they come (start, end, or fromGrounding for start_idx, end_idx and points or boxes in pixels, 0–1, percent or 0–1000). Spans must not overlap; a span that does starts where the one before ends.
  • Give every span the ids of all its marks, and every mark a span. A span whose marks are not on the picture is plain text.
  • Highlighting is the selected ink at 3 px with the rest faded, never a colour per span. In high contrast nothing fades; the width carries it.
  • Class words on the picture are off: the text names each mark. Turn on showLabels="selected" when the words differ from the text (a model's class next to a person's note).
  • The text is beside the picture from 42 rem of the component's own width (a 720 px canvas), under it when narrower. It follows its container, not the window: put it in the panel, not a wider wrapper.
  • When the screen already shows the picture in its own panel, use GroundedTextBody in the other and wire the one annotated-image with groundedImageProps: one picture on the page, never a second copy. Share pinned; the picture's onActiveChange goes to activeMark, the text's onActiveChange to activeSpan.
  • Pass the picture's panel as picture: pinning a span scrolls its marks into view there. Hovering never scrolls; reduced motion jumps.

Changelog

  • 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
  • 0.53.02026-11-27Its doc opens with its description, word for word; the code is unchanged.
  • 0.52.02026-11-27Uses the shared helper instead of its own copy; behaviour unchanged. Counts group thousands (1,200).

How to upgrade