Skip to main content

Annotated Text Component for Streamlit

A simple component to display annotated text in Streamlit apps. For example:

Example image

Or, even better, check out our demo app here:

Open in Streamlit

Installation

First install Streamlit (of course!) then pip-install this library:

pip install streamlit
pip install st-annotated-text

Example

import streamlit as st
from annotated_text import annotated_text

annotated_text(
    "This ",
    ("is", "verb"),
    " some ",
    ("annotated", "adj"),
    ("text", "noun"),
    " for those of ",
    ("you", "pronoun"),
    " who ",
    ("like", "verb"),
    " this sort of ",
    ("thing", "noun"),
    "."
)

For more examples, including :sparkles:customization options:sparkles:, see the demo app.

Parameters

The annotated_text() function accepts any number of the following arguments:

  • strings, to draw the string as-is on the screen.
  • tuples of the form (main_text, annotation_text, background, color) where background and foreground colors are optional and should be an CSS-valid string such as "#aabbcc" or "rgb(10, 20, 30)"
  • htbuilder.HtmlElement objects in case you want to customize the annotations further. In particular, you can import the annotation() function from this module to easily produce annotations whose CSS you can customize via keyword arguments.
  • lists of any of the above -- or of lists!

Release files for st-annotated-text 4.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for st-annotated-text 4.0.2
File Size Uploaded
st_annotated_text-4.0.2.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for st-annotated-text 4.0.2
File Interpreter ABI Platform
st_annotated_text-4.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / st_annotated_text-4.0.2.tar.gz

Download URL st_annotated_text-4.0.2.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b0134dcf734697cc3dbdb11862c4174071e7fb6f365af55a37c710d357fd88a5
BLAKE2b-256 checksum
How to use checksums
4d76c0f64a56b779bfb5c87437687a9970d12dad37b5aea2541823d0c5010818
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 23, 2025.

Transparency log

Release files / st_annotated_text-4.0.2-py3-none-any.whl

Download URL st_annotated_text-4.0.2-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
712c45821f020eccafad3a58c10b9d2d51d449f4db999a06308ecf39a753a4df
BLAKE2b-256 checksum
How to use checksums
d970f29d4359ddfd1a0afa00065e4dac32bd4931f589185f5f0f499db9aee4fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 23, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

4.0.2 This release

2 release files

4.0.1

2 release files

4.0.0

1 release file

3.0.0

1 release file

2.0.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page