Grounded text
v0.64.0, changelogBetaText 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.
API reference
Generated from the types. Every part also takes className.
GroundedTextBody
- textrequired
stringThe answer or caption. Line breaks are kept.- spansrequired
GroundedSpan[]- annotationsrequired
readonly Pick<Annotation, "id" | "shape">[]The marks the spans point at: the list given to the annotated-image (only each one'sidandshapeare read).- activeMark
string | null = nullThe mark under the pointer or keyboard on the picture (itsonActiveChange): the spans that point at it light up.- onActiveChange
(span: number | null) => voidThe span under the mouse, or else the one with keyboard focus (its index inspans);nullwhen neither. Touch does not hover: a tap pins. Give it togroundedImagePropsasactiveSpan.- defaultPinned
{ span: number } | { mark: string } | null = nullPinned at first (uncontrolled), or controlled withonPinnedChange. Control it when the picture is elsewhere, so a pinned mark lights its spans.- pinned
{ span: number } | { mark: string } | null- onPinnedChange
(pin: GroundedPin | null) => void- picture
RefObject<Element | null>The element around the linked annotated-image: pinning a span scrolls its marks into view there when they are scrolled out.- labels
Partial<GroundedTextLabels>
GroundedText
- textrequired
stringThe answer or caption. Line breaks are kept.- spansrequired
GroundedSpan[]- annotationsrequired
Annotation[]The marks the spans point at (points, boxes or any shape), in the picture's pixels.fromGroundingbuilds both.- src
stringThe picture, as in annotated-image:srcorimage, its naturalwidthandheight, and what it is inlabel.- image
ReactNode- widthrequired
number- heightrequired
number- labelrequired
string- showLabels
"none" | "all" | "selected" = "none"Class words on the picture. None by default: the text says what each mark is; "selected" shows the highlighted ones.- legend
boolean = falseannotated-image's line-style legend, for the kinds present. Off by default: a model's answer has one kind.- overlays
AnnotationOverlay[]- loading
boolean- defaultPinned
{ span: number } | { mark: string } | null = nullPinned at first (uncontrolled), or controlled withonPinnedChange.- pinned
{ span: number } | { mark: string } | null- onPinnedChange
(pin: GroundedPin | null) => void- labels
Partial<GroundedTextLabels>- imageLabels
Partial<AnnotatedImageLabels>annotated-image's words (annotatedImageLabelsin labels-zh-tw).