Skip to main content
The HighlightedText component displays text with spans highlighted by category or confidence value.

Basic usage

Constructor

list[tuple[str, str | float | None]] | dict | Callable | None
default:"None"
Highlighted text as:
  • List of (text, label) tuples
  • Dict with "text" and "entities" keys (Hugging Face format)
dict[str, str] | None
default:"None"
Dictionary mapping labels to colors (e.g., {"PER": "red", "LOC": "#00FF00"})
bool
default:"False"
Whether to show category legend separately
bool
default:"True"
If False, doesn’t display label inline. Only applies when show_legend=False
bool
default:"False"
If True, merges adjacent tokens with same category
str
default:"''"
Separator between adjacent tokens when combine_adjacent=True
bool
default:"True"
If False, strips leading/trailing whitespace from tokens
bool
default:"False"
If True, displays text right-to-left

Events

  • change - Triggered when highlighted text changes
  • select - Triggered when span is selected

Examples

Named Entity Recognition

Sentiment scores

HuggingFace format