Skip to content

Annotate

The Annotate component (ui:annotate) renders a text area with highlight annotations. Users can select text and assign labels to create new annotations.

Examples

View Glyph Markdown source
```ui:annotate
title: Code Review
labels:
- name: Bug
color: "#dc2626"
- name: Unclear
color: "#f59e0b"
- name: Good
color: "#16a34a"
text: |
function processData(input) {
var result = input.split(',');
eval(result[0]);
return result;
}
annotations:
- start: 62
end: 78
label: Bug
note: eval() is dangerous
```

Prose text

Properties

PropertyTypeRequiredDefaultDescription
titlestringNoOptional heading.
labelsAnnotateLabel[]YesAvailable label categories.
textstringYesThe text content to annotate.
annotationsAnnotation[]No[]Pre-existing annotations.
markdownbooleanNofalseEnable inline markdown formatting (bold, italic, links, code) in text fields.

AnnotateLabel

PropertyTypeRequiredDescription
namestringYesLabel name.
colorstringYesCSS color for the label.

Annotation

PropertyTypeRequiredDescription
startnumberYesStart character offset.
endnumberYesEnd character offset.
labelstringYesLabel name.
notestringNoAnnotation note.

Markdown Support

Enable inline markdown formatting in annotation notes:

View Glyph Markdown source
```ui:annotate
title: Code Review
labels:
- name: Bug
color: "#dc2626"
- name: Unclear
color: "#f59e0b"
- name: Good
color: "#16a34a"
text: |
function processData(input) {
var result = input.split(',');
eval(result[0]);
return result;
}
annotations:
- start: 62
end: 78
label: Bug
note: "**eval()** is dangerous. See [MDN security docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!)."
- start: 28
end: 31
label: Unclear
note: "Use `let` or `const` instead of *var*"
markdown: true
```

Supported formatting: bold, italic, code, links

Learn more about markdown in components →

Interaction events

Event kind: annotate-create

Payload fieldTypeDescription
startnumberStart offset.
endnumberEnd offset.
selectedTextstringThe annotated text.
labelstringAssigned label.
allAnnotationsArray<{ start, end, text, label }>Full annotations state.

Accessibility

  • Text area uses role="document".
  • Annotations rendered as <mark> elements.
  • Label picker uses role="menu" with role="menuitem".
  • Sidebar uses role="complementary" with a role="list" for annotations.