Skip to main content

A simple component to display annotated text in Streamlit apps.

Project description

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

st_annotated_text-4.0.2.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

st_annotated_text-4.0.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file st_annotated_text-4.0.2.tar.gz.

File metadata

  • Download URL: st_annotated_text-4.0.2.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for st_annotated_text-4.0.2.tar.gz
Algorithm Hash digest
SHA256 b0134dcf734697cc3dbdb11862c4174071e7fb6f365af55a37c710d357fd88a5
MD5 2cd58527254cb906919ee629395d6212
BLAKE2b-256 4d76c0f64a56b779bfb5c87437687a9970d12dad37b5aea2541823d0c5010818

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_annotated_text-4.0.2.tar.gz:

Publisher: publish.yml on tvst/st-annotated-text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file st_annotated_text-4.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for st_annotated_text-4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 712c45821f020eccafad3a58c10b9d2d51d449f4db999a06308ecf39a753a4df
MD5 1f1a2676358b657f98e25086400044fe
BLAKE2b-256 d970f29d4359ddfd1a0afa00065e4dac32bd4931f589185f5f0f499db9aee4fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for st_annotated_text-4.0.2-py3-none-any.whl:

Publisher: publish.yml on tvst/st-annotated-text

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page